Re: [PATCHv1 4/6] zsmalloc: introduce new object mapping API

From: Sergey Senozhatsky
Date: Wed Jan 29 2025 - 23:18:08 EST


On (25/01/30 12:21), Sergey Senozhatsky wrote:
> [..]
> > > + if (off + class->size <= PAGE_SIZE) {
> > > + /* this object is contained entirely within a page */
> > > + void *dst = kmap_local_zpdesc(zpdesc);
> > > +
> > > + if (!ZsHugePage(zspage))
> > > + off += ZS_HANDLE_SIZE;
> > > + memcpy(dst + off, handle_mem, mem_len);
> > > + kunmap_local(dst);
> > > + } else {
> > > + size_t sizes[2];
> > > +
> > > + /* this object spans two pages */
> > > + off += ZS_HANDLE_SIZE;
> >
> > Are huge pages always stored in a single page? If yes, can we just do
> > this before the if block for both cases:
>
> Yes.
>
> > if (!ZsHugePage(zspage))
> > off += ZS_HANDLE_SIZE;
>
> Looks good.

Ah, now I see why I didn't do it. off += ZS_HANDLE_SIZE before
if (off + size <= PAGE_SIZE) messes it up.