From: Ben Gardon <bgardon@google.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
Roman Gushchin <roman.gushchin@linux.dev>,
Tejun Heo <tj@kernel.org>
Cc: JP Kobryn <jp.kobryn@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
David Rientjes <rientjes@google.com>,
Suren Baghdasaryan <surenb@google.com>,
Josh Don <joshdon@google.com>,
Sweet Tea Dorminy <sweettea-kernel@dorminy.me>,
Chuyi Zhou <zhouchuyi@bytedance.com>,
Yafang Shao <laoar.shao@gmail.com>,
benbwgardon@gmail.com, bpf@vger.kernel.org, linux-mm@kvack.org,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
Ben Gardon <bgardon@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
linux-trace-kernel@vger.kernel.org
Subject: [PATCH bpf-next v4 06/17] sched/psi: add a tracepoint to psi_avgs_work()
Date: Wed, 2 Dec 2026 13:03:56 -0800 [thread overview]
Message-ID: <20261202210415.517651-7-bgardon@google.com> (raw)
In-Reply-To: <20261202210415.517651-1-bgardon@google.com>
From: Roman Gushchin <roman.gushchin@linux.dev>
Add a bare tracepoint to psi_avgs_work() to allow BPF programs to
monitor memory pressure.
Add include/trace/events/psi.h to the PSI entry in MAINTAINERS.
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Co-developed-by: Ben Gardon <bgardon@google.com>
Signed-off-by: Ben Gardon <bgardon@google.com>
---
v3 -> v4:
- Switched from TRACE_EVENT() to bare DECLARE_TRACE() (psi_avgs_work_tp)
so no pointer-only tracefs event ABI is exported.
- Added include/trace/events/psi.h to the PSI entry in MAINTAINERS.
v3: https://lore.kernel.org/all/20260127024421.494929-14-roman.gushchin@linux.dev/
MAINTAINERS | 1 +
include/trace/events/psi.h | 19 +++++++++++++++++++
kernel/sched/psi.c | 6 ++++++
3 files changed, 26 insertions(+)
create mode 100644 include/trace/events/psi.h
diff --git a/MAINTAINERS b/MAINTAINERS
index d4ef52c5594b..8bb61211b7f0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22397,6 +22397,7 @@ M: Suren Baghdasaryan <surenb@google.com>
R: Peter Zijlstra <peterz@infradead.org>
S: Maintained
F: include/linux/psi*
+F: include/trace/events/psi.h
F: kernel/sched/psi.c
PROPELLER BUILD
diff --git a/include/trace/events/psi.h b/include/trace/events/psi.h
new file mode 100644
index 000000000000..838dc95c3401
--- /dev/null
+++ b/include/trace/events/psi.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM psi
+
+#if !defined(_TRACE_PSI_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_PSI_H
+
+#include <linux/tracepoint.h>
+
+struct psi_group;
+
+DECLARE_TRACE(psi_avgs_work,
+ TP_PROTO(struct psi_group *group),
+ TP_ARGS(group));
+
+#endif /* _TRACE_PSI_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 7c5381423334..d89c40902492 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -141,6 +141,10 @@
#include <linux/psi.h>
#include "sched.h"
+#define CREATE_TRACE_POINTS
+#include <trace/events/psi.h>
+#undef CREATE_TRACE_POINTS
+
static int psi_bug __read_mostly;
DEFINE_STATIC_KEY_FALSE(psi_disabled);
@@ -607,6 +611,8 @@ static void psi_avgs_work(struct work_struct *work)
group->avg_next_update - now) + 1);
}
+ trace_psi_avgs_work_tp(group);
+
mutex_unlock(&group->avgs_lock);
}
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-02 21:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 21:03 [PATCH bpf-next v4 00/17] mm: BPF OOM Ben Gardon
2026-12-02 21:03 ` [PATCH bpf-next v4 01/17] bpf: mark struct oom_control's memcg field as TRUSTED_OR_NULL Ben Gardon
2026-12-02 21:03 ` [PATCH bpf-next v4 02/17] mm, bpf: introduce BPF OOM struct ops Ben Gardon
2026-12-02 21:59 ` bot+bpf-ci
2026-12-02 21:03 ` [PATCH bpf-next v4 03/17] mm, bpf: introduce bpf_oom_kill_process() BPF kfunc Ben Gardon
2026-12-02 21:58 ` bot+bpf-ci
2026-12-02 21:03 ` [PATCH bpf-next v4 04/17] mm, bpf: introduce bpf_out_of_memory() " Ben Gardon
2026-12-02 21:18 ` sashiko-bot
2026-12-02 21:59 ` bot+bpf-ci
2026-12-02 21:03 ` [PATCH bpf-next v4 05/17] selftests/bpf: Add BPF OOM struct ops test Ben Gardon
2026-12-02 21:03 ` Ben Gardon [this message]
2026-12-02 21:15 ` [PATCH bpf-next v4 06/17] sched/psi: add a tracepoint to psi_avgs_work() sashiko-bot
2026-12-02 21:03 ` [PATCH bpf-next v4 07/17] sched/psi: add cgroup_id field to psi_group structure Ben Gardon
2026-12-02 21:03 ` [PATCH bpf-next v4 08/17] mm, bpf: allow calling bpf_out_of_memory() from a PSI tracepoint Ben Gardon
2026-12-02 21:03 ` [PATCH bpf-next v4 09/17] selftests/bpf: Enable CONFIG_PSI Ben Gardon
2026-12-02 21:04 ` [PATCH bpf-next v4 10/17] selftests/bpf: Add PSI tracepoint OOM test Ben Gardon
2026-12-02 21:04 ` [PATCH bpf-next v4 11/17] selftests/bpf: Add systemd-oomd style OOM policy test Ben Gardon
2026-12-02 21:58 ` bot+bpf-ci
2026-12-02 21:04 ` [PATCH bpf-next v4 12/17] mm, bpf: introduce bpf_oom_proactive_kill() for proactive OOM prevention Ben Gardon
2026-12-02 21:58 ` bot+bpf-ci
2026-12-02 21:04 ` [PATCH bpf-next v4 13/17] selftests/bpf: Add bpf_oom_proactive_kill() proactive OOM test Ben Gardon
2026-12-02 21:04 ` [PATCH bpf-next v4 14/17] selftests/bpf: Add negative and verifier tests for BPF OOM kfuncs Ben Gardon
2026-12-02 21:15 ` sashiko-bot
2026-12-02 21:58 ` bot+bpf-ci
2026-12-02 21:04 ` [PATCH bpf-next v4 15/17] mm, bpf: introduce bpf_mem_cgroup_raise_max() kfunc Ben Gardon
2026-12-02 21:45 ` sashiko-bot
2026-12-02 21:58 ` bot+bpf-ci
2026-12-02 21:04 ` [PATCH bpf-next v4 16/17] selftests/bpf: Add bpf_mem_cgroup_raise_max() OOM test Ben Gardon
2026-12-02 21:04 ` [PATCH bpf-next v4 17/17] Documentation/bpf: Document BPF OOM handling and kfuncs Ben Gardon
2026-12-02 21:58 ` bot+bpf-ci
2026-12-02 21:38 ` [PATCH bpf-next v4 00/17] mm: BPF OOM Ben Gardon
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=20261202210415.517651-7-bgardon@google.com \
--to=bgardon@google.com \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=benbwgardon@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dietmar.eggemann@arm.com \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=hannes@cmpxchg.org \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=joshdon@google.com \
--cc=jp.kobryn@linux.dev \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=memxor@gmail.com \
--cc=mgorman@suse.de \
--cc=mhiramat@kernel.org \
--cc=mhocko@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
--cc=song@kernel.org \
--cc=surenb@google.com \
--cc=sweettea-kernel@dorminy.me \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yonghong.song@linux.dev \
--cc=zhouchuyi@bytedance.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