All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Muchun Song <muchun.song@linux.dev>,
	"T . J . Mercier" <tjmercier@google.com>,
	kernel-team@meta.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/8] memcg: reduce memory for the lruvec and memcg stats
Date: Tue, 30 Apr 2024 20:50:58 -0400	[thread overview]
Message-ID: <20240501005058.GA2538005@cmpxchg.org> (raw)
In-Reply-To: <CAJD7tkbue8S86YZE3y_1qOF5ee14F9MCuh2iJ0BNBZC8QpL=_Q@mail.gmail.com>

On Tue, Apr 30, 2024 at 04:07:05PM -0700, Yosry Ahmed wrote:
> On Tue, Apr 30, 2024 at 4:00 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> > On Tue, Apr 30, 2024 at 10:41:01AM -0700, Yosry Ahmed wrote:
> > > On Tue, Apr 30, 2024 at 10:38 AM Shakeel Butt <shakeel.butt@linux.dev> 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@linux.dev> 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.
> > >
> >
> > I will be posting v4 and will change the name (still thinking about the
> > name) becasuse:
> >
> > > > > > +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 */);
> >
> > The above should be MEMCG_NR_STAT instead of NR_MEMCG_STATS.
> 
> Yeah it's pretty confusing :)
> 
> How about something explicit like:
> 
> NR_MEMCG_POSSIBLE_STAT_ITEMS / MEMCG_MAX_STAT_ITEM
> NR_MEMCG_ACTUAL_STAT_ITEMS / MEMCG_ACTUAL_NR_STAT

NR is pretty common to mark the end of an enum range. It would be good
to keep that for enum memcg_stat_item.

The other one is about an array, where we usually use "size" or
"len". How about using one of those instead? I think it should be
sufficiently distinguished then:

- MEMORY_STAT_LEN
- MEMCG_VMSTAT_LEN
- MEMCG_VMSTAT_SIZE


  reply	other threads:[~2024-05-01  0:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30  6:06 [PATCH v3 0/8] memcg: reduce memory consumption by memcg stats Shakeel Butt
2024-04-30  6:06 ` [PATCH v3 1/8] memcg: reduce memory size of mem_cgroup_events_index Shakeel Butt
2024-04-30  8:33   ` Yosry Ahmed
2024-04-30 17:29     ` T.J. Mercier
2024-04-30  6:06 ` [PATCH v3 2/8] memcg: dynamically allocate lruvec_stats Shakeel Butt
2024-04-30 17:29   ` T.J. Mercier
2024-04-30  6:06 ` [PATCH v3 3/8] mm: memcg: account memory used for memcg vmstats and lruvec stats Shakeel Butt
2024-04-30  8:34   ` Yosry Ahmed
2024-04-30 17:30     ` T.J. Mercier
2024-04-30  6:06 ` [PATCH v3 4/8] memcg: reduce memory for the lruvec and memcg stats Shakeel Butt
2024-04-30  8:41   ` Yosry Ahmed
2024-04-30 17:37     ` Shakeel Butt
2024-04-30 17:41       ` Yosry Ahmed
2024-04-30 17:49         ` Shakeel Butt
2024-04-30 23:00         ` Shakeel Butt
2024-04-30 23:07           ` Yosry Ahmed
2024-05-01  0:50             ` Johannes Weiner [this message]
2024-04-30 17:30   ` T.J. Mercier
2024-04-30 17:45     ` Shakeel Butt
2024-04-30  6:06 ` [PATCH v3 5/8] memcg: cleanup __mod_memcg_lruvec_state Shakeel Butt
2024-04-30 17:31   ` T.J. Mercier
2024-04-30  6:06 ` [PATCH v3 6/8] mm: cleanup WORKINGSET_NODES in workingset Shakeel Butt
2024-04-30 17:32   ` T.J. Mercier
2024-04-30  6:06 ` [PATCH v3 7/8] memcg: warn for unexpected events and stats Shakeel Butt
2024-04-30  6:06 ` [PATCH v3 8/8] memcg: use proper type for mod_memcg_state Shakeel Butt
2024-04-30 18:09   ` T.J. Mercier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240501005058.GA2538005@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=tjmercier@google.com \
    --cc=yosryahmed@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.