* [PATCH v1] perf metrics: Avoid segv with --topdown
@ 2023-05-15 22:45 Ian Rogers
2023-05-16 17:14 ` Liang, Kan
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2023-05-15 22:45 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter, Kajol Jain, linux-perf-users,
linux-kernel, Kan Liang
Some metrics may not have a metric_group which can result in segvs
with "perf stat --topdown". Add a condition for the no metric_group
case.
Fixes: 1647cd5b8802 ("perf stat: Implement --topdown using json metrics")
Reported-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/metricgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 4e7d41d285b4..5e9c657dd3f7 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -1672,7 +1672,7 @@ static int metricgroup__topdown_max_level_callback(const struct pmu_metric *pm,
{
unsigned int *max_level = data;
unsigned int level;
- const char *p = strstr(pm->metric_group, "TopdownL");
+ const char *p = strstr(pm->metric_group ?: "", "TopdownL");
if (!p || p[8] == '\0')
return 0;
--
2.40.1.606.ga4b1b128d6-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] perf metrics: Avoid segv with --topdown
2023-05-15 22:45 [PATCH v1] perf metrics: Avoid segv with --topdown Ian Rogers
@ 2023-05-16 17:14 ` Liang, Kan
0 siblings, 0 replies; 2+ messages in thread
From: Liang, Kan @ 2023-05-16 17:14 UTC (permalink / raw)
To: Ian Rogers, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Adrian Hunter, Kajol Jain, linux-perf-users, linux-kernel
On 2023-05-15 6:45 p.m., Ian Rogers wrote:
> Some metrics may not have a metric_group which can result in segvs
> with "perf stat --topdown". Add a condition for the no metric_group
> case.
>
> Fixes: 1647cd5b8802 ("perf stat: Implement --topdown using json metrics")
> Reported-by: Kan Liang <kan.liang@linux.intel.com>
> Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Thanks,
Kan
> ---
> tools/perf/util/metricgroup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 4e7d41d285b4..5e9c657dd3f7 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -1672,7 +1672,7 @@ static int metricgroup__topdown_max_level_callback(const struct pmu_metric *pm,
> {
> unsigned int *max_level = data;
> unsigned int level;
> - const char *p = strstr(pm->metric_group, "TopdownL");
> + const char *p = strstr(pm->metric_group ?: "", "TopdownL");
>
> if (!p || p[8] == '\0')
> return 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-16 17:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 22:45 [PATCH v1] perf metrics: Avoid segv with --topdown Ian Rogers
2023-05-16 17:14 ` Liang, Kan
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).