Re: [PATCH v5 6/8] perf report: Add --latency flag

From: Namhyung Kim
Date: Thu Feb 06 2025 - 22:53:31 EST


On Wed, Feb 05, 2025 at 05:27:45PM +0100, Dmitry Vyukov wrote:
> Add record/report --latency flag that allows to capture and show
> latency-centric profiles rather than the default CPU-consumption-centric
> profiles. For latency profiles record captures context switch events,
> and report shows Latency as the first column.
>
> Signed-off-by: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Ian Rogers <irogers@xxxxxxxxxx>
> Cc: linux-perf-users@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
>
> ---
[SNIP]
> +void perf_hpp__cancel_latency(void)
> +{
> + struct perf_hpp_fmt *fmt, *lat, *acc, *tmp;
> +
> + if (is_strict_order(field_order) || is_strict_order(sort_order))
> + return;

This also needs to be changed since you call setup_overhead even if you
have a strict sort_order.

For example, it's strange these two are different.

With default sort order:

$ perf record --latency -- ls /

$ perf report --stdio
...
# Overhead Command Shared Object Symbol
# ........ ....... .................... ........................
#
64.50% ls ld-linux-x86-64.so.2 [.] do_lookup_x
33.41% ls [kernel.kallsyms] [k] chacha_block_generic
2.00% perf-ex [kernel.kallsyms] [k] put_ctx
0.09% perf-ex [kernel.kallsyms] [k] native_write_msr

Same sort order, but explicitly:

$ perf report --stdio -s comm,dso,sym
...
# Overhead Latency Command Shared Object Symbol
# ........ ........ ....... .................... ........................
#
64.50% 64.50% ls ld-linux-x86-64.so.2 [.] do_lookup_x
33.41% 33.41% ls [kernel.kallsyms] [k] chacha_block_generic
2.00% 2.00% perf-ex [kernel.kallsyms] [k] put_ctx
0.09% 0.09% perf-ex [kernel.kallsyms] [k] native_write_msr

Maybe you want to cancel the latency field even if sort key is given
(unless it has 'latency').

Something like this?

---8<---
@@ -714,7 +715,9 @@ void perf_hpp__cancel_latency(void)
{
struct perf_hpp_fmt *fmt, *lat, *acc, *tmp;

- if (is_strict_order(field_order) || is_strict_order(sort_order))
+ if (is_strict_order(field_order))
+ return;
+ if (is_strict_order(sort_order) && strstr(sort_order, "latency"))
return;

lat = &perf_hpp__format[PERF_HPP__LATENCY];
---8<---

Thanks,
Namhyung

> +
> + lat = &perf_hpp__format[PERF_HPP__LATENCY];
> + acc = &perf_hpp__format[PERF_HPP__LATENCY_ACC];
> +
> + perf_hpp_list__for_each_format_safe(&perf_hpp_list, fmt, tmp) {
> + if (fmt_equal(lat, fmt) || fmt_equal(acc, fmt))
> + perf_hpp__column_unregister(fmt);
> + }
> +}
> +
> void perf_hpp__setup_output_field(struct perf_hpp_list *list)
> {
> struct perf_hpp_fmt *fmt;