Re: [PATCH v6 11/17] zsmalloc: make zspage lock preemptible
From: Sergey Senozhatsky
Date: Thu Feb 20 2025 - 20:21:01 EST
On (25/02/20 19:18), Yosry Ahmed wrote:
[..]
> > +static void zspage_lock_init(struct zspage *zspage)
> > +{
> > +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> > + lockdep_init_map(&zspage->zsl.dep_map, "zspage->lock",
> > + &zspage->pool->lock_class, 0);
> > +#endif
> > +
> > + spin_lock_init(&zspage->zsl.lock);
> > + zspage->zsl.cnt = ZS_PAGE_UNLOCKED;
> > +}
> > +
> > +#ifdef CONFIG_DEBUG_LOCK_ALLOC
>
> Instead of the #ifdef and repeating all the functions, can't we do
> something like:
>
> #ifdef CONFIG_DEBUG_LOCK_ALLOC
> #define zspage_lock_map(zsl) (&zsl->dep_map)
> #else
> #define zspage_lock_map(zsl) /* empty or NULL */
> #endif
>
> Then we can just have one version of the functions and use
> zspage_lock_map() instead of zsl->dep_map, right?
Yeah, maybe.