Re: [PATCH v2 10/11] zsmalloc: fold zs_obj_write() into zs_store()
From: Sergey Senozhatsky
Date: Wed Nov 11 2026 - 01:09:42 EST
On (26/11/10 11:01), Nhat Pham wrote:
> On Mon, Nov 9, 2026 at 10:49 PM Sergey Senozhatsky
> <senozhatsky@xxxxxxxxxxxx> wrote:
> >
> > zram and zswap always call zs_obj_write() right after zs_malloc(), and
> > zs_obj_write() has to take pool->lock and look up object location
> > again, which zs_malloc() just did.
> >
> > Replace zs_malloc() and zs_obj_write() with one single zs_store()
> > call.
> >
> > zs_store() takes zspage read lock under class->lock, before it drops
> > class->lock to copy the data, while zs_obj_write() used to take it
> > under pool->lock. Compaction and page migration already take zspage
> > lock under class->lock, so this follows the existing pool->lock ->
> > class->lock -> zspage->lock order. We don't need pool->lock there,
> > zs_store() doesn't look up the object via the handle, it already has
> > the zspage from the allocation.
>
> Oh nice, this looks like it'd save a pool lock acquisition?
>
> That (effectively global) lock can be quite contend-y under memory
> fragmentation, etc...
Right.