perf sched latency: Refine outputs, unit scaling, and histogram support
v2 cover perf sched latency: Refine outputs, unit scaling, and histogram support
This patch series improves 'perf sched latency' by fixing misleading empty table output, introducing dynamic unit auto-scaling for latency and runtime statistics, and adding latency histogram visualisation alongside time-span filtering.
Patch 1 fixes a bug where 'perf sched latency' would fall through and return success (0) when perf_session__has_traces() failed due to missing tracepoint events in perf.data. This resulted in empty header tables and zeroed summary statistics being printed. The fix ensures an early return of a suitable error code.
Patch 2 introduces dynamic auto-scaling for display columns (Runtime, Avg delay, Max delay). Previously, all values were unconditionally formatted in milliseconds (ms), making microsecond or second-scale latencies difficult to read. Columns are now scaled dynamically to the most appropriate unit (ns, us, ms, s) and headers are updated accordingly.
Patch 3 adds three new command-line options to 'perf sched latency':
--histogram (-H):
Displays an ASCII bar chart of CPU wait latencies between snapshots
--hist-mode:
Configures the bucketing scheme to either logarithmic (log) or 100 us equal-width linear (linear) mode
--time:
Filters event processing to a specified [start,stop] time span
Changes since v1:
- Fixed integer overflow in latency_bucket() (Ian Rogers)
- Linked to v1: https://lore.kernel.org/lkml/[email protected]/
Aaron Tomlin (3):
perf sched: Suppress latency table output when trace samples are
missing
perf sched latency: Auto-scale latency and runtime display units perf sched latency: Add histogram and time interval options
tools/perf/Documentation/perf-sched.txt | 6 + tools/perf/builtin-sched.c | 234 +++++++++++++++++++++--- 2 files changed, 219 insertions(+), 21 deletions(-)
Signature · 1 line
2.54.0
PATCH v2 1/3 perf sched: Suppress latency table output when trace samples are missing
When 'perf sched latency' is executed on a perf.data file that lacks tracepoint samples (i.e., a file recorded without the -R flag or containing only non-tracepoint events), perf_session__has_traces() correctly outputs an error message. However, perf_sched__read_events() subsequently falls through and returns 0 (success).
Consequently, caller functions such as perf_sched__lat() assume event processing succeeded and proceed to render empty latency header tables and total summary statistics.
Fix this behaviour by ensuring perf_sched__read_events() aborts early and returns a suitable error code when perf_session__has_traces() evaluates to false. This prevents superfluous table output from being generated when no trace data is available.
--- tools/perf/builtin-sched.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
tools/perf/builtin-sched.c +11 -10
@@ -2001,7 +2001,7 @@ static int perf_sched__read_events(struct perf_sched *sched) .mode = PERF_DATA_MODE_READ, .force = sched->force, }; -int rc =-1 ; +int rc =-1 , err; session =perf_session__new (&data, &sched->tool);if (IS_ERR (session)) {
@@ -2018,18 +2018,19 @@ static int perf_sched__read_events(struct perf_sched *sched)if (perf_session__set_tracepoints_handlers (session, handlers)) goto out_delete; -if (perf_session__has_traces (session,"record -R" )) { -int err =perf_session__process_events (session); -if (err) { -pr_err ("Failed to process events, error %d" , err); - goto out_delete; - } +if (!perf_session__has_traces (session,"record -R" )) + goto out_delete; - sched->nr_events = session->evlist->stats.nr_events[0 ]; - sched->nr_lost_events = session->evlist->stats.total_lost; - sched->nr_lost_chunks = session->evlist->stats.nr_events[PERF_RECORD_LOST ]; + err =perf_session__process_events (session); +if (err) { +pr_err ("Failed to process events, error %d" , err); + goto out_delete; } + sched->nr_events = session->evlist->stats.nr_events[0 ]; + sched->nr_lost_events = session->evlist->stats.total_lost; + sched->nr_lost_chunks = session->evlist->stats.nr_events[PERF_RECORD_LOST ]; + rc =0 ; out_delete:perf_session__delete (session);
Signature · 1 line
2.54.0
PATCH v2 2/3 perf sched latency: Auto-scale latency and runtime display units
In reply to Aaron TomlinCurrently, 'perf sched latency' displays task runtime and delay values exclusively in milliseconds (ms). This can be hard to read when latencies are very small (in the microsecond or nanosecond range) or unusually large (seconds).
Introduce auto-scaling for latency and runtime display columns. Values are dynamically scaled and output with the most appropriate unit:
nanoseconds (ns), microseconds (us), milliseconds (ms), or seconds (s).
Additionally, rename column headers from "Runtime ms", "Avg delay ms", and "Max delay ms" to "Runtime", "Avg delay", and "Max delay" respectively, and adjust spacing to maintain column alignment.
--- tools/perf/builtin-sched.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
tools/perf/builtin-sched.c +26 -8
@@ -246,6 +246,17 @@ struct perf_sched {struct perf_data *data; }; +static int scnprintf_latency_unit (char *buf,size_t size,u64 nsecs) +{ +if (nsecs <1000 ) +return scnprintf (buf, size,"%6" PRIu64" ns" , nsecs); +if (nsecs <NSEC_PER_MSEC ) +return scnprintf (buf, size,"%6.3f us" , (double )nsecs /NSEC_PER_USEC ); +if (nsecs <NSEC_PER_SEC ) +return scnprintf (buf, size,"%6.3f ms" , (double )nsecs /NSEC_PER_MSEC ); +return scnprintf (buf, size,"%6.3f s " , (double )nsecs /NSEC_PER_SEC ); +} +/* per thread run time data */ struct thread_runtime {u64 last_time;/* time of previous sched in/out event */
@@ -1405,6 +1416,8 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_int i;int ret;u64 avg; +char runtime_lat[32 ]; +char avg_lat[32 ], max_lat[32 ];char max_lat_start[32 ], max_lat_end[32 ];if (!work_list->nb_atoms)
@@ -1430,14 +1443,17 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_printf (" " ); avg = work_list->total_lat / work_list->nb_atoms; +scnprintf_latency_unit (runtime_lat,sizeof (runtime_lat), work_list->total_runtime); +scnprintf_latency_unit (avg_lat,sizeof (avg_lat), avg); +scnprintf_latency_unit (max_lat,sizeof (max_lat), work_list->max_lat);timestamp__scnprintf_usec (work_list->max_lat_start, max_lat_start,sizeof (max_lat_start));timestamp__scnprintf_usec (work_list->max_lat_end, max_lat_end,sizeof (max_lat_end)); -printf ("|%11.3f ms |%9" PRIu64" | avg:%8.3f ms | max:%8.3f ms | max start: %12s s | max end: %12s s\n" , - (double )work_list->total_runtime /NSEC_PER_MSEC , - work_list->nb_atoms, (double )avg /NSEC_PER_MSEC , - (double )work_list->max_lat /NSEC_PER_MSEC , - max_lat_start, max_lat_end); +printf ("|%13s |%9" PRIu64" | avg:%10s | max:%10s | max start: %12s s | max end: %12s s\n" , + runtime_lat, + work_list->nb_atoms, avg_lat, max_lat, + max_lat_start, max_lat_end); + }static int pid_cmp (struct work_atoms *l,struct work_atoms *r)
@@ -3599,6 +3615,7 @@ static int perf_sched__lat(struct perf_sched *sched) {int rc =-1 ;struct rb_node *next; +char total_runtime_str[32 ];setup_pager ();
@@ -3612,7 +3629,7 @@ static int perf_sched__lat(struct perf_sched *sched)perf_sched__sort_lat (sched);printf ("\n -------------------------------------------------------------------------------------------------------------------------------------------\n" ); -printf (" Task | Runtime ms | Count | Avg delay ms | Max delay ms | Max delay start | Max delay end |\n" ); +printf (" Task | Runtime | Count | Avg delay | Max delay | Max delay start | Max delay end |\n" );printf (" -------------------------------------------------------------------------------------------------------------------------------------------\n" ); next =rb_first_cached (&sched->sorted_atom_root);
@@ -3626,8 +3643,9 @@ static int perf_sched__lat(struct perf_sched *sched) }printf (" -----------------------------------------------------------------------------------------------------------------\n" ); -printf (" TOTAL: |%11.3f ms |%9" PRIu64" |\n" , - (double )sched->all_runtime /NSEC_PER_MSEC , sched->all_count); +scnprintf_latency_unit (total_runtime_str,sizeof (total_runtime_str), sched->all_runtime); +printf (" TOTAL: |%13s |%9" PRIu64" |\n" , + total_runtime_str, sched->all_count);printf (" ---------------------------------------------------\n" );
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 2/3] perf sched latency: Auto-scale latency and runtime display units
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The table column alignment in `perf sched latency` is broken by the new formatting widths…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The table column alignment in perf sched latency is broken by the new formatting widths, contradicting the commit message's claim of maintaining column alignment. --
--- Patch [2]: [PATCH v2 2/3] perf sched latency: Auto-scale latency and runtime display units --- commit bd1f9f65443ae53474112d9990f8290686a5aaa3
Author: Aaron Tomlin <[email protected]>
perf sched latency: Auto-scale latency and runtime display units
This commit introduces dynamic scaling for latency and runtime values in 'perf sched latency' output. It replaces hardcoded millisecond output with auto-scaled units (ns, us, ms, s) and updates the table formatting to improve readability.
Quoted 4 lines
tools/perf/builtin-sched.c +0
-0
[ ... ]
Quoted 11 lines
tools/perf/builtin-sched.c +3
-1@@ -1430,14 +1443,17 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_printf (" " ); avg = work_list->total_lat / work_list->nb_atoms; +scnprintf_latency_unit (runtime_lat,sizeof (runtime_lat), work_list->total_runtime); +scnprintf_latency_unit (avg_lat,sizeof (avg_lat), avg); +scnprintf_latency_unit (max_lat,sizeof (max_lat), work_list->max_lat);timestamp__scnprintf_usec (work_list->max_lat_start, max_lat_start,sizeof (max_lat_start));timestamp__scnprintf_usec (work_list->max_lat_end, max_lat_end,sizeof (max_lat_end)); - printf("|%11.3f ms |%9" PRIu64 " | avg:%8.3f ms | max:%8.3f ms | max start: %12s s | max end: %12s s\n",
tools/perf/builtin-sched.c static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ · line 1457
Quoted 10 lines
tools/perf/builtin-sched.c +5
-4- (double )work_list->total_runtime /NSEC_PER_MSEC , - work_list->nb_atoms, (double )avg /NSEC_PER_MSEC , - (double )work_list->max_lat /NSEC_PER_MSEC , - max_lat_start, max_lat_end); +printf ("|%13s |%9" PRIu64" | avg:%10s | max:%10s | max start: %12s s | max end: %12s s\n" , + runtime_lat, + work_list->nb_atoms, avg_lat, max_lat, + max_lat_start, max_lat_end); + }
[Severity: Low]
Does this format string break the column alignment?
The table header defines a width of 15 characters for the "Runtime" column
(| Runtime |), and 17 characters for the "Avg delay" and "Max delay"
columns. The new formats %13s and avg:%10s produce strings that are shorter than these expected widths, which appears to cause the vertical bar separators to misalign.
[ ... ]
Quoted 7 lines
tools/perf/builtin-sched.c +1
-1@@ -3612,7 +3629,7 @@ static int perf_sched__lat(struct perf_sched *sched)perf_sched__sort_lat (sched);printf ("\n -------------------------------------------------------------------------------------------------------------------------------------------\n" ); -printf (" Task | Runtime ms | Count | Avg delay ms | Max delay ms | Max delay start | Max delay end |\n" ); +printf (" Task | Runtime | Count | Avg delay | Max delay | Max delay start | Max delay end |\n" );printf (" -------------------------------------------------------------------------------------------------------------------------------------------\n" );
[ ... ]
tools/perf/builtin-sched.c static int perf_sched__lat(struct perf_sched *sched) · line 3650
Quoted 11 lines
tools/perf/builtin-sched.c +3
-2@@ -3626,8 +3643,9 @@ static int perf_sched__lat(struct perf_sched *sched) }printf (" -----------------------------------------------------------------------------------------------------------------\n" ); -printf (" TOTAL: |%11.3f ms |%9" PRIu64" |\n" , - (double )sched->all_runtime /NSEC_PER_MSEC , sched->all_count); +scnprintf_latency_unit (total_runtime_str,sizeof (total_runtime_str), sched->all_runtime); +printf (" TOTAL: |%13s |%9" PRIu64" |\n" , + total_runtime_str, sched->all_count);printf (" ---------------------------------------------------\n" );
[Severity: Low]
Does the use of %13s here also break the vertical alignment of the first column for the TOTAL row summary?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v2 2/3] perf sched latency: Auto-scale latency and runtime display units
Quoted 19 lines · On Sat, Jul 25, 2026 at 05:39:33PM +0000, [email protected] wrote:
Quoted 19 lines
tools/perf/builtin-sched.c +7
-5@@ -1430,14 +1443,17 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_printf (" " ); avg = work_list->total_lat / work_list->nb_atoms; +scnprintf_latency_unit (runtime_lat,sizeof (runtime_lat), work_list->total_runtime); +scnprintf_latency_unit (avg_lat,sizeof (avg_lat), avg); +scnprintf_latency_unit (max_lat,sizeof (max_lat), work_list->max_lat);timestamp__scnprintf_usec (work_list->max_lat_start, max_lat_start,sizeof (max_lat_start));timestamp__scnprintf_usec (work_list->max_lat_end, max_lat_end,sizeof (max_lat_end)); -printf ("|%11.3f ms |%9" PRIu64" | avg:%8.3f ms | max:%8.3f ms | max start: %12s s | max end: %12s s\n" , - (double )work_list->total_runtime /NSEC_PER_MSEC , - work_list->nb_atoms, (double )avg /NSEC_PER_MSEC , - (double )work_list->max_lat /NSEC_PER_MSEC , - max_lat_start, max_lat_end); +printf ("|%13s |%9" PRIu64" | avg:%10s | max:%10s | max start: %12s s | max end: %12s s\n" , + runtime_lat, + work_list->nb_atoms, avg_lat, max_lat, + max_lat_start, max_lat_end);
Quoted 8 lines
tools/perf/builtin-sched.c static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ · line 1457
Quoted 2 lines
tools/perf/builtin-sched.c +1
-0+ }The table header defines a width of 15 characters for the "Runtime" column
(| Runtime |), and 17 characters for the "Avg delay" and "Max delay"
columns. The new formats %13s and avg:%10s produce strings that are shorter than these expected widths, which appears to cause the vertical bar separators to misalign.
Acknowledged.
Quoted 11 lines
tools/perf/builtin-sched.c static int perf_sched__lat(struct perf_sched *sched) · line 3650
Quoted 11 lines
tools/perf/builtin-sched.c +3
-2@@ -3626,8 +3643,9 @@ static int perf_sched__lat(struct perf_sched *sched) }printf (" -----------------------------------------------------------------------------------------------------------------\n" ); -printf (" TOTAL: |%11.3f ms |%9" PRIu64" |\n" , - (double )sched->all_runtime /NSEC_PER_MSEC , sched->all_count); +scnprintf_latency_unit (total_runtime_str,sizeof (total_runtime_str), sched->all_runtime); +printf (" TOTAL: |%13s |%9" PRIu64" |\n" , + total_runtime_str, sched->all_count);printf (" ---------------------------------------------------\n" );
This is a minor concern. Nevertheless, I will address this and the above.
Kind regards,
Signature · 1 line
Aaron Tomlin
PATCH v2 3/3 perf sched latency: Add histogram and time interval options
In reply to Aaron TomlinWhile 'perf sched latency' reports task runtime and delay statistics (average and maximum delay), it does not provide a visual representation of how task wait times are distributed across latency ranges between snapshots (start and finish of the analysis window).
The --histogram option collects CPU wait latencies (time between when a task becomes runnable and when it gets scheduled onto a CPU) into 22 latency buckets, displaying an ASCII bar chart distribution.
The --hist-mode option configures the bucketing scheme:
- log (default). Logarithmic latency buckets ranging from sub-microsecond (< 1 us) up to >= 1.05 seconds
- linear. Equal-width linear latency buckets
(i.e., 100 us steps up to >= 2.1 ms)
The --time option allows filtering trace event processing to a specific time interval [start,stop].
Example histogram output excerpt:
❯ sudo perf sched latency --histogram --CPU 0
CPU Wait Latency Distribution Histogram (between snapshots) (total samples: 36114)
-------------------------------------------------------------------
Latency Range | Count | Pct | Histogram Graph
-------------------------------------------------------------------
< 1 us | 17 | 0.0% | #
2 - 4 us | 673 | 1.9% | #
4 - 8 us | 6237 | 17.3% | ######
8 - 16 us | 3224 | 8.9% | ###
16 - 32 us | 1388 | 3.8% | #
32 - 64 us | 709 | 2.0% | #
64 - 128 us | 690 | 1.9% | #
128 - 256 us | 789 | 2.2% | #
256 - 512 us | 541 | 1.5% | #
512 - 1024 us | 2256 | 6.2% | ##
1 - 2 ms | 3577 | 9.9% | ###
2 - 4 ms | 13259 | 36.7% | ##############
4 - 8 ms | 2523 | 7.0% | ##
8 - 16 ms | 222 | 0.6% | #
16 - 32 ms | 10 | 0.0% | #
>= 1.05 s | 3 | 0.0% | #
---------------------------------------------------------------------- tools/perf/Documentation/perf-sched.txt | 6 + tools/perf/builtin-sched.c | 179 +++++++++++++++++++++++- 2 files changed, 182 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-sched.txt +6 -0
@@ -40,6 +40,12 @@ There are several variants of 'perf sched': Tasks with the same command name are merged and the merge count is given within (), However if -p option is used, pid is mentioned. + If -H or --histogram option is passed, a CPU wait latency distribution + histogram is displayed illustrating how long tasks waited for CPU + runtime across latency buckets between snapshots. The --time + option (start,stop) limits analysis to a specific snapshot time interval. + The --hist-mode option (log or linear) configures the latency bucketing scheme. + 'perf sched script' to see a detailed trace of the workload that was recorded (aliased to 'perf script' for now).
tools/perf/builtin-sched.c +176 -3
282 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 3/3] perf sched latency: Add histogram and time interval options
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Global latency histogram incorrectly includes idle thread ('swapper') events, causing mismatched…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Global latency histogram incorrectly includes idle thread ('swapper') events, causing mismatched totals and percentages exceeding 100%.
- [Medium] The --time filtering option corrupts task state and records false 0-latency samples for tasks that cross the time window boundary. --
--- Patch [3]: [PATCH v2 3/3] perf sched latency: Add histogram and time interval options --- commit bb3a51b49ab123e7a4b3ab24f406cc892cd975b4
Author: Aaron Tomlin <[email protected]>
perf sched latency: Add histogram and time interval options
This commit adds a --histogram option to perf sched latency to display a visual bar chart of CPU wait latencies across buckets. It also adds a --time option to filter trace event processing to a specific time interval, and a --hist-mode option to configure logarithmic or linear bucketing.
Quoted 4 lines
tools/perf/builtin-sched.c +0
-0
[ ... ]
tools/perf/builtin-sched.c add_sched_in_event(struct work_atoms *atoms, u64 timestamp) · line 1297
Quoted 8 lines
tools/perf/builtin-sched.c +4
-0@@ -1169,6 +1291,10 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp) atoms->max_lat_end = timestamp; } atoms->nb_atoms++; + + b =latency_bucket (sched, delta); + atoms->hist[b]++; + sched->global_hist[b]++;
[Severity: Medium]
Will this unconditionally include 'swapper' events in global_hist?
Later in output_lat_thread(), 'swapper' threads are explicitly excluded from sched->all_count:
if (!strcmp(thread__comm_str(work_list->thread), "swapper")) return; sched->all_runtime += work_list->total_runtime; sched->all_count += work_list->nb_atoms;
Since sched->all_count is passed to print_latency_histogram() as the total count, including idle events in the histogram buckets but excluding them from the total could cause percentage calculations to exceed 100%.
Quoted 3 lines
tools/perf/builtin-sched.c +0
-0}static void free_work_atoms (struct work_atoms *atoms)
[ ... ]
tools/perf/builtin-sched.c static int latency_wakeup_event(struct perf_sched *sched, · line 1451
Quoted 7 lines
tools/perf/builtin-sched.c +3
-0@@ -1313,6 +1446,9 @@ static int latency_wakeup_event(struct perf_sched *sched,u64 timestamp = sample->time;int err =-1 ; +if (perf_time__skip_sample (&sched->ptime, sample->time)) +return 0 ; +
[Severity: Medium]
Does unconditionally skipping samples outside the time window break the internal state tracking?
If a task wakes up before the time window starts, its wakeup event is skipped here, preventing its wake_up_time from being recorded.
When the switch event later occurs inside the time window, the task might be treated as newly seen or stuck in a sleeping state, potentially resulting in false zero-latency samples or dropped tracking. Could we maintain the task state machine even for samples outside the window?
Quoted 3 lines
tools/perf/builtin-sched.c +0
-0wakee =machine__findnew_thread (machine,-1 , pid);if (wakee ==NULL )return -1 ;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v2 3/3] perf sched latency: Add histogram and time interval options
Quoted 20 lines · On Sat, Jul 25, 2026 at 05:44:21PM +0000, [email protected] wrote:
tools/perf/builtin-sched.c add_sched_in_event(struct work_atoms *atoms, u64 timestamp) · line 1297
Quoted 8 lines
tools/perf/builtin-sched.c +4
-0@@ -1169,6 +1291,10 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp) atoms->max_lat_end = timestamp; } atoms->nb_atoms++; + + b =latency_bucket (sched, delta); + atoms->hist[b]++; + sched->global_hist[b]++;Will this unconditionally include 'swapper' events in
global_hist?Later in
output_lat_thread(), 'swapper' threads are explicitly excluded fromsched->all_count:if (!strcmp(thread__comm_str(work_list->thread), "swapper")) return; sched->all_runtime += work_list->total_runtime; sched->all_count += work_list->nb_atoms;
Quoted 3 lines
Since
sched->all_countis passed toprint_latency_histogram()as the total count, including idle events in the histogram buckets but excluding them from the total could cause percentage calculations to exceed 100%.
A valid concern. Moving forward, sched->global_hist[b] is now incremented only when strcmp(thread__comm_str(atoms->thread), "swapper") is non-zero. This ensures sched->global_hist counts only non-idle task events.
Quoted 10 lines
tools/perf/builtin-sched.c static int latency_wakeup_event(struct perf_sched *sched, · line 1451
Quoted 7 lines
tools/perf/builtin-sched.c +3
-0@@ -1313,6 +1446,9 @@ static int latency_wakeup_event(struct perf_sched *sched,u64 timestamp = sample->time;int err =-1 ; +if (perf_time__skip_sample (&sched->ptime, sample->time)) +return 0 ; +Does unconditionally skipping samples outside the time window break the internal state tracking?
Quoted 7 lines
If a task wakes up before the time window starts, its wakeup event is skipped here, preventing its
wake_up_timefrom being recorded.When the switch event later occurs inside the time window, the task might be treated as newly seen or stuck in a sleeping state, potentially resulting in false zero-latency samples or dropped tracking. Could we maintain the task state machine even for samples outside the window?
This can be resolved by removing early perf_time__skip_sample() returns from event handlers (latency_switch_event, latency_runtime_event, latency_wakeup_event, and latency_migrate_task_event), allowing state machine tracking (atom->wake_up_time, atom->state, etc.) to run for all events regardless of time window bounds.
Finally move perf_time__skip_sample() inside add_sched_in_event(). So sample time filtering strictly gates the accumulation of latency statistics (atoms->nb_atoms, atoms->hist, sched->global_hist), preventing false or corrupted latency values when a task wakes up before the requested time window and is scheduled in inside it.
Signature · 1 line
Aaron Tomlin