Commit d363c2a8 authored by Fernand Sieber's avatar Fernand Sieber Committed by Namhyung Kim

perf: Timehist account sch delay for scheduled out running

When using perf timehist, sch delay is only computed for a waking task,
not for a pre empted task. This patches changes sch delay to account for
both. This makes sense as testing scheduling policy need to consider the
effect of scheduling delay globally, not only for waking tasks.

Example of `perf timehist` report before the patch for `stress` task
competing with each other.

First column is wait time, second column sch delay, third column
runtime.

1.492060 [0000]  s    stress[81]                          1.999      0.000      2.000      R  next: stress[83]
1.494060 [0000]  s    stress[83]                          2.000      0.000      2.000      R  next: stress[81]
1.496060 [0000]  s    stress[81]                          2.000      0.000      2.000      R  next: stress[83]
1.498060 [0000]  s    stress[83]                          2.000      0.000      1.999      R  next: stress[81]

After the patch, it looks like this (note that all wait time is not zero
anymore):

1.492060 [0000]  s    stress[81]                          1.999      1.999      2.000      R  next: stress[83]
1.494060 [0000]  s    stress[83]                          2.000      2.000      2.000      R  next: stress[81]
1.496060 [0000]  s    stress[81]                          2.000      2.000      2.000      R  next: stress[83]
1.498060 [0000]  s    stress[83]                          2.000      2.000      1.999      R  next: stress[81]
Signed-off-by: default avatarFernand Sieber <sieberf@amazon.com>
Reviewed-by: default avatarMadadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240618090339.87482-1-sieberf@amazon.com
parent fcd094e5
...@@ -64,8 +64,8 @@ There are several variants of 'perf sched': ...@@ -64,8 +64,8 @@ There are several variants of 'perf sched':
By default it shows the individual schedule events, including the wait By default it shows the individual schedule events, including the wait
time (time between sched-out and next sched-in events for the task), the time (time between sched-out and next sched-in events for the task), the
task scheduling delay (time between wakeup and actually running) and run task scheduling delay (time between runnable and actually running) and
time for the task: run time for the task:
time cpu task name wait time sch delay run time time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec) [tid/pid] (msec) (msec) (msec)
......
...@@ -2659,6 +2659,9 @@ static int timehist_sched_change_event(struct perf_tool *tool, ...@@ -2659,6 +2659,9 @@ static int timehist_sched_change_event(struct perf_tool *tool,
tr->last_state = state; tr->last_state = state;
/* sched out event for task so reset ready to run time */ /* sched out event for task so reset ready to run time */
if (state == 'R')
tr->ready_to_run = t;
else
tr->ready_to_run = 0; tr->ready_to_run = 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment