From: Yosry Ahmed <yosryahmed@google.com>
To: JP Kobryn <inwardvessel@gmail.com>
Cc: shakeel.butt@linux.dev, hannes@cmpxchg.org,
akpm@linux-foundation.org, rostedt@goodmis.org,
linux-mm@kvack.org, cgroups@vger.kernel.org
Subject: Re: [PATCH 2/2 v3] memcg: add flush tracepoint
Date: Mon, 28 Oct 2024 19:44:25 -0700 [thread overview]
Message-ID: <CAJD7tkb+Qx+0NCn5BcSv31Hq8TKhSRFfQKQ9BFBE2kNATyswPQ@mail.gmail.com> (raw)
In-Reply-To: <20241029021106.25587-3-inwardvessel@gmail.com>
On Mon, Oct 28, 2024 at 7:11 PM JP Kobryn <inwardvessel@gmail.com> wrote:
>
> This tracepoint gives visibility on how often the flushing of memcg stats
> occurs and contains info on whether it was forced, skipped, and the value of
> stats updated. It can help with understanding how readers are affected by
> having to perform the flush, and the effectiveness of the flush by inspecting
> the number of stats updated. Paired with the recently added tracepoints for
> tracing rstat updates, it can also help show correlation where stats exceed
> thresholds frequently.
>
> Signed-off-by: JP Kobryn <inwardvessel@gmail.com>
Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
> ---
> include/trace/events/memcg.h | 25 +++++++++++++++++++++++++
> mm/memcontrol.c | 7 ++++++-
> 2 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/include/trace/events/memcg.h b/include/trace/events/memcg.h
> index 8667e57816d2..dfe2f51019b4 100644
> --- a/include/trace/events/memcg.h
> +++ b/include/trace/events/memcg.h
> @@ -74,6 +74,31 @@ DEFINE_EVENT(memcg_rstat_events, count_memcg_events,
> TP_ARGS(memcg, item, val)
> );
>
> +TRACE_EVENT(memcg_flush_stats,
> +
> + TP_PROTO(struct mem_cgroup *memcg, s64 stats_updates,
> + bool force, bool needs_flush),
> +
> + TP_ARGS(memcg, stats_updates, force, needs_flush),
> +
> + TP_STRUCT__entry(
> + __field(u64, id)
> + __field(s64, stats_updates)
> + __field(bool, force)
> + __field(bool, needs_flush)
> + ),
> +
> + TP_fast_assign(
> + __entry->id = cgroup_id(memcg->css.cgroup);
> + __entry->stats_updates = stats_updates;
> + __entry->force = force;
> + __entry->needs_flush = needs_flush;
> + ),
> +
> + TP_printk("memcg_id=%llu stats_updates=%lld force=%d needs_flush=%d",
> + __entry->id, __entry->stats_updates,
> + __entry->force, __entry->needs_flush)
> +);
>
> #endif /* _TRACE_MEMCG_H */
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 59f6f247fc13..c3d6163aaa1c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -590,7 +590,12 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val)
>
> static void __mem_cgroup_flush_stats(struct mem_cgroup *memcg, bool force)
> {
> - if (!force && !memcg_vmstats_needs_flush(memcg->vmstats))
> + bool needs_flush = memcg_vmstats_needs_flush(memcg->vmstats);
> +
> + trace_memcg_flush_stats(memcg, atomic64_read(&memcg->vmstats->stats_updates),
> + force, needs_flush);
> +
> + if (!force && !needs_flush)
> return;
>
> if (mem_cgroup_is_root(memcg))
> --
> 2.47.0
>
next prev parent reply other threads:[~2024-10-29 2:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 2:11 [PATCH 0/2 v3] memcg: tracepoint for flushing stats JP Kobryn
2024-10-29 2:11 ` [PATCH 1/2 v3] memcg: rename do_flush_stats and add force flag JP Kobryn
2024-10-29 2:43 ` Yosry Ahmed
2024-10-29 5:25 ` Shakeel Butt
2024-10-29 2:11 ` [PATCH 2/2 v3] memcg: add flush tracepoint JP Kobryn
2024-10-29 2:44 ` Yosry Ahmed [this message]
2024-10-29 5:27 ` Shakeel Butt
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=CAJD7tkb+Qx+0NCn5BcSv31Hq8TKhSRFfQKQ9BFBE2kNATyswPQ@mail.gmail.com \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=inwardvessel@gmail.com \
--cc=linux-mm@kvack.org \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
/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