slab: fix calculate_slab_order() for SLAB_RECLAIM_ACCOUNT
Instead of having a hard-to-read and confusing conditional in the caller, just make the slab order calculation handle this special case, since it's simple and obvious there. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
7986824e4e
commit
f78bb8ad48
1 changed files with 9 additions and 11 deletions
20
mm/slab.c
20
mm/slab.c
|
@ -1647,6 +1647,14 @@ static inline size_t calculate_slab_order(struct kmem_cache *cachep,
|
||||||
cachep->gfporder = gfporder;
|
cachep->gfporder = gfporder;
|
||||||
left_over = remainder;
|
left_over = remainder;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A VFS-reclaimable slab tends to have most allocations
|
||||||
|
* as GFP_NOFS and we really don't want to have to be allocating
|
||||||
|
* higher-order pages when we are unable to shrink dcache.
|
||||||
|
*/
|
||||||
|
if (flags & SLAB_RECLAIM_ACCOUNT)
|
||||||
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Large number of objects is good, but very large slabs are
|
* Large number of objects is good, but very large slabs are
|
||||||
* currently bad for the gfp()s.
|
* currently bad for the gfp()s.
|
||||||
|
@ -1869,17 +1877,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
|
||||||
|
|
||||||
size = ALIGN(size, align);
|
size = ALIGN(size, align);
|
||||||
|
|
||||||
if ((flags & SLAB_RECLAIM_ACCOUNT) && size <= PAGE_SIZE) {
|
left_over = calculate_slab_order(cachep, size, align, flags);
|
||||||
/*
|
|
||||||
* A VFS-reclaimable slab tends to have most allocations
|
|
||||||
* as GFP_NOFS and we really don't want to have to be allocating
|
|
||||||
* higher-order pages when we are unable to shrink dcache.
|
|
||||||
*/
|
|
||||||
cachep->gfporder = 0;
|
|
||||||
cache_estimate(cachep->gfporder, size, align, flags,
|
|
||||||
&left_over, &cachep->num);
|
|
||||||
} else
|
|
||||||
left_over = calculate_slab_order(cachep, size, align, flags);
|
|
||||||
|
|
||||||
if (!cachep->num) {
|
if (!cachep->num) {
|
||||||
printk("kmem_cache_create: couldn't create cache %s.\n", name);
|
printk("kmem_cache_create: couldn't create cache %s.\n", name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue