Commit 38d14f0c authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo

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: default avatarAndi Kleen <ak@linux.intel.com>
Suggested-by: default avatarIngo Molnar <mingo@kernel.org>
Tested-by: default avatarArnaldo 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ecf1e225
...@@ -1139,8 +1139,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, ...@@ -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"); bool is_cpu = !strcmp(pmu->name, "cpu");
if (event_glob != NULL && if (event_glob != NULL &&
!(strglobmatch(name, event_glob) || !(strglobmatch_nocase(name, event_glob) ||
(!is_cpu && strglobmatch(alias->name, (!is_cpu && strglobmatch_nocase(alias->name,
event_glob)))) event_glob))))
continue; continue;
......
...@@ -193,7 +193,8 @@ static bool __match_charclass(const char *pat, char c, const char **npat) ...@@ -193,7 +193,8 @@ static bool __match_charclass(const char *pat, char c, const char **npat)
} }
/* Glob/lazy pattern matching */ /* 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 != '*') { while (*str && *pat && *pat != '*') {
if (ignore_space) { if (ignore_space) {
...@@ -219,8 +220,13 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space) ...@@ -219,8 +220,13 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
return false; return false;
else if (*pat == '\\') /* Escaped char match as normal char */ else if (*pat == '\\') /* Escaped char match as normal char */
pat++; pat++;
if (*str++ != *pat++) if (case_ins) {
if (tolower(*str) != tolower(*pat))
return false;
} else if (*str != *pat)
return false; return false;
str++;
pat++;
} }
/* Check wild card */ /* Check wild card */
if (*pat == '*') { if (*pat == '*') {
...@@ -229,7 +235,7 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space) ...@@ -229,7 +235,7 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
if (!*pat) /* Tail wild card matches all */ if (!*pat) /* Tail wild card matches all */
return true; return true;
while (*str) while (*str)
if (__match_glob(str++, pat, ignore_space)) if (__match_glob(str++, pat, ignore_space, case_ins))
return true; return true;
} }
return !*str && !*pat; return !*str && !*pat;
...@@ -249,7 +255,12 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space) ...@@ -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) 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) ...@@ -262,7 +273,7 @@ bool strglobmatch(const char *str, const char *pat)
*/ */
bool strlazymatch(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);
} }
/** /**
......
...@@ -222,6 +222,7 @@ s64 perf_atoll(const char *str); ...@@ -222,6 +222,7 @@ s64 perf_atoll(const char *str);
char **argv_split(const char *str, int *argcp); char **argv_split(const char *str, int *argcp);
void argv_free(char **argv); void argv_free(char **argv);
bool strglobmatch(const char *str, const char *pat); 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); bool strlazymatch(const char *str, const char *pat);
static inline bool strisglob(const char *str) static inline bool strisglob(const char *str)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment