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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 24 Aug 2022 08:45:44 -0700
From:   Ian Rogers <irogers@...gle.com>
To:     Adrian Hunter <adrian.hunter@...el.com>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/5] perf evlist: Add evlist__{en/dis}able_non_dummy()

On Wed, Aug 24, 2022 at 12:28 AM Adrian Hunter <adrian.hunter@...el.com> wrote:
>
> Dummy events are used to provide sideband information like MMAP events that
> are always needed even when main events are disabled. Add functions that
> take that into account.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>

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

Thanks,
Ian

> ---
>  tools/perf/util/evlist.c | 30 ++++++++++++++++++++++++------
>  tools/perf/util/evlist.h |  2 ++
>  2 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 4c5e6e9f8d11..3cfe730c12b8 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -480,7 +480,7 @@ static int evlist__is_enabled(struct evlist *evlist)
>         return false;
>  }
>
> -static void __evlist__disable(struct evlist *evlist, char *evsel_name)
> +static void __evlist__disable(struct evlist *evlist, char *evsel_name, bool excl_dummy)
>  {
>         struct evsel *pos;
>         struct evlist_cpu_iterator evlist_cpu_itr;
> @@ -502,6 +502,8 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name)
>                                 continue;
>                         if (pos->disabled || !evsel__is_group_leader(pos) || !pos->core.fd)
>                                 continue;
> +                       if (excl_dummy && evsel__is_dummy_event(pos))
> +                               continue;
>                         if (pos->immediate)
>                                 has_imm = true;
>                         if (pos->immediate != imm)
> @@ -518,6 +520,8 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name)
>                         continue;
>                 if (!evsel__is_group_leader(pos) || !pos->core.fd)
>                         continue;
> +               if (excl_dummy && evsel__is_dummy_event(pos))
> +                       continue;
>                 pos->disabled = true;
>         }
>
> @@ -533,15 +537,20 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name)
>
>  void evlist__disable(struct evlist *evlist)
>  {
> -       __evlist__disable(evlist, NULL);
> +       __evlist__disable(evlist, NULL, false);
> +}
> +
> +void evlist__disable_non_dummy(struct evlist *evlist)
> +{
> +       __evlist__disable(evlist, NULL, true);

nit: I think it is better to  prefer to name the argument when passing
constants, it can avoid errors if later constants are introduced, etc.
It can also be checked by compiler warnings. As this is limited to the
same file it is not hugely critical.

>  }
>
>  void evlist__disable_evsel(struct evlist *evlist, char *evsel_name)
>  {
> -       __evlist__disable(evlist, evsel_name);
> +       __evlist__disable(evlist, evsel_name, false);
>  }
>
> -static void __evlist__enable(struct evlist *evlist, char *evsel_name)
> +static void __evlist__enable(struct evlist *evlist, char *evsel_name, bool excl_dummy)
>  {
>         struct evsel *pos;
>         struct evlist_cpu_iterator evlist_cpu_itr;
> @@ -560,6 +569,8 @@ static void __evlist__enable(struct evlist *evlist, char *evsel_name)
>                         continue;
>                 if (!evsel__is_group_leader(pos) || !pos->core.fd)
>                         continue;
> +               if (excl_dummy && evsel__is_dummy_event(pos))
> +                       continue;
>                 evsel__enable_cpu(pos, evlist_cpu_itr.cpu_map_idx);
>         }
>         affinity__cleanup(affinity);
> @@ -568,6 +579,8 @@ static void __evlist__enable(struct evlist *evlist, char *evsel_name)
>                         continue;
>                 if (!evsel__is_group_leader(pos) || !pos->core.fd)
>                         continue;
> +               if (excl_dummy && evsel__is_dummy_event(pos))
> +                       continue;
>                 pos->disabled = false;
>         }
>
> @@ -581,12 +594,17 @@ static void __evlist__enable(struct evlist *evlist, char *evsel_name)
>
>  void evlist__enable(struct evlist *evlist)
>  {
> -       __evlist__enable(evlist, NULL);
> +       __evlist__enable(evlist, NULL, false);
> +}
> +
> +void evlist__enable_non_dummy(struct evlist *evlist)
> +{
> +       __evlist__enable(evlist, NULL, true);
>  }
>
>  void evlist__enable_evsel(struct evlist *evlist, char *evsel_name)
>  {
> -       __evlist__enable(evlist, evsel_name);
> +       __evlist__enable(evlist, evsel_name, false);
>  }
>
>  void evlist__toggle_enable(struct evlist *evlist)
> diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
> index 3a464585d397..3a8474406738 100644
> --- a/tools/perf/util/evlist.h
> +++ b/tools/perf/util/evlist.h
> @@ -205,6 +205,8 @@ void evlist__enable(struct evlist *evlist);
>  void evlist__toggle_enable(struct evlist *evlist);
>  void evlist__disable_evsel(struct evlist *evlist, char *evsel_name);
>  void evlist__enable_evsel(struct evlist *evlist, char *evsel_name);
> +void evlist__disable_non_dummy(struct evlist *evlist);
> +void evlist__enable_non_dummy(struct evlist *evlist);
>
>  void evlist__set_selected(struct evlist *evlist, struct evsel *evsel);
>
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ