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

Dmitry Vyukov
2025-02-07T11:42:19Z

On Fri, 7 Feb 2025 at 04:53, Namhyung Kim <namhyung@kernel.org> wrote:
>
> 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@google.com>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> > Cc: Ian Rogers <irogers@google.com>
> > Cc: linux-perf-users@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> >
> > ---
> [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?

Makes sense! Done in v6.

> ---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;