[PATCH v1 07/40] perf stat: Avoid segv on counter->name

Ian Rogers posted 40 patches 2 years, 7 months ago
There is a newer version of this series
[PATCH v1 07/40] perf stat: Avoid segv on counter->name
Posted by Ian Rogers 2 years, 7 months ago
Switch to use evsel__name that doesn't return NULL for hardware and
similar events.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/stat-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index 6b46bbb3d322..71dd6cb83918 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -747,7 +747,7 @@ static void uniquify_event_name(struct evsel *counter)
 	int ret = 0;
 
 	if (counter->uniquified_name || counter->use_config_name ||
-	    !counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
+	    !counter->pmu_name || !strncmp(evsel__name(counter), counter->pmu_name,
 					   strlen(counter->pmu_name)))
 		return;
 
-- 
2.40.1.495.gc816e09b53d-goog
Re: [PATCH v1 07/40] perf stat: Avoid segv on counter->name
Posted by Liang, Kan 2 years, 7 months ago

On 2023-04-26 3:00 a.m., Ian Rogers wrote:
> Switch to use evsel__name that doesn't return NULL for hardware and
> similar events.

This one should be backport to 6.4. It helps to fix the Segmentation
fault with default mode.
https://lore.kernel.org/lkml/2b8768bf-de24-946f-62da-6ed171a5c324@linux.intel.com/


> Signed-off-by: Ian Rogers <irogers@google.com>

Reviewed-by: Kan Liang <kan.liang@linux.intel.com>

Thanks,
Kan

> ---
>  tools/perf/util/stat-display.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 6b46bbb3d322..71dd6cb83918 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -747,7 +747,7 @@ static void uniquify_event_name(struct evsel *counter)
>  	int ret = 0;
>  
>  	if (counter->uniquified_name || counter->use_config_name ||
> -	    !counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
> +	    !counter->pmu_name || !strncmp(evsel__name(counter), counter->pmu_name,
>  					   strlen(counter->pmu_name)))
>  		return;
>
Re: [PATCH v1 07/40] perf stat: Avoid segv on counter->name
Posted by Arnaldo Carvalho de Melo 2 years, 7 months ago
Em Thu, Apr 27, 2023 at 03:11:49PM -0400, Liang, Kan escreveu:
> On 2023-04-26 3:00 a.m., Ian Rogers wrote:
> > Switch to use evsel__name that doesn't return NULL for hardware and
> > similar events.
 
> This one should be backport to 6.4. It helps to fix the Segmentation
> fault with default mode.
> https://lore.kernel.org/lkml/2b8768bf-de24-946f-62da-6ed171a5c324@linux.intel.com/
 
> > Signed-off-by: Ian Rogers <irogers@google.com>
 
> Reviewed-by: Kan Liang <kan.liang@linux.intel.com>

Thanks,

I'll pick those before pushing to Linus, I'm mostly waiting for you guys
to come to a resolution on moving forward, which I hope has been reached
with that patch you sent.

- Arnaldo