Re: [PATCH] zsmalloc: allow only one active pool compaction context

From: Sergey Senozhatsky
Date: Mon Apr 17 2023 - 08:38:17 EST


Hi,

On (23/04/17 04:53), Yosry Ahmed wrote:
> > Introduce pool compaction mutex and permit only one compaction
> > context at a time.
>
> I am not sure what's the best practice here, but if the only use of
> the mutex is a trylock, do we need a mutex here? It seems like a
> simple atomic would do the trick. Perhaps something like:
>
> static atomic_t ongoing_compaction = ATOMIC_INIT(0);
> ...
> if (atomic_xchg(&ongoing_compaction, 1))
> return;
> ....
> atomic_set(&ongoing_compaction, 0);

Looks good to me. Will switch to atomic_t in v2.