diff options
author | Christoph Hellwig <hch@lst.de> | 2006-06-23 05:03:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 10:42:48 -0400 |
commit | e1b6aa6f1404f162697650df2cdb6c374b1d6a5b (patch) | |
tree | 5d7f93f6d9a315b66fbc2bcfb7cc5d866a7013e9 /mm/slab.c | |
parent | a43a8c39bbb493c9e93f6764b350de2e33e18e92 (diff) |
[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: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 30 |
1 files changed, 14 insertions, 16 deletions
@@ -1489,31 +1489,29 @@ __initcall(cpucache_init); | |||
1489 | static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid) | 1489 | static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid) |
1490 | { | 1490 | { |
1491 | struct page *page; | 1491 | struct page *page; |
1492 | void *addr; | 1492 | int nr_pages; |
1493 | int i; | 1493 | int i; |
1494 | 1494 | ||
1495 | flags |= cachep->gfpflags; | ||
1496 | #ifndef CONFIG_MMU | 1495 | #ifndef CONFIG_MMU |
1497 | /* nommu uses slab's for process anonymous memory allocations, so | 1496 | /* |
1498 | * requires __GFP_COMP to properly refcount higher order allocations" | 1497 | * Nommu uses slab's for process anonymous memory allocations, and thus |
1498 | * requires __GFP_COMP to properly refcount higher order allocations | ||
1499 | */ | 1499 | */ |
1500 | page = alloc_pages_node(nodeid, (flags | __GFP_COMP), cachep->gfporder); | 1500 | flags |= __GFP_COMP; |
1501 | #else | ||
1502 | page = alloc_pages_node(nodeid, flags, cachep->gfporder); | ||
1503 | #endif | 1501 | #endif |
1502 | flags |= cachep->gfpflags; | ||
1503 | |||
1504 | page = alloc_pages_node(nodeid, flags, cachep->gfporder); | ||
1504 | if (!page) | 1505 | if (!page) |
1505 | return NULL; | 1506 | return NULL; |
1506 | addr = page_address(page); | ||
1507 | 1507 | ||
1508 | i = (1 << cachep->gfporder); | 1508 | nr_pages = (1 << cachep->gfporder); |
1509 | if (cachep->flags & SLAB_RECLAIM_ACCOUNT) | 1509 | if (cachep->flags & SLAB_RECLAIM_ACCOUNT) |
1510 | atomic_add(i, &slab_reclaim_pages); | 1510 | atomic_add(nr_pages, &slab_reclaim_pages); |
1511 | add_page_state(nr_slab, i); | 1511 | add_page_state(nr_slab, nr_pages); |
1512 | while (i--) { | 1512 | for (i = 0; i < nr_pages; i++) |
1513 | __SetPageSlab(page); | 1513 | __SetPageSlab(page + i); |
1514 | page++; | 1514 | return page_address(page); |
1515 | } | ||
1516 | return addr; | ||
1517 | } | 1515 | } |
1518 | 1516 | ||
1519 | /* | 1517 | /* |