[RFC 2/8] Basic allocation for higher order page cache pages

From: Christoph Lameter
Date: Thu Apr 19 2007 - 12:36:49 EST


Variable Order Page Cache: Add basic allocation functions

Extend __page_cache_alloc to take an order parameter and
modify caller sites. Modify mapping_set_gfp_mask to set
__GFP_COMP if the mapping requires higher order allocations.

put_page() is already capable of handling compound pages. So
there are no changes needed to release higher order page
cache pages.

Signed-off-by: Christoph Lameter <clameter@xxxxxxx>

---
include/linux/pagemap.h | 15 +++++++++------
mm/filemap.c | 9 +++++----
2 files changed, 14 insertions(+), 10 deletions(-)

Index: linux-2.6.21-rc7/include/linux/pagemap.h
===================================================================
--- linux-2.6.21-rc7.orig/include/linux/pagemap.h 2007-04-18 21:21:56.000000000 -0700
+++ linux-2.6.21-rc7/include/linux/pagemap.h 2007-04-18 21:29:02.000000000 -0700
@@ -32,6 +32,8 @@ static inline void mapping_set_gfp_mask(
{
m->flags = (m->flags & ~(__force unsigned long)__GFP_BITS_MASK) |
(__force unsigned long)mask;
+ if (m->order)
+ m->flags |= __GFP_COMP;
}

/*
@@ -40,7 +42,7 @@ static inline void mapping_set_gfp_mask(
* throughput (it can then be mapped into user
* space in smaller chunks for same flexibility).
*
- * Or rather, it _will_ be done in larger chunks.
+ * This is the base page size
*/
#define PAGE_CACHE_SHIFT PAGE_SHIFT
#define PAGE_CACHE_SIZE PAGE_SIZE
@@ -52,22 +54,23 @@ static inline void mapping_set_gfp_mask(
void release_pages(struct page **pages, int nr, int cold);

#ifdef CONFIG_NUMA
-extern struct page *__page_cache_alloc(gfp_t gfp);
+extern struct page *__page_cache_alloc(gfp_t gfp, int order);
#else
-static inline struct page *__page_cache_alloc(gfp_t gfp)
+static inline struct page *__page_cache_alloc(gfp_t gfp, int order)
{
- return alloc_pages(gfp, 0);
+ return alloc_pages(gfp, order);
}
#endif

static inline struct page *page_cache_alloc(struct address_space *x)
{
- return __page_cache_alloc(mapping_gfp_mask(x));
+ return __page_cache_alloc(mapping_gfp_mask(x), x->order);
}

static inline struct page *page_cache_alloc_cold(struct address_space *x)
{
- return __page_cache_alloc(mapping_gfp_mask(x)|__GFP_COLD);
+ return __page_cache_alloc(mapping_gfp_mask(x)|__GFP_COLD,
+ x->order);
}

typedef int filler_t(void *, struct page *);
Index: linux-2.6.21-rc7/mm/filemap.c
===================================================================
--- linux-2.6.21-rc7.orig/mm/filemap.c 2007-04-18 21:21:56.000000000 -0700
+++ linux-2.6.21-rc7/mm/filemap.c 2007-04-18 21:28:30.000000000 -0700
@@ -467,13 +467,13 @@ int add_to_page_cache_lru(struct page *p
}

#ifdef CONFIG_NUMA
-struct page *__page_cache_alloc(gfp_t gfp)
+struct page *__page_cache_alloc(gfp_t gfp, int order)
{
if (cpuset_do_page_mem_spread()) {
int n = cpuset_mem_spread_node();
- return alloc_pages_node(n, gfp, 0);
+ return alloc_pages_node(n, gfp, order);
}
- return alloc_pages(gfp, 0);
+ return alloc_pages(gfp, order);
}
EXPORT_SYMBOL(__page_cache_alloc);
#endif
@@ -803,7 +803,8 @@ grab_cache_page_nowait(struct address_sp
page_cache_release(page);
return NULL;
}
- page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~__GFP_FS);
+ page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~__GFP_FS,
+ mapping->order);
if (page && add_to_page_cache_lru(page, mapping, index, GFP_KERNEL)) {
page_cache_release(page);
page = NULL;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/