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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAM9d7cj-q8Zxf1hqBYSnTrfCJmbgxs9KhFn5m1TYmFjGbwubCg@mail.gmail.com>
Date:   Fri, 17 Nov 2023 13:36:06 -0800
From:   Namhyung Kim <namhyung@...nel.org>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Yang Jihong <yangjihong1@...wei.com>,
        Leo Yan <leo.yan@...aro.org>,
        Sandipan Das <sandipan.das@....com>,
        Ravi Bangoria <ravi.bangoria@....com>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
        Ajay Kaher <akaher@...are.com>,
        Alexey Makhalov <amakhalov@...are.com>
Subject: Re: [RFC PATCH v1] perf evsel: Fallback to task-clock when not system wide

Hi Ian,

On Tue, Nov 14, 2023 at 1:13 PM Ian Rogers <irogers@...gle.com> wrote:
>
> When the cycles event isn't available evsel will fallback to the
> cpu-clock software event. task-clock is similar to cpu-clock but only
> runs when the process is running. Falling back to cpu-clock when not
> system wide leads to confusion, by falling back to task-clock it is
> hoped the confusion is less.

I think they are almost the same and no meaningful difference.
The cpu-clock event also runs only when the task is running if
it's a per-task event.

>
> Update a nearby comment and debug string for the change.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
>  tools/perf/util/evsel.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index a5da74e3a517..e1175313e4bc 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2861,18 +2861,19 @@ bool evsel__fallback(struct evsel *evsel, int err, char *msg, size_t msgsize)
>             evsel->core.attr.type   == PERF_TYPE_HARDWARE &&
>             evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES) {
>                 /*
> -                * If it's cycles then fall back to hrtimer based
> -                * cpu-clock-tick sw counter, which is always available even if
> -                * no PMU support.
> +                * If it's cycles then fall back to hrtimer based cpu-clock sw
> +                * counter, which is always available even if no PMU support.
>                  *
>                  * PPC returns ENXIO until 2.6.37 (behavior changed with commit
>                  * b0a873e).
>                  */
> -               scnprintf(msg, msgsize, "%s",
> -"The cycles event is not supported, trying to fall back to cpu-clock-ticks");
> -
>                 evsel->core.attr.type   = PERF_TYPE_SOFTWARE;
> -               evsel->core.attr.config = PERF_COUNT_SW_CPU_CLOCK;
> +               evsel->core.attr.config = evsel->core.system_wide

I'm not sure you can use the system_wide flag for this.
IIUC it's to override the target setting in some cases
(e.g. a dummy event to track sideband events in all CPUs)
and I think you need to check target__has_cpu() instead.

But as I said above, it won't make any difference in the
output.  Conceptually it'd be more natural to use task-clock
event for per-task sessions though.

Thanks,
Namhyung


> +                       ? PERF_COUNT_SW_CPU_CLOCK
> +                       : PERF_COUNT_SW_TASK_CLOCK;
> +               scnprintf(msg, msgsize,
> +                       "The cycles event is not supported, trying to fall back to %s",
> +                       evsel->core.system_wide ? "cpu-clock" : "task-clock");
>
>                 zfree(&evsel->name);
>                 return true;
> --
> 2.43.0.rc0.421.g78406f8d94-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ