[PATCH 1/2] perf tools: ARM SPE code cleanup

Leo Yan leo.yan at linaro.org
Sun Jul 5 01:05:27 EDT 2020


Hi Wei,

On Tue, Jun 23, 2020 at 08:31:40PM +0800, Wei Li wrote:
> Remove the useless check code to make it clear.
> 
> Signed-off-by: Wei Li <liwei391 at huawei.com>
> ---
>  tools/perf/arch/arm/util/auxtrace.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/arch/arm/util/auxtrace.c b/tools/perf/arch/arm/util/auxtrace.c
> index 0a6e75b8777a..62b7b03d691a 100644
> --- a/tools/perf/arch/arm/util/auxtrace.c
> +++ b/tools/perf/arch/arm/util/auxtrace.c
> @@ -57,7 +57,7 @@ struct auxtrace_record
>  	struct evsel *evsel;
>  	bool found_etm = false;
>  	bool found_spe = false;
> -	static struct perf_pmu **arm_spe_pmus = NULL;
> +	static struct perf_pmu **arm_spe_pmus;

Here the 'static' should be removed as well.

Just for more complete background info, IIUC, at the beginning to
enable SPE's PMU event, since SPE is micro-architecture dependent
(though it's defined in ARMv8-ARM, but it might be different for
different ARM micro-architectures).  So this is why here it uses
'static' for varaible "arm_spe_pmus", it wants to initialize the
variable with finding all SPE PMU structure at the first time when
invoke the function auxtrace_record__init(), and afterwards we can
reuse the variable "arm_spe_pmus" and without calling
find_all_arm_spe_pmus() anymore.

So I struggled to figure out what's good thing to do with multiple SPE
PMU events, and your change is good thing to me.  The reason is:

- Firstly, the function auxtrace_record__init() will be invoked only
  once, the variable "arm_spe_pmus" will not be used afterwards, thus
  we don't need to check "arm_spe_pmus" is NULL or not;
- Another reason is, even though SPE is micro-architecture dependent,
  but so far it only supports "statistical-profiling-extension-v1" and
  we have no chance to use multiple SPE's PMU events in Perf command.


So after removing 'static' for varaible "arm_spe_pmus":
Reviewed-by: Leo Yan <leo.yan at linaro.org>


P.s. Sorry if it's my reason that James Clark's patch [1] has not been
merged in the mainline kernel and introduced duplicate efforts at here.
James's patch used similiar method to resolve this same issue.

[1] https://lkml.org/lkml/2019/12/20/293

>  	static int nr_spes = 0;
>  	int i = 0;
>  
> @@ -65,9 +65,7 @@ struct auxtrace_record
>  		return NULL;
>  
>  	cs_etm_pmu = perf_pmu__find(CORESIGHT_ETM_PMU_NAME);
> -
> -	if (!arm_spe_pmus)
> -		arm_spe_pmus = find_all_arm_spe_pmus(&nr_spes, err);
> +	arm_spe_pmus = find_all_arm_spe_pmus(&nr_spes, err);
>  
>  	evlist__for_each_entry(evlist, evsel) {
>  		if (cs_etm_pmu &&
> -- 
> 2.17.1
> 



More information about the linux-arm-kernel mailing list