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]
Message-ID: <CAP-5=fUDiDWT3oEqS5NmVn-muhC+P=g5rW2aEyAgAQLS=UYxQw@mail.gmail.com>
Date:   Wed, 6 Dec 2023 13:08:34 -0800
From:   Ian Rogers <irogers@...gle.com>
To:     kan.liang@...ux.intel.com
Cc:     acme@...nel.org, peterz@...radead.org, mingo@...hat.com,
        namhyung@...nel.org, jolsa@...nel.org, adrian.hunter@...el.com,
        john.g.garry@...cle.com, will@...nel.org, james.clark@....com,
        mike.leach@...aro.org, leo.yan@...aro.org,
        yuhaixin.yhx@...ux.alibaba.com, renyu.zj@...ux.alibaba.com,
        tmricht@...ux.ibm.com, ravi.bangoria@....com,
        linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 4/6] perf mem: Clean up perf_mem_event__supported()

On Wed, Dec 6, 2023 at 12:13 PM <kan.liang@...ux.intel.com> wrote:
>
> From: Kan Liang <kan.liang@...ux.intel.com>
>
> For some ARCHs, e.g., ARM and AMD, to get the availability of the
> mem-events, perf checks the existence of a specific PMU. For the other
> ARCHs, e.g., Intel and Power, perf has to check the existence of some
> specific events.
>
> The current perf only iterates the mem-events-supported PMUs. It's not
> required to check the existence of a specific PMU anymore.
>
> Rename sysfs_name to event_name, which stores the specific mem-events.
> Perf only needs to check those events for the availability of the
> mem-events.
>
> Signed-off-by: Kan Liang <kan.liang@...ux.intel.com>

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

Thanks,
Ian

> ---
>  tools/perf/arch/arm64/util/mem-events.c   |  8 ++++----
>  tools/perf/arch/powerpc/util/mem-events.c |  8 ++++----
>  tools/perf/arch/x86/util/mem-events.c     | 20 ++++++++++----------
>  tools/perf/util/mem-events.c              | 16 +++++++++-------
>  tools/perf/util/mem-events.h              |  2 +-
>  5 files changed, 28 insertions(+), 26 deletions(-)
>
> diff --git a/tools/perf/arch/arm64/util/mem-events.c b/tools/perf/arch/arm64/util/mem-events.c
> index eb2ef84f0fc8..590dddd6b0ab 100644
> --- a/tools/perf/arch/arm64/util/mem-events.c
> +++ b/tools/perf/arch/arm64/util/mem-events.c
> @@ -2,10 +2,10 @@
>  #include "map_symbol.h"
>  #include "mem-events.h"
>
> -#define E(t, n, s, l, a) { .tag = t, .name = n, .sysfs_name = s, .ldlat = l, .aux_event = a }
> +#define E(t, n, s, l, a) { .tag = t, .name = n, .event_name = s, .ldlat = l, .aux_event = a }
>
>  struct perf_mem_event perf_mem_events_arm[PERF_MEM_EVENTS__MAX] = {
> -       E("spe-load",   "%s/ts_enable=1,pa_enable=1,load_filter=1,store_filter=0,min_latency=%u/",      "arm_spe_0",    true,   0),
> -       E("spe-store",  "%s/ts_enable=1,pa_enable=1,load_filter=0,store_filter=1/",                     "arm_spe_0",    false,  0),
> -       E("spe-ldst",   "%s/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=%u/",      "arm_spe_0",    true,   0),
> +       E("spe-load",   "%s/ts_enable=1,pa_enable=1,load_filter=1,store_filter=0,min_latency=%u/",      NULL,   true,   0),
> +       E("spe-store",  "%s/ts_enable=1,pa_enable=1,load_filter=0,store_filter=1/",                     NULL,   false,  0),
> +       E("spe-ldst",   "%s/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=%u/",      NULL,   true,   0),
>  };
> diff --git a/tools/perf/arch/powerpc/util/mem-events.c b/tools/perf/arch/powerpc/util/mem-events.c
> index b7883e38950f..72a6ac2b52f5 100644
> --- a/tools/perf/arch/powerpc/util/mem-events.c
> +++ b/tools/perf/arch/powerpc/util/mem-events.c
> @@ -2,10 +2,10 @@
>  #include "map_symbol.h"
>  #include "mem-events.h"
>
> -#define E(t, n, s, l, a) { .tag = t, .name = n, .sysfs_name = s, .ldlat = l, .aux_event = a }
> +#define E(t, n, s, l, a) { .tag = t, .name = n, .event_name = s, .ldlat = l, .aux_event = a }
>
>  struct perf_mem_event perf_mem_events_power[PERF_MEM_EVENTS__MAX] = {
> -       E("ldlat-loads",        "%s/mem-loads/",        "cpu/events/mem-loads",         false,  0),
> -       E("ldlat-stores",       "%s/mem-stores/",       "cpu/events/mem-stores",        false,  0),
> -       E(NULL,                 NULL,                   NULL,                           false,  0),
> +       E("ldlat-loads",        "%s/mem-loads/",        "mem-loads",    false,  0),
> +       E("ldlat-stores",       "%s/mem-stores/",       "mem-stores",   false,  0),
> +       E(NULL,                 NULL,                   NULL,           false,  0),
>  };
> diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c
> index f0e66a0151a0..b776d849fc64 100644
> --- a/tools/perf/arch/x86/util/mem-events.c
> +++ b/tools/perf/arch/x86/util/mem-events.c
> @@ -9,24 +9,24 @@
>
>  #define MEM_LOADS_AUX          0x8203
>
> -#define E(t, n, s, l, a) { .tag = t, .name = n, .sysfs_name = s, .ldlat = l, .aux_event = a }
> +#define E(t, n, s, l, a) { .tag = t, .name = n, .event_name = s, .ldlat = l, .aux_event = a }
>
>  struct perf_mem_event perf_mem_events_intel[PERF_MEM_EVENTS__MAX] = {
> -       E("ldlat-loads",        "%s/mem-loads,ldlat=%u/P",      "%s/events/mem-loads",  true,   0),
> -       E("ldlat-stores",       "%s/mem-stores/P",              "%s/events/mem-stores", false,  0),
> -       E(NULL,                 NULL,                           NULL,                   false,  0),
> +       E("ldlat-loads",        "%s/mem-loads,ldlat=%u/P",      "mem-loads",    true,   0),
> +       E("ldlat-stores",       "%s/mem-stores/P",              "mem-stores",   false,  0),
> +       E(NULL,                 NULL,                           NULL,           false,  0),
>  };
>
>  struct perf_mem_event perf_mem_events_intel_aux[PERF_MEM_EVENTS__MAX] = {
> -       E("ldlat-loads",        "{%s/mem-loads-aux/,%s/mem-loads,ldlat=%u/}:P", "%s/events/mem-loads",  true,   MEM_LOADS_AUX),
> -       E("ldlat-stores",       "%s/mem-stores/P",              "%s/events/mem-stores", false,  0),
> -       E(NULL,                 NULL,                           NULL,                   false,  0),
> +       E("ldlat-loads",        "{%s/mem-loads-aux/,%s/mem-loads,ldlat=%u/}:P", "mem-loads",    true,   MEM_LOADS_AUX),
> +       E("ldlat-stores",       "%s/mem-stores/P",              "mem-stores",   false,  0),
> +       E(NULL,                 NULL,                           NULL,           false,  0),
>  };
>
>  struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX] = {
> -       E(NULL,         NULL,           NULL,           false,  0),
> -       E(NULL,         NULL,           NULL,           false,  0),
> -       E("mem-ldst",   "%s//",         "ibs_op",       false,  0),
> +       E(NULL,         NULL,           NULL,   false,  0),
> +       E(NULL,         NULL,           NULL,   false,  0),
> +       E("mem-ldst",   "%s//",         NULL,   false,  0),
>  };
>
>  bool is_mem_loads_aux_event(struct evsel *leader)
> diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
> index 3a60cbcd6d8e..9ea9e9a868c4 100644
> --- a/tools/perf/util/mem-events.c
> +++ b/tools/perf/util/mem-events.c
> @@ -17,12 +17,12 @@
>
>  unsigned int perf_mem_events__loads_ldlat = 30;
>
> -#define E(t, n, s, l, a) { .tag = t, .name = n, .sysfs_name = s, .ldlat = l, .aux_event = a }
> +#define E(t, n, s, l, a) { .tag = t, .name = n, .event_name = s, .ldlat = l, .aux_event = a }
>
>  struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
> -       E("ldlat-loads",        "%s/mem-loads/,ldlat=%u/P",     "cpu/events/mem-loads",         true,   0),
> -       E("ldlat-stores",       "%s/mem-stores/P",              "cpu/events/mem-stores",        false,  0),
> -       E(NULL,                 NULL,                           NULL,                           false,  0),
> +       E("ldlat-loads",        "%s/mem-loads/,ldlat=%u/P",     "mem-loads",    true,   0),
> +       E("ldlat-stores",       "%s/mem-stores/P",              "mem-stores",   false,  0),
> +       E(NULL,                 NULL,                           NULL,           false,  0),
>  };
>  #undef E
>
> @@ -150,12 +150,14 @@ int perf_mem_events__parse(struct perf_pmu *pmu, const char *str)
>  static bool perf_mem_event__supported(const char *mnt, struct perf_pmu *pmu,
>                                       struct perf_mem_event *e)
>  {
> -       char sysfs_name[100];
>         char path[PATH_MAX];
>         struct stat st;
>
> -       scnprintf(sysfs_name, sizeof(sysfs_name), e->sysfs_name, pmu->name);
> -       scnprintf(path, PATH_MAX, "%s/devices/%s", mnt, sysfs_name);
> +       if (!e->event_name)
> +               return true;
> +
> +       scnprintf(path, PATH_MAX, "%s/devices/%s/events/%s", mnt, pmu->name, e->event_name);
> +
>         return !stat(path, &st);
>  }
>
> diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
> index d257cf67d6d9..d2875d731da8 100644
> --- a/tools/perf/util/mem-events.h
> +++ b/tools/perf/util/mem-events.h
> @@ -18,7 +18,7 @@ struct perf_mem_event {
>         u32             aux_event;
>         const char      *tag;
>         const char      *name;
> -       const char      *sysfs_name;
> +       const char      *event_name;
>  };
>
>  struct mem_info {
> --
> 2.35.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ