[DTrace-devel] [PATCH 1/2] sched: fix firing of sched:::on-cpu

Alan Maguire alan.maguire at oracle.com
Tue Jun 25 16:22:29 UTC 2024


sched:::on-cpu is not firing very often versus off-cpu.  It appears
that - for recent kernels at least - fbt::schedule_tail:entry
placement is wrong.  We can instead rely on the cpc:::context_switches-all-1
probe to carry out on-cpu firing since the associated SW perf event
fires for context switches.  With that in place, we see sensible
off/on-cpu numbers:

$ dtrace -n 'sched:::*-cpu { @c[probename] = count();}'
dtrace: description 'sched:::*-cpu ' matched 2 probes
^C

  on-cpu                                                         6491
  off-cpu                                                        6492

...and can easily do off-cpu analysis:

$ dtrace -n 'sched:::off-cpu { start[execname, pid] = timestamp;} sched:::on-cpu /start[execname,pid]/ { @offcpu[execname, pid] = avg(timestamp - start[execname, pid]); }'
dtrace: description 'sched:::off-cpu ' matched 2 probes
^C

  gdbus                                                  3086             1415
  Web Content                                         1427650             1644
  dbus-daemon                                            1347             1804
...

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
---
 libdtrace/dt_prov_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libdtrace/dt_prov_sched.c b/libdtrace/dt_prov_sched.c
index 2749385a..74166543 100644
--- a/libdtrace/dt_prov_sched.c
+++ b/libdtrace/dt_prov_sched.c
@@ -25,7 +25,7 @@ static probe_dep_t	probes[] = {
 	{ "off-cpu",
 	  DTRACE_PROBESPEC_NAME,	"rawtp:sched::sched_switch" },
 	{ "on-cpu",
-	  DTRACE_PROBESPEC_NAME,	"fbt::schedule_tail:entry" },
+	  DTRACE_PROBESPEC_NAME,	"cpc:::context_switches-all-1" },
 	{ "surrender",
 	  DTRACE_PROBESPEC_NAME,	"fbt::do_sched_yield:entry" },
 	{ "tick",
-- 
2.43.0




More information about the DTrace-devel mailing list