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] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 10 Oct 2022 16:36:56 -0700
From:   Ian Rogers <irogers@...gle.com>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...nel.org>, Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        linux-perf-users@...r.kernel.org,
        Kan Liang <kan.liang@...ux.intel.com>,
        Leo Yan <leo.yan@...aro.org>, Andi Kleen <ak@...ux.intel.com>,
        Athira Rajeev <atrajeev@...ux.vnet.ibm.com>,
        James Clark <james.clark@....com>,
        Xing Zhengjun <zhengjun.xing@...ux.intel.com>
Subject: Re: [PATCH 16/19] perf stat: Add perf_stat_process_shadow_stats()

On Sun, Oct 9, 2022 at 10:36 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> This function updates the shadow stats using the aggregated counts
> uniformly since it uses the aggr_counts for the every aggr mode.
>
> It'd have duplicate shadow stats for each items for now since the
> display routines will update them once again.  But that'd be fine
> as it shows the average values and it'd be gone eventually.
>
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>

Acked-by: Ian Rogers <irogers@...gle.com>

Thanks,
Ian

> ---
>  tools/perf/builtin-stat.c |  1 +
>  tools/perf/util/stat.c    | 50 ++++++++++++++++++++-------------------
>  tools/perf/util/stat.h    |  1 +
>  3 files changed, 28 insertions(+), 24 deletions(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index c127e784a7be..d92815f4eae0 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -489,6 +489,7 @@ static void process_counters(void)
>
>         perf_stat_merge_counters(&stat_config, evsel_list);
>         perf_stat_process_percore(&stat_config, evsel_list);
> +       perf_stat_process_shadow_stats(&stat_config, evsel_list);
>  }
>
>  static void process_interval(void)
> diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
> index d788d0e85204..f2a3761dacff 100644
> --- a/tools/perf/util/stat.c
> +++ b/tools/perf/util/stat.c
> @@ -454,7 +454,7 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
>                 aggr_counts->val += count->val;
>                 aggr_counts->ena += count->ena;
>                 aggr_counts->run += count->run;
> -               goto update;
> +               return 0;
>         }
>
>         if (ps->aggr) {
> @@ -491,32 +491,10 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
>                 }
>         }
>
> -update:
> -       switch (config->aggr_mode) {
> -       case AGGR_THREAD:
> -       case AGGR_CORE:
> -       case AGGR_DIE:
> -       case AGGR_SOCKET:
> -       case AGGR_NODE:
> -       case AGGR_NONE:
> -               if ((config->aggr_mode == AGGR_NONE) && (!evsel->percore)) {
> -                       perf_stat__update_shadow_stats(evsel, count->val,
> -                                                      cpu_map_idx, &rt_stat);
> -               }
> -
> -               if (config->aggr_mode == AGGR_THREAD) {
> -                       perf_stat__update_shadow_stats(evsel, count->val,
> -                                                      thread, &rt_stat);
> -               }
> -               break;
> -       case AGGR_GLOBAL:
> +       if (config->aggr_mode == AGGR_GLOBAL) {
>                 aggr->val += count->val;
>                 aggr->ena += count->ena;
>                 aggr->run += count->run;
> -       case AGGR_UNSET:
> -       case AGGR_MAX:
> -       default:
> -               break;
>         }
>
>         return 0;
> @@ -742,6 +720,30 @@ void perf_stat_process_percore(struct perf_stat_config *config, struct evlist *e
>                 evsel__process_percore(evsel);
>  }
>
> +static void evsel__update_shadow_stats(struct evsel *evsel)
> +{
> +       struct perf_stat_evsel *ps = evsel->stats;
> +       int i;
> +
> +       if (ps->aggr == NULL)
> +               return;
> +
> +       for (i = 0; i < ps->nr_aggr; i++) {
> +               struct perf_counts_values *aggr_counts = &ps->aggr[i].counts;
> +
> +               perf_stat__update_shadow_stats(evsel, aggr_counts->val, i, &rt_stat);
> +       }
> +}
> +
> +void perf_stat_process_shadow_stats(struct perf_stat_config *config __maybe_unused,
> +                                   struct evlist *evlist)
> +{
> +       struct evsel *evsel;
> +
> +       evlist__for_each_entry(evlist, evsel)
> +               evsel__update_shadow_stats(evsel);
> +}
> +
>  int perf_event__process_stat_event(struct perf_session *session,
>                                    union perf_event *event)
>  {
> diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
> index ac85ed46aa59..e51214918c7f 100644
> --- a/tools/perf/util/stat.h
> +++ b/tools/perf/util/stat.h
> @@ -273,6 +273,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
>                               struct evsel *counter);
>  void perf_stat_merge_counters(struct perf_stat_config *config, struct evlist *evlist);
>  void perf_stat_process_percore(struct perf_stat_config *config, struct evlist *evlist);
> +void perf_stat_process_shadow_stats(struct perf_stat_config *config, struct evlist *evlist);
>
>  struct perf_tool;
>  union perf_event;
> --
> 2.38.0.rc1.362.ged0d419d3c-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ