[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zk9hIBJr35_wSTMq@P9FQF9L96D.corp.robot.car>
Date: Thu, 23 May 2024 08:30:40 -0700
From: Roman Gushchin <roman.gushchin@...ux.dev>
To: Shakeel Butt <shakeel.butt@...ux.dev>
Cc: Yosry Ahmed <yosryahmed@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Muchun Song <muchun.song@...ux.dev>, ying.huang@...el.com,
feng.tang@...el.com, fengwei.yin@...el.com, oliver.sang@...el.com,
kernel-team@...a.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] memcg: rearrage fields of mem_cgroup_per_node
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@...ux.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!
Powered by blists - more mailing lists