Messages in this thread | | | Date | Mon, 17 Apr 2023 21:37:40 +0900 | From | Sergey Senozhatsky <> | Subject | Re: [PATCH] zsmalloc: allow only one active pool compaction context |
| |
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.
| |