Re: [PATCH 5/7] zsmalloc: embed struct zs_handle into zram and zswap entries
From: Sergey Senozhatsky
Date: Mon Nov 09 2026 - 21:44:35 EST
On (26/11/05 17:30), Yosry Ahmed wrote:
> > +#ifdef CONFIG_ZSMALLOC_REBIND_HANDLE
> > +/**
> > + * zs_rebind_handle() - Rebind an allocated object to a new handle.
> > + * @pool: pool the object belongs to
> > + * @dst: unallocated destination handle (must not be on the stack)
> > + * @src: source handle that currently owns the object
> > + *
> > + * Rebinds the object from @src to @dst, updating the object header so
> > + * compaction and page migration update @dst instead of @src, and resets
> > + * @src.
> > + */
> > +void zs_rebind_handle(struct zs_pool *pool, struct zs_handle *dst,
> > + struct zs_handle *src)
> > +{
> > + struct size_class *class;
> > + struct zspage *zspage;
> > + unsigned long obj;
> > +
> > + if (WARN_ON_ONCE(object_is_on_stack(dst) ||
> > + zs_handle_is_allocated(dst) ||
> > + !zs_handle_is_allocated(src)))
> > + return;
> > +
> > + obj_class_get_and_lock(pool, src, &obj, &zspage, &class);
> > +
> > + if (likely(!ZsHugePage(zspage))) {
> > + struct zpdesc *zpdesc;
> > + struct link_free *link;
> > + unsigned int obj_idx;
> > + unsigned long off;
> > + void *vaddr;
>
> I think this would be easier to read if you move the declarations to the
> top of the function, so that the different logic in the branches is more
> obvious.
Ack.