Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Fernand Sieber <sieberf@amazon.com>
Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240618090339.87482-1-sieberf@amazon.com

authored by

Fernand Sieber and committed by
Namhyung Kim
d363c2a8 fcd094e5

+6 -3
+2 -2
tools/perf/Documentation/perf-sched.txt
··· 64 64 65 65 By default it shows the individual schedule events, including the wait 66 66 time (time between sched-out and next sched-in events for the task), the 67 - task scheduling delay (time between wakeup and actually running) and run 68 - time for the task: 67 + task scheduling delay (time between runnable and actually running) and 68 + run time for the task: 69 69 70 70 time cpu task name wait time sch delay run time 71 71 [tid/pid] (msec) (msec) (msec)
+4 -1
tools/perf/builtin-sched.c
··· 2659 2659 tr->last_state = state; 2660 2660 2661 2661 /* sched out event for task so reset ready to run time */ 2662 - tr->ready_to_run = 0; 2662 + if (state == 'R') 2663 + tr->ready_to_run = t; 2664 + else 2665 + tr->ready_to_run = 0; 2663 2666 } 2664 2667 2665 2668 evsel__save_time(evsel, sample->time, sample->cpu);