From: Martin Hicks When using the early zone reclaim, it was noticed that allocating new pages that should be spread across the whole system caused eviction of local pages. This adds a new GFP flag to prevent early reclaim from happening during certain allocation attempts. The example that is implemented here is for page cache pages. We want page cache pages to be spread across the whole system, and we don't want page cache pages to evict other pages to get local memory. Signed-off-by: Martin Hicks Signed-off-by: Andrew Morton --- include/linux/gfp.h | 3 ++- include/linux/pagemap.h | 4 ++-- mm/page_alloc.c | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff -puN include/linux/gfp.h~vm-add-__gfp_noreclaim include/linux/gfp.h --- 25/include/linux/gfp.h~vm-add-__gfp_noreclaim 2005-06-05 22:07:17.000000000 -0700 +++ 25-akpm/include/linux/gfp.h 2005-06-05 22:07:17.000000000 -0700 @@ -39,6 +39,7 @@ struct vm_area_struct; #define __GFP_COMP 0x4000u /* Add compound page metadata */ #define __GFP_ZERO 0x8000u /* Return zeroed page on success */ #define __GFP_NOMEMALLOC 0x10000u /* Don't use emergency reserves */ +#define __GFP_NORECLAIM 0x20000u /* No realy zone reclaim during allocation */ #define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ #define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1) @@ -47,7 +48,7 @@ struct vm_area_struct; #define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \ - __GFP_NOMEMALLOC) + __GFP_NOMEMALLOC|__GFP_NORECLAIM) #define GFP_ATOMIC (__GFP_HIGH) #define GFP_NOIO (__GFP_WAIT) diff -puN include/linux/pagemap.h~vm-add-__gfp_noreclaim include/linux/pagemap.h --- 25/include/linux/pagemap.h~vm-add-__gfp_noreclaim 2005-06-05 22:07:17.000000000 -0700 +++ 25-akpm/include/linux/pagemap.h 2005-06-05 22:07:17.000000000 -0700 @@ -52,12 +52,12 @@ void release_pages(struct page **pages, static inline struct page *page_cache_alloc(struct address_space *x) { - return alloc_pages(mapping_gfp_mask(x), 0); + return alloc_pages(mapping_gfp_mask(x)|__GFP_NORECLAIM, 0); } static inline struct page *page_cache_alloc_cold(struct address_space *x) { - return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0); + return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD|__GFP_NORECLAIM, 0); } typedef int filler_t(void *, struct page *); diff -puN mm/page_alloc.c~vm-add-__gfp_noreclaim mm/page_alloc.c --- 25/mm/page_alloc.c~vm-add-__gfp_noreclaim 2005-06-05 22:07:17.000000000 -0700 +++ 25-akpm/mm/page_alloc.c 2005-06-05 22:07:17.000000000 -0700 @@ -729,6 +729,8 @@ check_zone_reclaim(struct zone *z, unsig { if (!z->reclaim_pages) return 0; + if (gfp_mask & __GFP_NORECLAIM) + return 0; return 1; } _