Re: [PATCH v3 3/4] mm: introduce page memcg flags

From: Roman Gushchin
Date: Wed Sep 30 2020 - 19:45:05 EST


On Wed, Sep 30, 2020 at 04:35:37PM -0700, Shakeel Butt wrote:
> On Tue, Sep 29, 2020 at 4:59 PM Roman Gushchin <guro@xxxxxx> wrote:
> >
> > The lowest bit in page->memcg_data is used to distinguish between
> > struct memory_cgroup pointer and a pointer to a objcgs array.
> > All checks and modifications of this bit are open-coded.
> >
> > Let's formalize it using page memcg flags, defined in enum
> > page_memcg_data_flags.
> >
> > Additional flags might be added later.
> >
> > Signed-off-by: Roman Gushchin <guro@xxxxxx>
>
> One nit below:
>
> Reviewed-by: Shakeel Butt <shakeelb@xxxxxxxxxx>

Thank you!

>
> > ---
> > include/linux/memcontrol.h | 35 ++++++++++++++++++++++++-----------
> > 1 file changed, 24 insertions(+), 11 deletions(-)
> >
> > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> > index d4d15c04bbaf..35f846c6b89b 100644
> > --- a/include/linux/memcontrol.h
> > +++ b/include/linux/memcontrol.h
> > @@ -343,6 +343,15 @@ struct mem_cgroup {
> >
> > extern struct mem_cgroup *root_mem_cgroup;
> >
> > +enum page_memcg_data_flags {
> > + /* page->memcg_data is a pointer to an objcgs vector */
> > + MEMCG_DATA_OBJCGS,
> > + /* the next bit after the last actual flag */
> > + __NR_MEMCG_DATA_FLAGS,
> > +};
> > +
> > +#define MEMCG_DATA_FLAGS_MASK ((0x1UL << __NR_MEMCG_DATA_FLAGS) - 1)
> > +
>
> Nit:
>
> #define PG_MEMCG_OBJCGS (0x1UL << MEMCG_DATA_OBJCGS)
>
> and use this macro below.

Johannes's pushing on defining flags as bit fields, so I'm sending v4 soon.

Thanks!