[Patch] Hotfix for Re: wrong madvise(MADV_DONTNEED) semantic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 28 June 2005 15:43:16 +0200, Samuel Thibault wrote:
> 
> There is something wrong with the current madvise(MADV_DONTNEED)
> implementation. Both the manpage and the source code says that
> MADV_DONTNEED means that the application does not care about the data,
> so it might be thrown away by the kernel. But that's not what posix
> says:
> 
> http://www.opengroup.org/onlinepubs/009695399/functions/posix_madvise.html
> 
> It says that "The posix_madvise() function shall have no effect on the
> semantics of access to memory in the specified range". I.e. the data
> that was recorded shall be saved!
> 
> The current linux implementation of MADV_DONTNEED is rather an
> implementation of solaris' MADV_FREE, see its manpage:
> http://docs.sun.com/app/docs/doc/816-5168/6mbb3hrde?a=view
> 
> Hence the current madvise_dontneed() implementation could be renamed
> into madvise_free() and the appropriate MADV_FREE case be added, while
> a new implementation of madvise_dontneed() _needs_ be written. It may
> for instance go through the range so as to zap clean pages (since it is
> safe), and set dirty pages as being least recently used so that they
> will be considered as good candidates for eviction.

Agreed.  Unless someone else comes up with something better soon, you
can use below patch.

Akpm, would you merge this?

Jörn

-- 
The story so far:
In the beginning the Universe was created.  This has made a lot
of people very angry and been widely regarded as a bad move.
-- Douglas Adams


Signed-off-by: Jörn Engel <[email protected]>
---

 mm/madvise.c |    4 ++++
 1 files changed, 4 insertions(+)

--- linux-2.6.12-rc4logfs/mm/madvise.c~madvice_bug	2005-03-04 11:40:50.000000000 +0100
+++ linux-2.6.12-rc4logfs/mm/madvise.c	2005-06-28 16:34:54.000000000 +0200
@@ -97,6 +97,10 @@ static long madvise_willneed(struct vm_a
 static long madvise_dontneed(struct vm_area_struct * vma,
 			     unsigned long start, unsigned long end)
 {
+	return 0;
+	/* Really ugly bugfix - madvice may never change anything
+	 * beyond performance.  Dropping dirty pages is right out.
+	 */
 	if ((vma->vm_flags & VM_LOCKED) || is_vm_hugetlb_page(vma))
 		return -EINVAL;
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux