Re: [PATCH v7 11/17] zsmalloc: make zspage lock preemptible
From: Sergey Senozhatsky
Date: Fri Feb 21 2025 - 17:29:55 EST
On (25/02/21 19:52), Yosry Ahmed wrote:
> On Fri, Feb 21, 2025 at 06:38:04PM +0900, Sergey Senozhatsky wrote:
> > In order to implement preemptible object mapping we need a zspage lock
> > that satisfies several preconditions:
> > - it should be reader-write type of a lock
> > - it should be possible to hold it from any context, but also being
> > preemptible if the context allows it
> > - we never sleep while acquiring but can sleep while holding in read
> > mode
> >
> > An rwsemaphore doesn't suffice, due to atomicity requirements, rwlock
> > doesn't satisfy due to reader-preemptability requirement. It's also
> > worth to mention, that per-zspage rwsem is a little too memory heavy
> > (we can easily have double digits megabytes used only on rwsemaphores).
> >
> > Switch over from rwlock_t to a atomic_t-based implementation of a
> > reader-writer semaphore that satisfies all of the preconditions.
> >
> > The spin-lock based zspage_lock is suggested by Hillf Danton.
> >
> > Suggested-by: Hillf Danton <hdanton@xxxxxxxx>
> > Signed-off-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
>
> FWIW the code looks correct to me, but I don't trust my locking
> knowledge enough to give a Reviewed-by :)
YOLO-by: :)
Thanks for all your help!