* [PATCH] perf sched: Suppress latency table output when trace samples are missing
@ 2026-07-24 14:29 Aaron Tomlin
2026-07-25 3:14 ` Aaron Tomlin
0 siblings, 1 reply; 2+ messages in thread
From: Aaron Tomlin @ 2026-07-24 14:29 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung
Cc: mark.rutland, alexander.shishkin, jolsa, irogers, adrian.hunter,
james.clark, howardchu95, atomlin, neelx, chjohnst, sean, steve,
linux-perf-users, linux-kernel
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.
Fixes: 27295592c22e ("perf session: Share the common trace sample_check routine as perf_session__has_traces")
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
tools/perf/builtin-sched.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 7fd63a9db457..b3cf678573e0 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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);
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] perf sched: Suppress latency table output when trace samples are missing
2026-07-24 14:29 [PATCH] perf sched: Suppress latency table output when trace samples are missing Aaron Tomlin
@ 2026-07-25 3:14 ` Aaron Tomlin
0 siblings, 0 replies; 2+ messages in thread
From: Aaron Tomlin @ 2026-07-25 3:14 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung
Cc: mark.rutland, alexander.shishkin, jolsa, irogers, adrian.hunter,
james.clark, howardchu95, neelx, chjohnst, sean, steve,
linux-perf-users, linux-kernel
On Fri, Jul 24, 2026 at 10:29:01AM -0400, Aaron Tomlin wrote:
> 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.
>
> Fixes: 27295592c22e ("perf session: Share the common trace sample_check routine as perf_session__has_traces")
> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
> ---
> tools/perf/builtin-sched.c | 21 +++++++++++----------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 7fd63a9db457..b3cf678573e0 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -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);
> --
> 2.54.0
>
Hi Peter, Ingo, Arnaldo, Namhyung, Ian,
Please ignore this patch.
I will include it as part of a series for '[RFC PATCH] perf sched latency:
Add histogram and time interval options' [1]. Thank you.
[1]: https://lore.kernel.org/lkml/20260724201207.661300-1-atomlin@atomlin.com/
Kind regards,
--
Aaron Tomlin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-25 3:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 14:29 [PATCH] perf sched: Suppress latency table output when trace samples are missing Aaron Tomlin
2026-07-25 3:14 ` Aaron Tomlin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox