Skip to content

Commit 0393895

Browse files
committed
mm/slub: Convert __slab_lock() and __slab_unlock() to struct slab
These functions operate on the PG_locked page flag, but make them accept struct slab to encapsulate this implementation detail. Signed-off-by: Vlastimil Babka <[email protected]> Reviewed-by: Roman Gushchin <[email protected]>
1 parent d835eef commit 0393895

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

mm/slub.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,18 @@ slub_set_cpu_partial(struct kmem_cache *s, unsigned int nr_objects)
440440
/*
441441
* Per slab locking using the pagelock
442442
*/
443-
static __always_inline void __slab_lock(struct page *page)
443+
static __always_inline void __slab_lock(struct slab *slab)
444444
{
445+
struct page *page = slab_page(slab);
446+
445447
VM_BUG_ON_PAGE(PageTail(page), page);
446448
bit_spin_lock(PG_locked, &page->flags);
447449
}
448450

449-
static __always_inline void __slab_unlock(struct page *page)
451+
static __always_inline void __slab_unlock(struct slab *slab)
450452
{
453+
struct page *page = slab_page(slab);
454+
451455
VM_BUG_ON_PAGE(PageTail(page), page);
452456
__bit_spin_unlock(PG_locked, &page->flags);
453457
}
@@ -456,12 +460,12 @@ static __always_inline void slab_lock(struct page *page, unsigned long *flags)
456460
{
457461
if (IS_ENABLED(CONFIG_PREEMPT_RT))
458462
local_irq_save(*flags);
459-
__slab_lock(page);
463+
__slab_lock(page_slab(page));
460464
}
461465

462466
static __always_inline void slab_unlock(struct page *page, unsigned long *flags)
463467
{
464-
__slab_unlock(page);
468+
__slab_unlock(page_slab(page));
465469
if (IS_ENABLED(CONFIG_PREEMPT_RT))
466470
local_irq_restore(*flags);
467471
}
@@ -530,16 +534,16 @@ static inline bool cmpxchg_double_slab(struct kmem_cache *s, struct page *page,
530534
unsigned long flags;
531535

532536
local_irq_save(flags);
533-
__slab_lock(page);
537+
__slab_lock(page_slab(page));
534538
if (page->freelist == freelist_old &&
535539
page->counters == counters_old) {
536540
page->freelist = freelist_new;
537541
page->counters = counters_new;
538-
__slab_unlock(page);
542+
__slab_unlock(page_slab(page));
539543
local_irq_restore(flags);
540544
return true;
541545
}
542-
__slab_unlock(page);
546+
__slab_unlock(page_slab(page));
543547
local_irq_restore(flags);
544548
}
545549

0 commit comments

Comments
 (0)