Re: [PATCH 3/8] mm/zsmalloc: Introduce objcgs pointer in struct zpdesc
From: Joshua Hahn
Date: Thu Feb 26 2026 - 16:43:49 EST
On Thu, 26 Feb 2026 13:37:42 -0800 Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote:
> On Thu, Feb 26, 2026 at 11:29:26AM -0800, Joshua Hahn wrote:
> > --- a/mm/zpdesc.h
> > +++ b/mm/zpdesc.h
> > @@ -20,10 +20,12 @@
> > * @zspage: Points to the zspage this zpdesc is a part of.
> > * @first_obj_offset: First object offset in zsmalloc pool.
> > * @_refcount: The number of references to this zpdesc.
> > + * @objcgs: Array of objcgs pointers that the stored objs
> > + * belong to. Overlayed on top of page->memcg_data, and
> > + * will always have first bit set if it is a valid pointer.
> > *
> > * This struct overlays struct page for now. Do not modify without a good
> > - * understanding of the issues. In particular, do not expand into the overlap
> > - * with memcg_data.
> > + * understanding of the issues.
> > *
> > * Page flags used:
> > * * PG_private identifies the first component page.
> > @@ -47,6 +49,9 @@ struct zpdesc {
> > */
> > unsigned int first_obj_offset;
> > atomic_t _refcount;
> > +#ifdef CONFIG_MEMCG
> > + unsigned long objcgs;
Hello Shakeel, I hope you're doing well!
> Why not just strore struct obj_cgroup ** instead of unsigned long? You will not
> need to do conversions when storing or accessing.
Yeah, that makes sense to me : -)
I guess if we're going to be accessing it with the zpdesc_objcgs and
zpdesc_set_objcgs helpers anyways, we can abstract away the casting to
unsigned long and re-casting to obj_cgroup pointer away from the user.
I was just trying to skip one cast, but I think it won't matter too much
anyways since it's always hidden away. I'll change it to obj_cgroup **
in the next version!!
I hope you have a great day : -)
Joshua