Commit e1b6aa6f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] slab: clean up kmem_getpages

The last ifdef addition hit the ugliness treshold on this functions, so:

 - rename the variable i to nr_pages so it's somewhat descriptive
 - remove the addr variable and do the page_address call at the very end
 - instead of ifdef'ing the whole alloc_pages_node call just make the
   __GFP_COMP addition to flags conditional
 - rewrite the __GFP_COMP comment to make sense
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a43a8c39
...@@ -1489,31 +1489,29 @@ __initcall(cpucache_init); ...@@ -1489,31 +1489,29 @@ __initcall(cpucache_init);
static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid) static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
{ {
struct page *page; struct page *page;
void *addr; int nr_pages;
int i; int i;
flags |= cachep->gfpflags;
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
/* nommu uses slab's for process anonymous memory allocations, so /*
* requires __GFP_COMP to properly refcount higher order allocations" * Nommu uses slab's for process anonymous memory allocations, and thus
* requires __GFP_COMP to properly refcount higher order allocations
*/ */
page = alloc_pages_node(nodeid, (flags | __GFP_COMP), cachep->gfporder); flags |= __GFP_COMP;
#else
page = alloc_pages_node(nodeid, flags, cachep->gfporder);
#endif #endif
flags |= cachep->gfpflags;
page = alloc_pages_node(nodeid, flags, cachep->gfporder);
if (!page) if (!page)
return NULL; return NULL;
addr = page_address(page);
i = (1 << cachep->gfporder); nr_pages = (1 << cachep->gfporder);
if (cachep->flags & SLAB_RECLAIM_ACCOUNT) if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
atomic_add(i, &slab_reclaim_pages); atomic_add(nr_pages, &slab_reclaim_pages);
add_page_state(nr_slab, i); add_page_state(nr_slab, nr_pages);
while (i--) { for (i = 0; i < nr_pages; i++)
__SetPageSlab(page); __SetPageSlab(page + i);
page++; return page_address(page);
}
return addr;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment