perf, tools, list: Make vendor event matching case insensitive
PATCH 1/3 perf, tools, list: Make vendor event matching case insensitive
From: Andi Kleen <[email protected]>
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]
--- 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(-)
tools/perf/util/pmu.c +2 -2
@@ -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 ;
tools/perf/util/string.c +16 -5
@@ -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); }/**
tools/perf/util/util.h +1 -0
@@ -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) {
Signature · 1 line
2.5.5
PATCH 2/3 perf, tools, list: Support matching by topic
From: Andi Kleen <[email protected]>
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]
...
--- tools/perf/util/pmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/pmu.c +3 -1
@@ -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)
Signature · 1 line
2.5.5
tip-bot for Andi Kleen
merge bot[tip:perf/core] perf list: Support matching by topic
perf list: Support matching by topic
Commit-ID: 67bdc35fb48c97502dd4b9eeac561e4bcc18684b Gitweb: http://git.kernel.org/tip/67bdc35fb48c97502dd4b9eeac561e4bcc18684b Author: Andi Kleen <[email protected]> AuthorDate: Wed, 19 Oct 2016 11:45:23 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 28 Oct 2016 11:29:42 -0200
perf list: Support matching by topic
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]
...
--- tools/perf/util/pmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/pmu.c +3 -1
@@ -1141,7 +1141,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)
PATCH 3/3 perf, tools, list: Support perf list cache for topics
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
"Cache" is a common topic name for vendor lists. But it couldn't be matched with perf list cache, because that already prints only the existing perf cache events.
Simply print the vendor cache events too in this case.
--- tools/perf/builtin-list.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-list.c +4 -2
@@ -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)
Signature · 1 line
2.5.5