linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org, mingo@kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH 1/2] perf, tools, list: Make vendor event matching case insensitive
Date: Wed, 19 Oct 2016 15:13:29 -0300	[thread overview]
Message-ID: <20161019181329.GI25522@kernel.org> (raw)
In-Reply-To: <1476899402-31460-1-git-send-email-andi@firstfloor.org>

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

  parent reply	other threads:[~2016-10-19 18:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-19 18:32     ` Andi Kleen
2016-10-19 18:13 ` Arnaldo Carvalho de Melo [this message]
2016-10-24 19:07 ` [tip:perf/core] perf list: Make vendor event matching case insensitive tip-bot for Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161019181329.GI25522@kernel.org \
    --to=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).