* [PATCH 2/2] perf, tools, list: Support matching by topic
2016-10-19 17:50 [PATCH 1/2] perf, tools, list: Make vendor event matching case insensitive Andi Kleen
@ 2016-10-19 17:50 ` Andi Kleen
2016-10-19 18:13 ` Arnaldo Carvalho de Melo
2016-10-19 18:13 ` [PATCH 1/2] perf, tools, list: Make vendor event matching case insensitive Arnaldo Carvalho de Melo
2016-10-24 19:07 ` [tip:perf/core] perf " tip-bot for Andi Kleen
2 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2016-10-19 17:50 UTC (permalink / raw)
To: acme; +Cc: jolsa, linux-kernel, mingo, Andi Kleen
From: Andi Kleen <ak@linux.intel.com>
Add support in perf list topic to only show events belonging to a specific
vendor events topic. For example the following works now:
% perf list frontend
List of pre-defined events (to be used in -e):
stalled-cycles-frontend OR idle-cycles-frontend [Hardware event]
stalled-cycles-frontend OR cpu/stalled-cycles-frontend/ [Kernel PMU event]
frontend:
dsb2mite_switches.count
[Decode Stream Buffer (DSB)-to-MITE switches]
dsb2mite_switches.penalty_cycles
[Decode Stream Buffer (DSB)-to-MITE switch true penalty cycles]
dsb_fill.exceed_dsb_lines
[Cycles when Decode Stream Buffer (DSB) fill encounter more than 3 Decode Stream Buffer (DSB)
lines]
icache.hit
[Number of Instruction Cache, Streaming Buffer and Victim Cache Reads. both cacheable and
noncacheable, including UC fetches]
...
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
tools/perf/builtin-list.c | 6 ++++--
tools/perf/util/pmu.c | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 1095a6dada66..c00b0eb343c0 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -67,9 +67,11 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
print_symbol_events(NULL, PERF_TYPE_SOFTWARE,
event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
else if (strcmp(argv[i], "cache") == 0 ||
- strcmp(argv[i], "hwcache") == 0)
+ strcmp(argv[i], "hwcache") == 0) {
print_hwcache_events(NULL, raw_dump);
- else if (strcmp(argv[i], "pmu") == 0)
+ print_pmu_events(argv[i], raw_dump, !desc_flag,
+ long_desc_flag, true);
+ } else if (strcmp(argv[i], "pmu") == 0)
print_pmu_events(NULL, raw_dump, !desc_flag,
long_desc_flag, false);
else if (strcmp(argv[i], "sdt") == 0)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 101922b2a243..dc8eb30e8597 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1142,7 +1142,9 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
if (event_glob != NULL &&
!(strglobmatch_nocase(name, event_glob) ||
(!is_cpu && strglobmatch_nocase(alias->name,
- event_glob))))
+ event_glob)) ||
+ (alias->topic &&
+ strglobmatch_nocase(alias->topic, event_glob))))
continue;
if (is_cpu && !name_only && !alias->desc)
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] perf, tools, list: Support matching by topic
2016-10-19 17:50 ` [PATCH 2/2] perf, tools, list: Support matching by topic Andi Kleen
@ 2016-10-19 18:13 ` Arnaldo Carvalho de Melo
2016-10-19 18:32 ` Andi Kleen
0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-19 18:13 UTC (permalink / raw)
To: Andi Kleen; +Cc: jolsa, linux-kernel, mingo, Andi Kleen
Em Wed, Oct 19, 2016 at 10:50:02AM -0700, Andi Kleen escreveu:
> From: Andi Kleen <ak@linux.intel.com>
>
> Add support in perf list topic to only show events belonging to a specific
> vendor events topic. For example the following works now:
>
> % perf list frontend
> List of pre-defined events (to be used in -e):
>
> stalled-cycles-frontend OR idle-cycles-frontend [Hardware event]
>
> stalled-cycles-frontend OR cpu/stalled-cycles-frontend/ [Kernel PMU event]
>
> frontend:
> dsb2mite_switches.count
> [Decode Stream Buffer (DSB)-to-MITE switches]
> dsb2mite_switches.penalty_cycles
> [Decode Stream Buffer (DSB)-to-MITE switch true penalty cycles]
> dsb_fill.exceed_dsb_lines
> [Cycles when Decode Stream Buffer (DSB) fill encounter more than 3 Decode Stream Buffer (DSB)
> lines]
> icache.hit
> [Number of Instruction Cache, Streaming Buffer and Victim Cache Reads. both cacheable and
> noncacheable, including UC fetches]
> ...
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
> tools/perf/builtin-list.c | 6 ++++--
> tools/perf/util/pmu.c | 4 +++-
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> index 1095a6dada66..c00b0eb343c0 100644
> --- a/tools/perf/builtin-list.c
> +++ b/tools/perf/builtin-list.c
> @@ -67,9 +67,11 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
> print_symbol_events(NULL, PERF_TYPE_SOFTWARE,
> event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
> else if (strcmp(argv[i], "cache") == 0 ||
> - strcmp(argv[i], "hwcache") == 0)
> + strcmp(argv[i], "hwcache") == 0) {
This is changing existing behaviour, please remove it. A separate patch
could either make it show both hwcache events and vendor cache events,
or you could make:
perf list vendor cache
Do what you expect.
> print_hwcache_events(NULL, raw_dump);
> - else if (strcmp(argv[i], "pmu") == 0)
> + print_pmu_events(argv[i], raw_dump, !desc_flag,
> + long_desc_flag, true);
> + } else if (strcmp(argv[i], "pmu") == 0)
> print_pmu_events(NULL, raw_dump, !desc_flag,
> long_desc_flag, false);
What is this here?
> else if (strcmp(argv[i], "sdt") == 0)
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 101922b2a243..dc8eb30e8597 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1142,7 +1142,9 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
> if (event_glob != NULL &&
> !(strglobmatch_nocase(name, event_glob) ||
> (!is_cpu && strglobmatch_nocase(alias->name,
> - event_glob))))
> + event_glob)) ||
> + (alias->topic &&
> + strglobmatch_nocase(alias->topic, event_glob))))
> continue;
>
> if (is_cpu && !name_only && !alias->desc)
> --
> 2.5.5
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] perf, tools, list: Support matching by topic
2016-10-19 18:13 ` Arnaldo Carvalho de Melo
@ 2016-10-19 18:32 ` Andi Kleen
0 siblings, 0 replies; 6+ messages in thread
From: Andi Kleen @ 2016-10-19 18:32 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Andi Kleen, jolsa, linux-kernel, mingo, Andi Kleen
> > diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> > index 1095a6dada66..c00b0eb343c0 100644
> > --- a/tools/perf/builtin-list.c
> > +++ b/tools/perf/builtin-list.c
> > @@ -67,9 +67,11 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
> > print_symbol_events(NULL, PERF_TYPE_SOFTWARE,
> > event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
> > else if (strcmp(argv[i], "cache") == 0 ||
> > - strcmp(argv[i], "hwcache") == 0)
> > + strcmp(argv[i], "hwcache") == 0) {
>
> This is changing existing behaviour, please remove it. A separate patch
> could either make it show both hwcache events and vendor cache events,
That's what the patch does: "show both hwcache and vendor cache events"
which is a reasonable default.
I can split it into a separate patch if makes you feel better.
>
> > print_hwcache_events(NULL, raw_dump);
> > - else if (strcmp(argv[i], "pmu") == 0)
> > + print_pmu_events(argv[i], raw_dump, !desc_flag,
> > + long_desc_flag, true);
> > + } else if (strcmp(argv[i], "pmu") == 0)
> > print_pmu_events(NULL, raw_dump, !desc_flag,
> > long_desc_flag, false);
>
> What is this here?
Only adding a } but diff displays it in a weird way.
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] perf, tools, list: Make vendor event matching case insensitive
2016-10-19 17:50 [PATCH 1/2] perf, tools, list: Make vendor event matching case insensitive Andi Kleen
2016-10-19 17:50 ` [PATCH 2/2] perf, tools, list: Support matching by topic Andi Kleen
@ 2016-10-19 18:13 ` Arnaldo Carvalho de Melo
2016-10-24 19:07 ` [tip:perf/core] perf " tip-bot for Andi Kleen
2 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-19 18:13 UTC (permalink / raw)
To: Andi Kleen; +Cc: jolsa, linux-kernel, mingo, Andi Kleen
Em Wed, Oct 19, 2016 at 10:50:01AM -0700, Andi Kleen escreveu:
> From: Andi Kleen <ak@linux.intel.com>
>
> Make the perf list glob matching for vendor events case insensitive.
> This allows to use the upper case vendor events with perf list too.
>
> Now the following works:
>
> % perf list LONGEST_LAT
>
> ...
>
> cache:
> longest_lat_cache.miss
> [Core-originated cacheable demand requests missed LLC]
> longest_lat_cache.reference
> [Core-originated cacheable demand requests that refer to LLC]
Thanks, tested and applied.
- Arnaldo
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
> tools/perf/util/pmu.c | 4 ++--
> tools/perf/util/string.c | 21 ++++++++++++++++-----
> tools/perf/util/util.h | 1 +
> 3 files changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index d8d7d4c0319c..101922b2a243 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1140,8 +1140,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
> continue;
>
> if (event_glob != NULL &&
> - !(strglobmatch(name, event_glob) ||
> - (!is_cpu && strglobmatch(alias->name,
> + !(strglobmatch_nocase(name, event_glob) ||
> + (!is_cpu && strglobmatch_nocase(alias->name,
> event_glob))))
> continue;
>
> diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
> index 7f7e072be746..d8dfaf64b32e 100644
> --- a/tools/perf/util/string.c
> +++ b/tools/perf/util/string.c
> @@ -193,7 +193,8 @@ static bool __match_charclass(const char *pat, char c, const char **npat)
> }
>
> /* Glob/lazy pattern matching */
> -static bool __match_glob(const char *str, const char *pat, bool ignore_space)
> +static bool __match_glob(const char *str, const char *pat, bool ignore_space,
> + bool case_ins)
> {
> while (*str && *pat && *pat != '*') {
> if (ignore_space) {
> @@ -219,8 +220,13 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
> return false;
> else if (*pat == '\\') /* Escaped char match as normal char */
> pat++;
> - if (*str++ != *pat++)
> + if (case_ins) {
> + if (tolower(*str) != tolower(*pat))
> + return false;
> + } else if (*str != *pat)
> return false;
> + str++;
> + pat++;
> }
> /* Check wild card */
> if (*pat == '*') {
> @@ -229,7 +235,7 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
> if (!*pat) /* Tail wild card matches all */
> return true;
> while (*str)
> - if (__match_glob(str++, pat, ignore_space))
> + if (__match_glob(str++, pat, ignore_space, case_ins))
> return true;
> }
> return !*str && !*pat;
> @@ -249,7 +255,12 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
> */
> bool strglobmatch(const char *str, const char *pat)
> {
> - return __match_glob(str, pat, false);
> + return __match_glob(str, pat, false, false);
> +}
> +
> +bool strglobmatch_nocase(const char *str, const char *pat)
> +{
> + return __match_glob(str, pat, false, true);
> }
>
> /**
> @@ -262,7 +273,7 @@ bool strglobmatch(const char *str, const char *pat)
> */
> bool strlazymatch(const char *str, const char *pat)
> {
> - return __match_glob(str, pat, true);
> + return __match_glob(str, pat, true, false);
> }
>
> /**
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 43899e0d6fa1..71b6992f1d98 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -222,6 +222,7 @@ s64 perf_atoll(const char *str);
> char **argv_split(const char *str, int *argcp);
> void argv_free(char **argv);
> bool strglobmatch(const char *str, const char *pat);
> +bool strglobmatch_nocase(const char *str, const char *pat);
> bool strlazymatch(const char *str, const char *pat);
> static inline bool strisglob(const char *str)
> {
> --
> 2.5.5
^ permalink raw reply [flat|nested] 6+ messages in thread* [tip:perf/core] perf list: Make vendor event matching case insensitive
2016-10-19 17:50 [PATCH 1/2] perf, tools, list: Make vendor event matching case insensitive Andi Kleen
2016-10-19 17:50 ` [PATCH 2/2] perf, tools, list: Support matching by topic Andi Kleen
2016-10-19 18:13 ` [PATCH 1/2] perf, tools, list: Make vendor event matching case insensitive Arnaldo Carvalho de Melo
@ 2016-10-24 19:07 ` tip-bot for Andi Kleen
2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Andi Kleen @ 2016-10-24 19:07 UTC (permalink / raw)
To: linux-tip-commits; +Cc: acme, linux-kernel, hpa, tglx, mingo, ak, jolsa
Commit-ID: 38d14f0c58fd89d46efd1b783d6536380af28c03
Gitweb: http://git.kernel.org/tip/38d14f0c58fd89d46efd1b783d6536380af28c03
Author: Andi Kleen <ak@linux.intel.com>
AuthorDate: Wed, 19 Oct 2016 10:50:01 -0700
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 24 Oct 2016 11:07:46 -0300
perf list: Make vendor event matching case insensitive
Make the 'perf list' glob matching for vendor events case insensitive.
This allows to use the upper case vendor events with perf list too.
Now the following works:
% perf list LONGEST_LAT
...
cache:
longest_lat_cache.miss
[Core-originated cacheable demand requests missed LLC]
longest_lat_cache.reference
[Core-originated cacheable demand requests that refer to LLC]
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Suggested-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1476899402-31460-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/pmu.c | 4 ++--
tools/perf/util/string.c | 21 ++++++++++++++++-----
tools/perf/util/util.h | 1 +
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index d7174f3..31b845e 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1139,8 +1139,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
bool is_cpu = !strcmp(pmu->name, "cpu");
if (event_glob != NULL &&
- !(strglobmatch(name, event_glob) ||
- (!is_cpu && strglobmatch(alias->name,
+ !(strglobmatch_nocase(name, event_glob) ||
+ (!is_cpu && strglobmatch_nocase(alias->name,
event_glob))))
continue;
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index 7f7e072..d8dfaf6 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -193,7 +193,8 @@ error:
}
/* Glob/lazy pattern matching */
-static bool __match_glob(const char *str, const char *pat, bool ignore_space)
+static bool __match_glob(const char *str, const char *pat, bool ignore_space,
+ bool case_ins)
{
while (*str && *pat && *pat != '*') {
if (ignore_space) {
@@ -219,8 +220,13 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
return false;
else if (*pat == '\\') /* Escaped char match as normal char */
pat++;
- if (*str++ != *pat++)
+ if (case_ins) {
+ if (tolower(*str) != tolower(*pat))
+ return false;
+ } else if (*str != *pat)
return false;
+ str++;
+ pat++;
}
/* Check wild card */
if (*pat == '*') {
@@ -229,7 +235,7 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
if (!*pat) /* Tail wild card matches all */
return true;
while (*str)
- if (__match_glob(str++, pat, ignore_space))
+ if (__match_glob(str++, pat, ignore_space, case_ins))
return true;
}
return !*str && !*pat;
@@ -249,7 +255,12 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
*/
bool strglobmatch(const char *str, const char *pat)
{
- return __match_glob(str, pat, false);
+ return __match_glob(str, pat, false, false);
+}
+
+bool strglobmatch_nocase(const char *str, const char *pat)
+{
+ return __match_glob(str, pat, false, true);
}
/**
@@ -262,7 +273,7 @@ bool strglobmatch(const char *str, const char *pat)
*/
bool strlazymatch(const char *str, const char *pat)
{
- return __match_glob(str, pat, true);
+ return __match_glob(str, pat, true, false);
}
/**
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 43899e0..71b6992 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -222,6 +222,7 @@ s64 perf_atoll(const char *str);
char **argv_split(const char *str, int *argcp);
void argv_free(char **argv);
bool strglobmatch(const char *str, const char *pat);
+bool strglobmatch_nocase(const char *str, const char *pat);
bool strlazymatch(const char *str, const char *pat);
static inline bool strisglob(const char *str)
{
^ permalink raw reply related [flat|nested] 6+ messages in thread