Re: [PATCH v5 01/18] zram: sleepable entry locking

From: Sergey Senozhatsky
Date: Thu Feb 13 2025 - 03:49:17 EST


On (25/02/13 10:42), Sergey Senozhatsky wrote:
> On (25/02/13 09:52), Sergey Senozhatsky wrote:
> > > > -static int zram_slot_trylock(struct zram *zram, u32 index)
> > > > +static void zram_slot_lock_init(struct zram *zram, u32 index)
> > > > {
> > > > - return spin_trylock(&zram->table[index].lock);
> > > > +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> > > > + lockdep_init_map(&zram->table[index].lockdep_map, "zram-entry->lock",
> > > > + &zram->table_lockdep_key, 0);
> > > > +#endif
> > > > +}
> > > > +
> > > >
> > > > ...
> > > >
> > > > +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> > > > + lockdep_register_key(&zram->table_lockdep_key);
> > > > +#endif
> > > > +
> > >
> > > Please check whether all the ifdefs are needed - some of these things
> > > have CONFIG_LOCKDEP=n stubs.
>
> The problem is that while functions have LOCKDEP=n stubs, struct members
> don't - we still declare table_lockdep_key and lockdep_map only when
> DEBUG_LOCK_ALLOC is enabled.

I rewrote those bits (in zram and in zsmalloc), given that we also
need lock-contended/lock-acquired in various branches, which require
even more ifdef-s. So I factored out debug-enabled variants.