Re: [PATCH v3 4/8] memcg: reduce memory for the lruvec and memcg stats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 30, 2024 at 10:38 AM Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote:
>
> On Tue, Apr 30, 2024 at 01:41:38AM -0700, Yosry Ahmed wrote:
> > On Mon, Apr 29, 2024 at 11:06 PM Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote:
> > >
> [...]
> > > +
> > > +#define NR_MEMCG_NODE_STAT_ITEMS ARRAY_SIZE(memcg_node_stat_items)
> > > +#define NR_MEMCG_STATS (NR_MEMCG_NODE_STAT_ITEMS + ARRAY_SIZE(memcg_stat_items))
> > > +static int8_t mem_cgroup_stats_index[MEMCG_NR_STAT] __read_mostly;
> >
> > NR_MEMCG_STATS and MEMCG_NR_STAT are awfully close and have different
> > meanings. I think we should come up with better names (sorry nothing
> > comes to mind) or add a comment to make the difference more obvious.
> >
>
> How about the following comment?

The comment LGTM. I prefer renaming them though if someone can come up
with better names.

>
> /*
>  * Please note that NR_MEMCG_STATS represents the number of memcg stats
>  * we store in memory while MEMCG_NR_STAT represents the max enum value
>  * of the memcg stats.
>  */
>
> > > +
> > > +static void init_memcg_stats(void)
> > > +{
> > > +       int8_t i, j = 0;
> > > +
> > > +       /* Switch to short once this failure occurs. */
> > > +       BUILD_BUG_ON(NR_MEMCG_STATS >= 127 /* INT8_MAX */);
> >
> > Should we use S8_MAX here too?
> >
>
> Yes. Andrew, can you please add the above comment and replacement of
> 127 with S8_MAX in the patch?
>
> [...]
> > >
> > > -       pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec);
> > > -       x = READ_ONCE(pn->lruvec_stats->state[idx]);
> > > +       i = memcg_stats_index(idx);
> > > +       if (i >= 0) {
> >
> > nit: we could return here if (i < 0) like you did in
> > memcg_page_state() and others below, less indentation. Same for
> > lruvec_page_state_local().
> >
>
> I have fixed this in the following patch which adds warnings.

Yeah I saw that after reviewing this one.

FWIW, *if* you respin this, fixing this here would reduce the diff
noise in the patch that adds the warnings.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux