All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] sched: psi: Add psi events trace point
@ 2025-08-14  7:07 Xuewen Yan
  2025-08-14 13:55 ` Johannes Weiner
  2025-08-14 17:13 ` kernel test robot
  0 siblings, 2 replies; 4+ 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] 4+ 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
  2025-08-14 17:13 ` kernel test robot
  1 sibling, 1 reply; 4+ 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] 4+ 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-14 17:13 ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-08-14 17:13 UTC (permalink / raw)
  To: Xuewen Yan; +Cc: oe-kbuild-all

Hi Xuewen,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:

[auto build test ERROR on trace/for-next]
[also build test ERROR on linus/master v6.17-rc1 next-20250814]
[cannot apply to tip/sched/core peterz-queue/sched/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Xuewen-Yan/sched-psi-Add-psi-events-trace-point/20250814-151309
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/20250814070719.865-1-xuewen.yan%40unisoc.com
patch subject: [RFC PATCH] sched: psi: Add psi events trace point
config: x86_64-buildonly-randconfig-003-20250814 (https://download.01.org/0day-ci/archive/20250815/202508150007.A1SNODpy-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250815/202508150007.A1SNODpy-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508150007.A1SNODpy-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from kernel/sched/sched.h:74,
                    from kernel/sched/build_utility.c:52:
>> include/trace/events/sched.h:899:22: error: expected ';' before 'extern'
     899 | struct psi_trigger *t
         |                      ^
         |                      ;
--
   In file included from kernel/sched/core.c:85:
>> include/trace/events/sched.h:899:22: error: expected ';' before 'extern'
     899 | struct psi_trigger *t
         |                      ^
         |                      ;
   In file included from include/trace/define_trace.h:118,
                    from include/trace/events/sched.h:907:
>> include/trace/events/sched.h:899:22: error: expected ';' before 'static'
     899 | struct psi_trigger *t
         |                      ^
         |                      ;


vim +899 include/trace/events/sched.h

   828	
   829	/*
   830	 * Following tracepoints are not exported in tracefs and provide hooking
   831	 * mechanisms only for testing and debugging purposes.
   832	 */
   833	DECLARE_TRACE(pelt_cfs,
   834		TP_PROTO(struct cfs_rq *cfs_rq),
   835		TP_ARGS(cfs_rq));
   836	
   837	DECLARE_TRACE(pelt_rt,
   838		TP_PROTO(struct rq *rq),
   839		TP_ARGS(rq));
   840	
   841	DECLARE_TRACE(pelt_dl,
   842		TP_PROTO(struct rq *rq),
   843		TP_ARGS(rq));
   844	
   845	DECLARE_TRACE(pelt_hw,
   846		TP_PROTO(struct rq *rq),
   847		TP_ARGS(rq));
   848	
   849	DECLARE_TRACE(pelt_irq,
   850		TP_PROTO(struct rq *rq),
   851		TP_ARGS(rq));
   852	
   853	DECLARE_TRACE(pelt_se,
   854		TP_PROTO(struct sched_entity *se),
   855		TP_ARGS(se));
   856	
   857	DECLARE_TRACE(sched_cpu_capacity,
   858		TP_PROTO(struct rq *rq),
   859		TP_ARGS(rq));
   860	
   861	DECLARE_TRACE(sched_overutilized,
   862		TP_PROTO(struct root_domain *rd, bool overutilized),
   863		TP_ARGS(rd, overutilized));
   864	
   865	DECLARE_TRACE(sched_util_est_cfs,
   866		TP_PROTO(struct cfs_rq *cfs_rq),
   867		TP_ARGS(cfs_rq));
   868	
   869	DECLARE_TRACE(sched_util_est_se,
   870		TP_PROTO(struct sched_entity *se),
   871		TP_ARGS(se));
   872	
   873	DECLARE_TRACE(sched_update_nr_running,
   874		TP_PROTO(struct rq *rq, int change),
   875		TP_ARGS(rq, change));
   876	
   877	DECLARE_TRACE(sched_compute_energy,
   878		TP_PROTO(struct task_struct *p, int dst_cpu, unsigned long energy,
   879			 unsigned long max_util, unsigned long busy_time),
   880		TP_ARGS(p, dst_cpu, energy, max_util, busy_time));
   881	
   882	DECLARE_TRACE(sched_entry,
   883		TP_PROTO(bool preempt),
   884		TP_ARGS(preempt));
   885	
   886	DECLARE_TRACE(sched_exit,
   887		TP_PROTO(bool is_switch),
   888		TP_ARGS(is_switch));
   889	
   890	DECLARE_TRACE_CONDITION(sched_set_state,
   891		TP_PROTO(struct task_struct *tsk, int state),
   892		TP_ARGS(tsk, state),
   893		TP_CONDITION(!!(tsk->__state) != !!state));
   894	
   895	DECLARE_TRACE(sched_set_need_resched,
   896		TP_PROTO(struct task_struct *tsk, int cpu, int tif),
   897		TP_ARGS(tsk, cpu, tif));
   898	
 > 899	struct psi_trigger *t
   900	DECLARE_TRACE(psi_event,
   901		TP_PROTO(struct psi_trigger *t),
   902		TP_ARGS(t));
   903	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ 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; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2025-08-15  6:55 UTC | newest]

Thread overview: 4+ 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
2025-08-14 17:13 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.