Re: [RFC v2 31/34] mm, slub: optionally save/restore irqs in slab_[un]lock()/

From: Sebastian Andrzej Siewior
Date: Fri Jul 02 2021 - 08:18:04 EST


On 2021-06-09 13:39:00 [+0200], Vlastimil Babka wrote:
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -353,18 +353,35 @@ static inline unsigned int oo_objects(struct kmem_cache_order_objects x)
> /*
> * Per slab locking using the pagelock
> */
> -static __always_inline void slab_lock(struct page *page)
> +static __always_inline void
> +__slab_lock(struct page *page, unsigned long *flags, bool disable_irqs)
> {
> VM_BUG_ON_PAGE(PageTail(page), page);
> + if (disable_irqs)
> + local_irq_save(*flags);
> bit_spin_lock(PG_locked, &page->flags);
> }
>
> -static __always_inline void slab_unlock(struct page *page)
> +static __always_inline void
> +__slab_unlock(struct page *page, unsigned long *flags, bool disable_irqs)
> {
> VM_BUG_ON_PAGE(PageTail(page), page);
> + if (disable_irqs)
> + local_irq_restore(*flags);
> __bit_spin_unlock(PG_locked, &page->flags);
> }

You should first unlock then enable IRQs.

Sebastian