From: Namhyung Kim <namhyung@kernel.org>
To: Aaron Tomlin <atomlin@atomlin.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
james.clark@linaro.org, howardchu95@gmail.com, neelx@suse.com,
chjohnst@mail.com, sean@ashe.io, steve@abita.co,
rishil1999@outlook.com, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 4/4] perf sched latency: Add histogram and time interval options
Date: Mon, 3 Aug 2026 11:06:16 -0700 [thread overview]
Message-ID: <anDYmITjYFalURtB@google.com> (raw)
In-Reply-To: <20260802210914.199941-5-atomlin@atomlin.com>
On Sun, Aug 02, 2026 at 05:09:14PM -0400, Aaron Tomlin wrote:
> While '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% | #
> -------------------------------------------------------------------
>
> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
> ---
[SNIP]
> @@ -1168,7 +1306,13 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp)
> atoms->max_lat_start = atom->wake_up_time;
> atoms->max_lat_end = timestamp;
> }
> +
> atoms->nb_atoms++;
> +
> + b = latency_bucket(sched, delta);
> + atoms->hist[b]++;
> + if (strcmp(thread__comm_str(atoms->thread), "swapper"))
> + sched->global_hist[b]++;
Why is the swapper thread not included in the global hist?
Also it's probably better to check thread__tid being 0.
> }
>
> static void free_work_atoms(struct work_atoms *atoms)
[SNIP]
> @@ -3659,6 +3831,21 @@ static int perf_sched__lat(struct perf_sched *sched)
> perf_sched__merge_lat(sched);
> perf_sched__sort_lat(sched);
>
> + next = rb_first_cached(&sched->sorted_atom_root);
> + while (next) {
> + struct work_atoms *work_list = rb_entry(next, struct work_atoms, node);
> +
> + if (work_list->nb_atoms && strcmp(thread__comm_str(work_list->thread), "swapper"))
Ditto. Comparing TID would be faster.
Thanks,
Namhyung
> + break;
> + next = rb_next(next);
> + }
> +
> + if (!next) {
> + pr_info("No matching trace samples found.\n");
> + rc = 0;
> + goto out_free_atoms;
> + }
next prev parent reply other threads:[~2026-08-03 18:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 21:09 [PATCH v7 0/4] perf sched latency: Refine outputs, unit scaling, and histogram support Aaron Tomlin
2026-08-02 21:09 ` [PATCH v7 1/4] perf sched: Suppress latency table output when trace samples are missing Aaron Tomlin
2026-08-02 21:09 ` [PATCH v7 2/4] perf sched: Handle missing trace samples in pipe mode Aaron Tomlin
2026-08-03 17:59 ` Namhyung Kim
2026-08-05 19:58 ` Aaron Tomlin
2026-08-02 21:09 ` [PATCH v7 3/4] perf sched latency: Auto-scale latency and runtime display units Aaron Tomlin
2026-08-02 21:09 ` [PATCH v7 4/4] perf sched latency: Add histogram and time interval options Aaron Tomlin
2026-08-03 18:06 ` Namhyung Kim [this message]
2026-08-05 20:16 ` Aaron Tomlin
2026-08-04 17:11 ` [PATCH v7 0/4] perf sched latency: Refine outputs, unit scaling, and histogram support Namhyung Kim
2026-08-05 20:19 ` Aaron Tomlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=anDYmITjYFalURtB@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atomlin@atomlin.com \
--cc=chjohnst@mail.com \
--cc=howardchu95@gmail.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=neelx@suse.com \
--cc=peterz@infradead.org \
--cc=rishil1999@outlook.com \
--cc=sean@ashe.io \
--cc=steve@abita.co \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox