Re: [PATCH v3 6/6] slab: Make slub local_trylock_t more precise for LOCKDEP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/17/25 05:32, Alexei Starovoitov wrote:
> On Wed, Jul 16, 2025 at 6:35 AM Vlastimil Babka <vbabka@xxxxxxx> wrote:
>> >  #endif
>> >       /* Used for retrieving partial slabs, etc. */
>> >       slab_flags_t flags;
>> > diff --git a/mm/slub.c b/mm/slub.c
>> > index c92703d367d7..526296778247 100644
>> > --- a/mm/slub.c
>> > +++ b/mm/slub.c
>> > @@ -3089,12 +3089,26 @@ static inline void note_cmpxchg_failure(const char *n,
>> >
>> >  static void init_kmem_cache_cpus(struct kmem_cache *s)
>> >  {
>> > +#ifdef CONFIG_PREEMPT_RT
>> > +     /* Register lockdep key for non-boot kmem caches */
>> > +     bool finegrain_lockdep = !init_section_contains(s, 1);
>>
>> I guess it's to avoid the "if (WARN_ON_ONCE(static_obj(key)))"
>> if it means the two bootstrap caches get a different class just by being
>> static, then I guess it works.
> 
> Yes. Not pretty. The alternative is to pass a flag
> through a bunch of functions all the way from kmem_cache_init.
> Another alternative is to
> bool finegrain_lockdep = s != boot_kmem_cache_node && s != boot_kmem_cache.
> Both are imo uglier.
> init_section_contains() is more precise and matches static_obj().

We also have the slab_state variable to handle bootstrap, but it would need
to gain a new state I think. Currently it's updated to "slab_state =
PARTIAL;" right between creating kmem_cache_node and kmem_cache, and the
next update "slab_state = UP;" is only after all the kmalloc caches. IIUC
we'd need to add a new one right after creating "kmem_cache".

I guess up to you, the init_section_contains() seems working too.

> Checking for SLAB_NO_OBJ_EXT isn't an option. Since it's conditional.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux