Commit 63109846 authored by Eric Dumazet's avatar Eric Dumazet Committed by Linus Torvalds

SLAB: don't allocate empty shared caches

We can avoid allocating empty shared caches and avoid unecessary check of
cache->limit.  We save some memory.  We avoid bringing into CPU cache
unecessary cache lines.

All accesses to l3->shared are already checking NULL pointers so this patch is
safe.
Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Acked-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Cc: Christoph Lameter <clameter@engr.sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 364fbb29
...@@ -1223,19 +1223,20 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb, ...@@ -1223,19 +1223,20 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
*/ */
list_for_each_entry(cachep, &cache_chain, next) { list_for_each_entry(cachep, &cache_chain, next) {
struct array_cache *nc; struct array_cache *nc;
struct array_cache *shared; struct array_cache *shared = NULL;
struct array_cache **alien = NULL; struct array_cache **alien = NULL;
nc = alloc_arraycache(node, cachep->limit, nc = alloc_arraycache(node, cachep->limit,
cachep->batchcount); cachep->batchcount);
if (!nc) if (!nc)
goto bad; goto bad;
shared = alloc_arraycache(node, if (cachep->shared) {
shared = alloc_arraycache(node,
cachep->shared * cachep->batchcount, cachep->shared * cachep->batchcount,
0xbaadf00d); 0xbaadf00d);
if (!shared) if (!shared)
goto bad; goto bad;
}
if (use_alien_caches) { if (use_alien_caches) {
alien = alloc_alien_cache(node, cachep->limit); alien = alloc_alien_cache(node, cachep->limit);
if (!alien) if (!alien)
...@@ -1317,8 +1318,8 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb, ...@@ -1317,8 +1318,8 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
shared = l3->shared; shared = l3->shared;
if (shared) { if (shared) {
free_block(cachep, l3->shared->entry, free_block(cachep, shared->entry,
l3->shared->avail, node); shared->avail, node);
l3->shared = NULL; l3->shared = NULL;
} }
...@@ -3870,12 +3871,15 @@ static int alloc_kmemlist(struct kmem_cache *cachep) ...@@ -3870,12 +3871,15 @@ static int alloc_kmemlist(struct kmem_cache *cachep)
goto fail; goto fail;
} }
new_shared = alloc_arraycache(node, new_shared = NULL;
if (cachep->shared) {
new_shared = alloc_arraycache(node,
cachep->shared*cachep->batchcount, cachep->shared*cachep->batchcount,
0xbaadf00d); 0xbaadf00d);
if (!new_shared) { if (!new_shared) {
free_alien_cache(new_alien); free_alien_cache(new_alien);
goto fail; goto fail;
}
} }
l3 = cachep->nodelists[node]; l3 = cachep->nodelists[node];
......
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