From: Roman Gushchin 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 Co-developed-by: Ben Gardon Signed-off-by: Ben Gardon --- 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 R: Peter Zijlstra 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 + +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 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 #include "sched.h" +#define CREATE_TRACE_POINTS +#include +#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