Re: Pagecache: find_or_create_page does not call a proper page allocator function

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Morton <akpm@...>
Cc: Christoph Lameter <clameter@...>, Nick Piggin <npiggin@...>, <linux-kernel@...>, <pj@...>
Date: Tuesday, April 24, 2007 - 9:09 am

On Mon, 23 Apr 2007, Andrew Morton wrote:

I've not yet looked at the patch under discussion, but this remark
prompts me...  a couple of days ago I got very worried by the various
hard-wired GFP_HIGHUSER allocations in mm/migrate.c and mm/mempolicy.c,
and wondered how those would work out if someone has a blockdev mmap'ed.

I tried to test it out before sending a patch, but found no problem at
all: maybe I was too timid (fearing to corrupt my whole system), maybe 
I've forgotten how that stuff works and wasn't doing the right thing
to reproduce it (I was mmap'ing /dev/sdb1 readonly, at the same time
as having it mounted as ext2 - when I forced migration to random pages,
then cp'ed /dev/zero to reuse the old pages, I was expecting ext2 to
get very upset with its metadata; mmap'ing while mounted isn't very
realistic, but my earlier sequence hadn't shown any problem either,
so I thought the cache got invalidated in between).

Here's the patch I'd suggest adding if you believe there really is
a problem there: it's far from ideal (I can imagine mapping_gfp_mask
being used to enforce other restrictions, but the __GFP_HIGHMEM issue
seems to be the only one in practice; and it would be a shame to
restrict all the architectures which have no concept of HIGHMEM).
If there's no such problem, sorry for wasting your time.

(If vma->vm_file is non-NULL, we can be sure vma->vm_file->f_mapping
is non-NULL, can't we?  Some common code assumes that, some does not:
I've avoided cargo-cult safety below, but don't let me make it unsafe.)


Is there a problem with page migration to HIGHMEM, if pages were
mapped from a GFP_USER block device?  I failed to demonstrate any
problem, but here's a quick fix if needed.

Signed-off-by: Hugh Dickins <hugh@veritas.com>

--- 2.6.21-rc7/include/linux/migrate.h	2007-03-07 13:08:59.000000000 +0000
+++ linux/include/linux/migrate.h	2007-04-24 13:18:31.000000000 +0100
@@ -2,6 +2,7 @@
 #define _LINUX_MIGRATE_H
 
 #include <linux/mm.h>
+#include <linux/pagemap.h>
 
 typedef struct page *new_page_t(struct page *, unsigned long private, int **);
 
@@ -10,6 +11,13 @@ static inline int vma_migratable(struct 
 {
 	if (vma->vm_flags & (VM_IO|VM_HUGETLB|VM_PFNMAP|VM_RESERVED))
 		return 0;
+#ifdef CONFIG_HIGHMEM
+	if (vma->vm_file) {
+		struct address_space *mapping = vma->vm_file->f_mapping;
+		if (!(mapping_gfp_mask(mapping) & __GFP_HIGHMEM))
+			return 0;
+	}
+#endif
 	return 1;
 }
 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Pagecache: find_or_create_page does not call a proper page a..., Christoph Lameter, (Mon Apr 23, 5:11 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Mon Apr 23, 6:33 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Hugh Dickins, (Tue Apr 24, 9:09 am)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 1:45 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 3:34 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 3:59 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 4:12 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 1:38 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 1:56 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 1:48 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 3:55 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 4:30 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 4:44 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 4:58 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Tue Apr 24, 5:28 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Mon Apr 23, 6:42 pm)
Re: Pagecache: find_or_create_page does not call a proper pa..., Christoph Lameter, (Mon Apr 23, 5:37 pm)