From: Dave Hansen <haveblue@us.ibm.com>
To: linux-mm <linux-mm@kvack.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [RFC][PATCH] make all non-file-backed madvise() calls fail
Date: Fri, 01 Apr 2005 11:43:00 -0800 [thread overview]
Message-ID: <1112384580.12201.30.camel@localhost> (raw)
[-- Attachment #1: Type: text/plain, Size: 483 bytes --]
This is related to this bug:
http://bugme.osdl.org/show_bug.cgi?id=2995
The kernel currently only checks that the memory is file-backed if
MADV_WILLNEED is set. It's not entirely clear from the manpage at least
that *all* non-file-backed madvise() calls should fail.
The attached patch returns -EBADF for all non-file-backed madvise()
calls. I'm not suggesting that this is the absolutely right behavior,
but it certainly does what the bug submitter wants.
Comments?
-- Dave
[-- Attachment #2: madvise-allebadf.patch --]
[-- Type: text/x-patch, Size: 1022 bytes --]
--- mm/madvise.c.orig 2005-04-01 10:40:59.000000000 -0800
+++ mm/madvise.c 2005-04-01 10:56:50.000000000 -0800
@@ -58,13 +58,9 @@
* Schedule all required I/O operations. Do not wait for completion.
*/
static long madvise_willneed(struct vm_area_struct * vma,
- unsigned long start, unsigned long end)
+ unsigned long start, unsigned long end,
+ struct file *file)
{
- struct file *file = vma->vm_file;
-
- if (!file)
- return -EBADF;
-
start = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
if (end > vma->vm_end)
end = vma->vm_end;
@@ -115,6 +111,10 @@
unsigned long end, int behavior)
{
long error = -EBADF;
+ struct file *file = vma->vm_file;
+
+ if (!file)
+ goto out;
switch (behavior) {
case MADV_NORMAL:
@@ -124,7 +124,7 @@
break;
case MADV_WILLNEED:
- error = madvise_willneed(vma, start, end);
+ error = madvise_willneed(vma, start, end, file);
break;
case MADV_DONTNEED:
@@ -136,6 +136,7 @@
break;
}
+out:
return error;
}
reply other threads:[~2005-04-01 19:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1112384580.12201.30.camel@localhost \
--to=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox