Re: [RFC PATCH 2/2] zsmalloc: chain-length configuration should consider other metrics
From: Sergey Senozhatsky
Date: Mon Jan 12 2026 - 21:36:56 EST
On (26/01/12 20:56), Yosry Ahmed wrote:
> > > Looks alright to me too.
> > >
> > > > > + size_t sizes[2];
> > > > > +
> > > > > + /* this object spans two pages */
> > > > > + sizes[0] = PAGE_SIZE - off;
> > > > > + sizes[1] = mem_len - sizes[0];
> > > > > +
> > > > > + sg_init_table(sg, 2);
> > > > > + sg_set_page(sg, zpdesc_page(zpdesc), sizes[0], off);
> > > > > +
> > > > > + zpdesc = get_next_zpdesc(zpdesc);
> > > > > + sg = sg_next(sg);
> > > >
> > > > Is this stateful? Will the SG list be returned pointing at the second
> > > > page now?
> > >
> > > It makes no difference because we just called sg_init_table(sg, 2),
> > > so sg_next(sg) is equivalent to &sg[1].
> >
> > I did it this way for (sort of) consistency: sg next follows zpdesc next.
>
> Makes sense, I think I confused myself earlier. Do you plan to switch
> the existing interfaces to use SG lists for both zswap and zram? Or does
> zram still need the old interfaces?
That's a good question. I don't know. I was thinking of providing
SG-list based API for zswap first and keeping zram as is, for now.
zram doesn't use crypto API at the moment so supporting new interface
will come with extra work.