lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAP-5=fUcCjDpu3=FNkiayZG7gpTzo9VLnEO-YM_b=GPwdDeLbw@mail.gmail.com>
Date: Thu, 6 Nov 2025 10:43:24 -0800
From: Ian Rogers <irogers@...gle.com>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
	Arnaldo Carvalho de Melo <acme@...nel.org>, Alexander Shishkin <alexander.shishkin@...ux.intel.com>, 
	Jiri Olsa <jolsa@...nel.org>, Adrian Hunter <adrian.hunter@...el.com>, 
	James Clark <james.clark@...aro.org>, Xu Yang <xu.yang_2@....com>, 
	Chun-Tse Shao <ctshao@...gle.com>, Thomas Richter <tmricht@...ux.ibm.com>, 
	Sumanth Korikkar <sumanthk@...ux.ibm.com>, Collin Funk <collin.funk1@...il.com>, 
	Thomas Falcon <thomas.falcon@...el.com>, Howard Chu <howardchu95@...il.com>, 
	Dapeng Mi <dapeng1.mi@...ux.intel.com>, Levi Yun <yeoreum.yun@....com>, 
	Yang Li <yang.lee@...ux.alibaba.com>, linux-kernel@...r.kernel.org, 
	linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v1 07/22] perf expr: Add #target_cpu literal

On Mon, Nov 3, 2025 at 8:56 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> On Fri, Oct 24, 2025 at 10:58:42AM -0700, Ian Rogers wrote:
> > For CPU nanoseconds a lot of the stat-shadow metrics use either
> > task-clock or cpu-clock, the latter being used when
> > target__has_cpu. Add a #target_cpu literal so that json metrics can
> > perform the same test.
>
> Do we have documentation for the literals and metric expressions in
> general?  I think it's getting complex and we should provide one.

So in general all these are documented in the tools events in `perf list`:
```
$ perf list
...
tool:
  duration_time
       [Wall clock interval time in nanoseconds. Unit: tool]
  has_pmem
       [1 if persistent memory installed otherwise 0. Unit: tool]
  num_cores
       [Number of cores. A core consists of 1 or more thread,with each
thread being associated
        with a logical Linux CPU. Unit: tool]
  num_cpus
       [Number of logical Linux CPUs. There may be multiple such CPUs
on a core. Unit: tool]
  num_cpus_online
       [Number of online logical Linux CPUs. There may be multiple
such CPUs on a core. Unit: tool]
  num_dies
       [Number of dies. Each die has 1 or more cores. Unit: tool]
  num_packages
       [Number of packages. Each package has 1 or more die. Unit: tool]
  smt_on
       [1 if simultaneous multithreading (aka hyperthreading) is
enable otherwise 0. Unit: tool]
  system_time
       [System/kernel time in nanoseconds. Unit: tool]
  system_tsc_freq
       [The amount a Time Stamp Counter (TSC) increases per second. Unit: tool]
  user_time
       [User (non-kernel) time in nanoseconds. Unit: tool]
```

We haven't done that with #core_wide and I followed that pattern for
#target_cpu as they do similar things. The issue with these two
"literals", why they are hard to be tool events, is that they depend
on command line options that may be processed after the processing of
the metrics. We could make tool versions with some plumbing. I'll look
to add that.

Thanks,
Ian

> Thanks,
> Namhyung
>
> >
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > ---
> >  tools/perf/util/expr.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> > index 7fda0ff89c16..4df56f2b283d 100644
> > --- a/tools/perf/util/expr.c
> > +++ b/tools/perf/util/expr.c
> > @@ -409,6 +409,9 @@ double expr__get_literal(const char *literal, const struct expr_scanner_ctx *ctx
> >       } else if (!strcmp("#core_wide", literal)) {
> >               result = core_wide(ctx->system_wide, ctx->user_requested_cpu_list)
> >                       ? 1.0 : 0.0;
> > +     } else if (!strcmp("#target_cpu", literal)) {
> > +             result = (ctx->system_wide || ctx->user_requested_cpu_list)
> > +                     ? 1.0 : 0.0;
> >       } else {
> >               pr_err("Unrecognized literal '%s'", literal);
> >       }
> > --
> > 2.51.1.821.gb6fe4d2222-goog
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ