]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm, slub: make locking in deactivate_slab() irq-safe
authorVlastimil Babka <vbabka@suse.cz>
Mon, 23 Aug 2021 23:58:59 +0000 (09:58 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Aug 2021 23:33:29 +0000 (09:33 +1000)
dectivate_slab() now no longer touches the kmem_cache_cpu structure, so it
will be possible to call it with irqs enabled.  Just convert the spin_lock
calls to their irq saving/restoring variants to make it irq-safe.

Note we now have to use cmpxchg_double_slab() for irq-safe slab_lock(),
because in some situations we don't take the list_lock, which would
disable irqs.

Link: https://lkml.kernel.org/r/20210805152000.12817-21-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
mm/slub.c

index ef36c94f27e2bdb702a6015aebd5aeadc328071d..00a96e9030e5091a703ce315062d38d3b24dd84b 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2209,6 +2209,7 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page,
        enum slab_modes l = M_NONE, m = M_NONE;
        void *nextfree, *freelist_iter, *freelist_tail;
        int tail = DEACTIVATE_TO_HEAD;
+       unsigned long flags = 0;
        struct page new;
        struct page old;
 
@@ -2284,7 +2285,7 @@ redo:
                         * that acquire_slab() will see a slab page that
                         * is frozen
                         */
-                       spin_lock(&n->list_lock);
+                       spin_lock_irqsave(&n->list_lock, flags);
                }
        } else {
                m = M_FULL;
@@ -2295,7 +2296,7 @@ redo:
                         * slabs from diagnostic functions will not see
                         * any frozen slabs.
                         */
-                       spin_lock(&n->list_lock);
+                       spin_lock_irqsave(&n->list_lock, flags);
                }
        }
 
@@ -2312,14 +2313,14 @@ redo:
        }
 
        l = m;
-       if (!__cmpxchg_double_slab(s, page,
+       if (!cmpxchg_double_slab(s, page,
                                old.freelist, old.counters,
                                new.freelist, new.counters,
                                "unfreezing slab"))
                goto redo;
 
        if (lock)
-               spin_unlock(&n->list_lock);
+               spin_unlock_irqrestore(&n->list_lock, flags);
 
        if (m == M_PARTIAL)
                stat(s, tail);