From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Ian Rogers <irogers@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] perf metrics: Fix metric matching
Date: Mon, 26 Feb 2024 11:00:07 -0500 [thread overview]
Message-ID: <cf12ec88-0a15-4aa8-b6b8-948841d7d66d@linux.intel.com> (raw)
In-Reply-To: <20240224011420.3066322-1-irogers@google.com>
On 2024-02-23 8:14 p.m., Ian Rogers wrote:
> The metric match function fails for cases like looking for "metric" in
> the string "all;foo_metric;metric" as the "metric" in "foo_metric"
> matches but isn't preceeded by a ';'. Fix this by matching the first
> list item and recursively matching on failure the next item after a
> semicolon.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
For the series,
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Thanks,
Kan
> ---
> tools/perf/util/metricgroup.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index b24a1c177a80..2d6865c392ef 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -352,25 +352,23 @@ static int setup_metric_events(const char *pmu, struct hashmap *ids,
> return 0;
> }
>
> -static bool match_metric(const char *n, const char *list)
> +static bool match_metric(const char *metric_or_groups, const char *sought)
> {
> int len;
> char *m;
>
> - if (!list)
> + if (!sought)
> return false;
> - if (!strcmp(list, "all"))
> + if (!strcmp(sought, "all"))
> return true;
> - if (!n)
> - return !strcasecmp(list, "No_group");
> - len = strlen(list);
> - m = strcasestr(n, list);
> - if (!m)
> - return false;
> - if ((m == n || m[-1] == ';' || m[-1] == ' ') &&
> - (m[len] == 0 || m[len] == ';'))
> + if (!metric_or_groups)
> + return !strcasecmp(sought, "No_group");
> + len = strlen(sought);
> + if (!strncasecmp(metric_or_groups, sought, len) &&
> + (metric_or_groups[len] == 0 || metric_or_groups[len] == ';'))
> return true;
> - return false;
> + m = strchr(metric_or_groups, ';');
> + return m && match_metric(m + 1, sought);
> }
>
> static bool match_pm_metric(const struct pmu_metric *pm, const char *pmu, const char *metric)
next prev parent reply other threads:[~2024-02-26 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-24 1:14 [PATCH v1 1/2] perf metrics: Fix metric matching Ian Rogers
2024-02-24 1:14 ` [PATCH v1 2/2] perf metrics: Fix segv for metrics with no events Ian Rogers
2024-02-26 16:00 ` Liang, Kan [this message]
2024-03-01 19:29 ` [PATCH v1 1/2] perf metrics: Fix metric matching Namhyung Kim
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=cf12ec88-0a15-4aa8-b6b8-948841d7d66d@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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).