Commit 833b706c authored by Joonsoo Kim's avatar Joonsoo Kim Committed by Linus Torvalds
Browse files

slab: destroy a slab without holding any alien cache lock

I haven't heard that this alien cache lock is contended, but to reduce
chance of contention would be better generally.  And with this change,
we can simplify complex lockdep annotation in slab code.  In the
following patch, it will be implemented.

Signed-off-by: default avatarJoonsoo Kim <>
Acked-by: default avatarChristoph Lameter <>
Cc: Pekka Enberg <>
Cc: David Rientjes <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 49dfc304
......@@ -1050,10 +1050,10 @@ static void free_alien_cache(struct alien_cache **alc_ptr)
static void __drain_alien_cache(struct kmem_cache *cachep,
struct array_cache *ac, int node)
struct array_cache *ac, int node,
struct list_head *list)
struct kmem_cache_node *n = get_node(cachep, node);
if (ac->avail) {
......@@ -1065,10 +1065,9 @@ static void __drain_alien_cache(struct kmem_cache *cachep,
if (n->shared)
transfer_objects(n->shared, ac, ac->limit);
free_block(cachep, ac->entry, ac->avail, node, &list);
free_block(cachep, ac->entry, ac->avail, node, list);
ac->avail = 0;
slabs_destroy(cachep, &list);
......@@ -1086,8 +1085,11 @@ static void reap_alien(struct kmem_cache *cachep, struct kmem_cache_node *n)
if (alc) {
ac = &alc->ac;
if (ac->avail && spin_trylock_irq(&alc->lock)) {
__drain_alien_cache(cachep, ac, node);
__drain_alien_cache(cachep, ac, node, &list);
slabs_destroy(cachep, &list);
......@@ -1104,10 +1106,13 @@ static void drain_alien_cache(struct kmem_cache *cachep,
for_each_online_node(i) {
alc = alien[i];
if (alc) {
ac = &alc->ac;
spin_lock_irqsave(&alc->lock, flags);
__drain_alien_cache(cachep, ac, i);
__drain_alien_cache(cachep, ac, i, &list);
spin_unlock_irqrestore(&alc->lock, flags);
slabs_destroy(cachep, &list);
......@@ -1138,10 +1143,11 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
if (unlikely(ac->avail == ac->limit)) {
__drain_alien_cache(cachep, ac, nodeid);
__drain_alien_cache(cachep, ac, nodeid, &list);
ac_put_obj(cachep, ac, objp);
slabs_destroy(cachep, &list);
} else {
n = get_node(cachep, nodeid);
Supports Markdown
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