diff options
author | Pekka Enberg <penberg@cs.helsinki.fi> | 2006-06-23 05:03:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 10:42:46 -0400 |
commit | 4776874ff096cd410382c0eca5d75f69c9dfa58f (patch) | |
tree | 50501cc3d909b03c1e792ac203aa3b56641cd226 /mm | |
parent | f886ed443fedb109e2062988bf120a531f0ec80a (diff) |
[PATCH] slab: page mapping cleanup
Clean up slab allocator page mapping a bit. The memory allocated for a
slab is physically contiguous so it is okay to assume struct pages are too
so kill the long-standing comment. Furthermore, rename set_slab_attr to
slab_map_pages and add a comment explaining why its needed.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slab.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -2499,23 +2499,28 @@ static void slab_put_obj(struct kmem_cache *cachep, struct slab *slabp, | |||
2499 | slabp->inuse--; | 2499 | slabp->inuse--; |
2500 | } | 2500 | } |
2501 | 2501 | ||
2502 | static void set_slab_attr(struct kmem_cache *cachep, struct slab *slabp, | 2502 | /* |
2503 | void *objp) | 2503 | * Map pages beginning at addr to the given cache and slab. This is required |
2504 | * for the slab allocator to be able to lookup the cache and slab of a | ||
2505 | * virtual address for kfree, ksize, kmem_ptr_validate, and slab debugging. | ||
2506 | */ | ||
2507 | static void slab_map_pages(struct kmem_cache *cache, struct slab *slab, | ||
2508 | void *addr) | ||
2504 | { | 2509 | { |
2505 | int i; | 2510 | int nr_pages; |
2506 | struct page *page; | 2511 | struct page *page; |
2507 | 2512 | ||
2508 | /* Nasty!!!!!! I hope this is OK. */ | 2513 | page = virt_to_page(addr); |
2509 | page = virt_to_page(objp); | ||
2510 | 2514 | ||
2511 | i = 1; | 2515 | nr_pages = 1; |
2512 | if (likely(!PageCompound(page))) | 2516 | if (likely(!PageCompound(page))) |
2513 | i <<= cachep->gfporder; | 2517 | nr_pages <<= cache->gfporder; |
2518 | |||
2514 | do { | 2519 | do { |
2515 | page_set_cache(page, cachep); | 2520 | page_set_cache(page, cache); |
2516 | page_set_slab(page, slabp); | 2521 | page_set_slab(page, slab); |
2517 | page++; | 2522 | page++; |
2518 | } while (--i); | 2523 | } while (--nr_pages); |
2519 | } | 2524 | } |
2520 | 2525 | ||
2521 | /* | 2526 | /* |
@@ -2587,7 +2592,7 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid) | |||
2587 | goto opps1; | 2592 | goto opps1; |
2588 | 2593 | ||
2589 | slabp->nodeid = nodeid; | 2594 | slabp->nodeid = nodeid; |
2590 | set_slab_attr(cachep, slabp, objp); | 2595 | slab_map_pages(cachep, slabp, objp); |
2591 | 2596 | ||
2592 | cache_init_objs(cachep, slabp, ctor_flags); | 2597 | cache_init_objs(cachep, slabp, ctor_flags); |
2593 | 2598 | ||