From: Shakeel Butt <shakeel.butt@linux.dev>
To: Yosry Ahmed <yosryahmed@google.com>
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>,
Vlastimil Babka <vbabka@suse.cz>,
Axel Rasmussen <axelrasmussen@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Suren Baghdasaryan <surenb@google.com>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org,
Meta kernel team <kernel-team@meta.com>
Subject: Re: [PATCH] mm: mmap_lock: optimize mmap_lock tracepoints
Date: Sat, 23 Nov 2024 13:14:40 -0800 [thread overview]
Message-ID: <bqza4gctbajm5coj7cazivcd7chpigc7h6cqd4pnp2ql2hggvp@5xlflsvtkdff> (raw)
In-Reply-To: <CAJD7tkYAch4TpO0JSpjmg6k3VVw-0x_acf2P2JBveaD3mXPxgA@mail.gmail.com>
On Fri, Nov 22, 2024 at 10:46:53PM -0800, Yosry Ahmed wrote:
> On Fri, Nov 22, 2024 at 10:10 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> > We are starting to deploy mmap_lock tracepoint monitoring across our
> > fleet and the early results showed that these tracepoints are consuming
> > significant amount of CPUs in kernfs_path_from_node when enabled.
> >
> > It seems like the kernel is trying to resolved the cgroup path in the
>
> s/resolved/resolve
>
> > fast path of the locking code path when the tracepoints are enabled. In
> > addition for some application their metrics are regressing when
> > monitoring is enabled.
> >
> > The cgroup path resolution can be slow and should not be done in the
> > fast path. Most userspace tools, like bpftrace, provides functionality
> > to get the cgroup path from cgroup id, so let's just trace the cgroup
> > id and the users can use better tools to get the path in the slow path.
> >
> > Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
> > ---
> > include/linux/memcontrol.h | 18 ++++++++++++
> > include/trace/events/mmap_lock.h | 32 ++++++++++----------
> > mm/mmap_lock.c | 50 ++------------------------------
> > 3 files changed, 36 insertions(+), 64 deletions(-)
> >
> > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> > index 5502aa8e138e..d82f08cd70cd 100644
> > --- a/include/linux/memcontrol.h
> > +++ b/include/linux/memcontrol.h
> > @@ -1046,6 +1046,19 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm,
> >
> > void split_page_memcg(struct page *head, int old_order, int new_order);
> >
> > +static inline u64 memcg_id_from_mm(struct mm_struct *mm)
>
> The usage of memcg_id here and throughout the patch is a bit confusing
> because we have a member called 'id' in struct mem_cgroup, but this
> isn't it. This is the cgroup_id of the memcg. I admit it's hard to
> distinguish them during naming, but when I first saw the function I
> thought it was returning memcg->id.
>
> Maybe just cgroup_id_from_mm()? In cgroup v2, the cgroup id is the
> same regardless of the controller anyway, in cgroup v1, it's kinda
> natural that we return the cgroup id of the memcg.
>
> I don't feel strongly, but I prefer that we use clearer naming, and
> either way a comment may help clarify things.
>
Ack, I will change to cgroup_id_from_mm() but I will keep memcg_id in
the tracepoints.
> > +{
> > + struct mem_cgroup *memcg;
> > + u64 id = 0;
> > +
> > + rcu_read_lock();
> > + memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
> > + if (likely(memcg))
> > + id = cgroup_id(memcg->css.cgroup);
>
> We return 0 if the memcg is NULL here, shouldn't we return the cgroup
> id of the root memcg instead? This is more consistent with
> get_mem_cgroup_from_mm(), and makes sure we always return the id of a
> valid cgroup.
Good point and I need to add a mem_cgroup_disabled() check as well. Will
do in v2.
next prev parent reply other threads:[~2024-11-23 21:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 6:09 Shakeel Butt
2024-11-23 6:46 ` Yosry Ahmed
2024-11-23 21:14 ` Shakeel Butt [this message]
2024-11-23 8:38 ` Vlastimil Babka
2024-11-23 21:15 ` Shakeel Butt
2024-11-23 17:01 ` Matthew Wilcox
2024-11-23 21:35 ` Shakeel Butt
2024-11-23 21:38 ` Vlastimil Babka
2024-11-24 6:26 ` Shakeel Butt
2024-11-24 13:39 ` Steven Rostedt
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=bqza4gctbajm5coj7cazivcd7chpigc7h6cqd4pnp2ql2hggvp@5xlflsvtkdff \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=cgroups@vger.kernel.org \
--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=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox