* [RFC PATCH] sched: psi: Add psi events trace point
@ 2025-08-14 7:07 Xuewen Yan
2025-08-14 13:55 ` Johannes Weiner
0 siblings, 1 reply; 3+ messages in thread
From: Xuewen Yan @ 2025-08-14 7:07 UTC (permalink / raw)
To: rostedt, surenb, hannes, peterz, mingo
Cc: mhiramat, mathieu.desnoyers, juri.lelli, vincent.guittot,
dietmar.eggemann, bsegall, andrii, vschneid, linux-kernel,
linux-trace-kernel, yuming.han, ke.wang, xuewen.yan94
Add trace point to psi triggers. This is useful to
observe the psi events in the kernel space.
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
include/trace/events/sched.h | 5 +++++
kernel/sched/psi.c | 2 ++
2 files changed, 7 insertions(+)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 7b2645b50e78..c23cb2bc76fd 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -896,6 +896,11 @@ DECLARE_TRACE(sched_set_need_resched,
TP_PROTO(struct task_struct *tsk, int cpu, int tif),
TP_ARGS(tsk, cpu, tif));
+struct psi_trigger *t
+DECLARE_TRACE(psi_event,
+ TP_PROTO(struct psi_trigger *t),
+ TP_ARGS(t));
+
#endif /* _TRACE_SCHED_H */
/* This part must be outside protection */
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 59fdb7ebbf22..268fc1b9cf1d 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -509,6 +509,8 @@ static void update_triggers(struct psi_group *group, u64 now,
if (now < t->last_event_time + t->win.size)
continue;
+ trace_psi_event_tp(t);
+
/* Generate an event */
if (cmpxchg(&t->event, 0, 1) == 0) {
if (t->of)
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] sched: psi: Add psi events trace point
2025-08-14 7:07 [RFC PATCH] sched: psi: Add psi events trace point Xuewen Yan
@ 2025-08-14 13:55 ` Johannes Weiner
2025-08-15 6:54 ` Xuewen Yan
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Weiner @ 2025-08-14 13:55 UTC (permalink / raw)
To: Xuewen Yan
Cc: rostedt, surenb, peterz, mingo, mhiramat, mathieu.desnoyers,
juri.lelli, vincent.guittot, dietmar.eggemann, bsegall, andrii,
vschneid, linux-kernel, linux-trace-kernel, yuming.han, ke.wang,
xuewen.yan94
On Thu, Aug 14, 2025 at 03:07:19PM +0800, Xuewen Yan wrote:
> Add trace point to psi triggers. This is useful to
> observe the psi events in the kernel space.
>
> Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
Can you elaborate on a situation in which you would use this?
> ---
> include/trace/events/sched.h | 5 +++++
> kernel/sched/psi.c | 2 ++
> 2 files changed, 7 insertions(+)
>
> diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
> index 7b2645b50e78..c23cb2bc76fd 100644
> --- a/include/trace/events/sched.h
> +++ b/include/trace/events/sched.h
> @@ -896,6 +896,11 @@ DECLARE_TRACE(sched_set_need_resched,
> TP_PROTO(struct task_struct *tsk, int cpu, int tif),
> TP_ARGS(tsk, cpu, tif));
>
> +struct psi_trigger *t
Missing ;
> +DECLARE_TRACE(psi_event,
> + TP_PROTO(struct psi_trigger *t),
> + TP_ARGS(t));
> +
> #endif /* _TRACE_SCHED_H */
>
> /* This part must be outside protection */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] sched: psi: Add psi events trace point
2025-08-14 13:55 ` Johannes Weiner
@ 2025-08-15 6:54 ` Xuewen Yan
0 siblings, 0 replies; 3+ messages in thread
From: Xuewen Yan @ 2025-08-15 6:54 UTC (permalink / raw)
To: Johannes Weiner
Cc: Xuewen Yan, rostedt, surenb, peterz, mingo, mhiramat,
mathieu.desnoyers, juri.lelli, vincent.guittot, dietmar.eggemann,
bsegall, andrii, vschneid, linux-kernel, linux-trace-kernel,
yuming.han, ke.wang
Hi Johannes,
Thanks for the reply:)
On Thu, Aug 14, 2025 at 9:55 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Thu, Aug 14, 2025 at 03:07:19PM +0800, Xuewen Yan wrote:
> > Add trace point to psi triggers. This is useful to
> > observe the psi events in the kernel space.
> >
> > Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
>
> Can you elaborate on a situation in which you would use this?
In the Android system, lmkd will kill processes by monitoring the
pressure of psi,
but lmkd may enter the UN state for some reasons, and be unable to
kill the process in time, resulting in OOM.
This hook can be used to detect psi just like lmkd, if lmkd was blocked,
the kernel could kill processes to avoid the occurrence of OOM.
Thanks!
BR
>
> > ---
> > include/trace/events/sched.h | 5 +++++
> > kernel/sched/psi.c | 2 ++
> > 2 files changed, 7 insertions(+)
> >
> > diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
> > index 7b2645b50e78..c23cb2bc76fd 100644
> > --- a/include/trace/events/sched.h
> > +++ b/include/trace/events/sched.h
> > @@ -896,6 +896,11 @@ DECLARE_TRACE(sched_set_need_resched,
> > TP_PROTO(struct task_struct *tsk, int cpu, int tif),
> > TP_ARGS(tsk, cpu, tif));
> >
> > +struct psi_trigger *t
>
> Missing ;
sorry for missing this, would add it later...
>
> > +DECLARE_TRACE(psi_event,
> > + TP_PROTO(struct psi_trigger *t),
> > + TP_ARGS(t));
> > +
> > #endif /* _TRACE_SCHED_H */
> >
> > /* This part must be outside protection */
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-15 6:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 7:07 [RFC PATCH] sched: psi: Add psi events trace point Xuewen Yan
2025-08-14 13:55 ` Johannes Weiner
2025-08-15 6:54 ` Xuewen Yan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).