All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] BUG #3054 madvise doesn't fail for exceding RSS limit.
@ 2005-06-04 22:50 Matt
  2005-06-04 22:56 ` Matt
  0 siblings, 1 reply; 2+ messages in thread
From: Matt @ 2005-06-04 22:50 UTC (permalink / raw)
  To: linux-kernel

Patch that fixes bug #3054. Compiles, tests ok.

--- linux-2.6.11.10/mm/madvise.c 2005-05-12 15:58:30.000000000 +0100
+++ linux/mm/madvise.c  2005-06-04 23:25:03.000000000 +0100
@@ -70,6 +70,17 @@
                end = vma->vm_end;
        end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;

+       /*
+        * This doesn't account for pages that may already be mapped
+        * due to readahead, but since this is merely a hint to the
+        * kernel no real harm should be done, it will just make things
+        * run a little slower. Sometimes less is more! More than enough
+        * code for this minor corner case.
+        */
+       if (((max_sane_readahead(end-start) << 
PAGE_SHIFT)+current->mm->rss)>
+           current->signal->rlim[RLIMIT_RSS].rlim_cur)
+               return -ENOMEM;
+
        force_page_cache_readahead(file->f_mapping,
                        file, start, max_sane_readahead(end - start));
        return 0;


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] BUG #3054 madvise doesn't fail for exceding RSS limit.
  2005-06-04 22:50 [PATCH] BUG #3054 madvise doesn't fail for exceding RSS limit Matt
@ 2005-06-04 22:56 ` Matt
  0 siblings, 0 replies; 2+ messages in thread
From: Matt @ 2005-06-04 22:56 UTC (permalink / raw)
  Cc: linux-kernel

sorry that error return should be -EIO not -ENOMEM, sorry! new patch 
attached.

--- linux-2.6.11.10/mm/madvise.c 2005-04-12 15:58:30.000000000 +0100
+++ linux/mm/madvise.c  2005-06-04 23:25:03.000000000 +0100
@@ -70,6 +70,17 @@
                end = vma->vm_end;
        end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;

+       /*
+        * This doesn't account for pages that may already be mapped
+        * due to readahead, but since this is merely a hint to the
+        * kernel no real harm should be done, it will just make things
+        * run a little slower. Sometimes less is more! More than enough
+        * code for this minor corner case.
+        */
+       if (((max_sane_readahead(end-start) << 
PAGE_SHIFT)+current->mm->rss)>
+           current->signal->rlim[RLIMIT_RSS].rlim_cur)
+               return -EIO;
+
        force_page_cache_readahead(file->f_mapping,
                        file, start, max_sane_readahead(end - start));
        return 0;


Matt wrote:

> Patch that fixes bug #3054. Compiles, tests ok.
>
> --- linux-2.6.11.10/mm/madvise.c 2005-05-12 15:58:30.000000000 +0100
> +++ linux/mm/madvise.c  2005-06-04 23:25:03.000000000 +0100
> @@ -70,6 +70,17 @@
>                end = vma->vm_end;
>        end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
>
> +       /*
> +        * This doesn't account for pages that may already be mapped
> +        * due to readahead, but since this is merely a hint to the
> +        * kernel no real harm should be done, it will just make things
> +        * run a little slower. Sometimes less is more! More than enough
> +        * code for this minor corner case.
> +        */
> +       if (((max_sane_readahead(end-start) << 
> PAGE_SHIFT)+current->mm->rss)>
> +           current->signal->rlim[RLIMIT_RSS].rlim_cur)
> +               return -ENOMEM;
> +
>        force_page_cache_readahead(file->f_mapping,
>                        file, start, max_sane_readahead(end - start));
>        return 0;
>
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-06-04 22:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-04 22:50 [PATCH] BUG #3054 madvise doesn't fail for exceding RSS limit Matt
2005-06-04 22:56 ` Matt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.