From: Roman Gushchin <roman.gushchin@linux.dev>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Yosry Ahmed <yosryahmed@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Muchun Song <muchun.song@linux.dev>,
ying.huang@intel.com, feng.tang@intel.com, fengwei.yin@intel.com,
oliver.sang@intel.com, kernel-team@meta.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] memcg: rearrage fields of mem_cgroup_per_node
Date: Thu, 23 May 2024 08:30:40 -0700 [thread overview]
Message-ID: <Zk9hIBJr35_wSTMq@P9FQF9L96D.corp.robot.car> (raw)
In-Reply-To: <m4ixafl5ajnr6tgkjwead3bmgglqqcpfwsgqijb6mlz2rfgjtu@yi3jwlnfpqpx>
On Wed, May 22, 2024 at 10:34:38PM -0700, Shakeel Butt wrote:
> On Wed, May 22, 2024 at 09:35:57PM -0700, Yosry Ahmed wrote:
> > On Wed, May 22, 2024 at 8:48 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> [...]
> > >
> > > struct mem_cgroup_per_node {
> > > - struct lruvec lruvec;
> > > + /* Keep the read-only fields at the start */
> > > + struct mem_cgroup *memcg; /* Back pointer, we cannot */
> > > + /* use container_of */
> > >
> > > struct lruvec_stats_percpu __percpu *lruvec_stats_percpu;
> > > struct lruvec_stats *lruvec_stats;
> > > -
> > > - unsigned long lru_zone_size[MAX_NR_ZONES][NR_LRU_LISTS];
> > > -
> > > - struct mem_cgroup_reclaim_iter iter;
> > > -
> > > struct shrinker_info __rcu *shrinker_info;
> > >
> > > + /* memcg-v1 only stuff in middle */
> > > +
> > > struct rb_node tree_node; /* RB tree node */
> > > unsigned long usage_in_excess;/* Set to the value by which */
> > > /* the soft limit is exceeded*/
> > > bool on_tree;
> > > - struct mem_cgroup *memcg; /* Back pointer, we cannot */
> > > - /* use container_of */
> >
> > Do we need CACHELINE_PADDING() here (or maybe make struct lruvec
> > cache-aligned) to make sure the false cacheline sharing doesn't happen
> > again with the fields below, or is the idea that the fields that get
> > read in hot paths (memcg, lruvec_stats_percpu, lruvec_stats) are far
> > at the top, and the memcg v1 elements in the middle act as a buffer?
It's a good point. Once we will compile out the memcg v1 stuff, it might stop
working.
> >
> > IOW, is sharing between the fields below and memcg v1 fields okay
> > because they are not read in the hot path? If yes, I believe it's
> > worth a comment. It can be easily missed if the memcg v1 soft limit is
> > removed later for example.
> >
>
> For 6.10, I wanted to keep the change simple and yes, the memcg v1 stuff
> as a buffer between the pointers and lruvec/lru_zone_size fields. For
> 6.11 or later kernels, I am planning to use some asserts to make sure
> these fields don't share a cacheline, so later when we remove the
> v1-only stuff, the asserts will make sure we keep the separate cacheline
> property intact.
Sounds good. Once we'll have memcg v1 stuff under a config option, we'll
put those asserts in.
Btw, I'm about (today/tomorrow) to post the memcg-v1 separation patchset,
so it won't take a long time.
Thanks!
next prev parent reply other threads:[~2024-05-23 15:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 3:48 [PATCH] memcg: rearrage fields of mem_cgroup_per_node Shakeel Butt
2024-05-23 4:35 ` Yosry Ahmed
2024-05-23 5:34 ` Shakeel Butt
2024-05-23 5:52 ` Yosry Ahmed
2024-05-23 15:30 ` Roman Gushchin [this message]
2024-05-23 15:34 ` Roman Gushchin
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=Zk9hIBJr35_wSTMq@P9FQF9L96D.corp.robot.car \
--to=roman.gushchin@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=feng.tang@intel.com \
--cc=fengwei.yin@intel.com \
--cc=hannes@cmpxchg.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=oliver.sang@intel.com \
--cc=shakeel.butt@linux.dev \
--cc=ying.huang@intel.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.