linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	 Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	 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: Wed, 22 May 2024 22:52:56 -0700	[thread overview]
Message-ID: <CAJD7tka2QnbjxZ=7YtRu-ufBUfREmayahsgR1_-oXhmYf8AQ9A@mail.gmail.com> (raw)
In-Reply-To: <m4ixafl5ajnr6tgkjwead3bmgglqqcpfwsgqijb6mlz2rfgjtu@yi3jwlnfpqpx>

On Wed, May 22, 2024 at 10:34 PM Shakeel Butt <shakeel.butt@linux.dev> 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?
> >
> > 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

Fair enough, could we update the comment to explicitly mention this?

> 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.
>

Makes sense to me.

With the comment update, feel free to add:
Reviewed-by: Yosry Ahmed <yosryahmed@google.com>


  reply	other threads:[~2024-05-23  5:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23  3:48 Shakeel Butt
2024-05-23  4:35 ` Yosry Ahmed
2024-05-23  5:34   ` Shakeel Butt
2024-05-23  5:52     ` Yosry Ahmed [this message]
2024-05-23 15:30     ` Roman Gushchin
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='CAJD7tka2QnbjxZ=7YtRu-ufBUfREmayahsgR1_-oXhmYf8AQ9A@mail.gmail.com' \
    --to=yosryahmed@google.com \
    --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=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=ying.huang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox