Skip to contentSkip to conversation

perf/core: declare the percpu variable properly

PATCH In review Mukesh Ojha 2 participants 3 messages Nov 27, 2018 – Dec 11, 2018 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/core: declare the percpu variable properly

Sparse reports the current declaration of percpu variable with below warning

warning: incorrect type in initializer (different address spaces)
expected void const [noderef] <asn:3>*__vpp_verify got struct perf_cpu_context *<noident>

Fix it by declaring it properly.

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 include/linux/perf_event.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/perf_event.h +2 -2
index 53c500f..1d5c551 100644
@@ -262,8 +262,8 @@ struct pmu {
 	 */
 	int				capabilities;
 
-	int * __percpu			pmu_disable_count;
-	struct perf_cpu_context * __percpu pmu_cpu_context;
+	int __percpu			*pmu_disable_count;
+	struct perf_cpu_context __percpu *pmu_cpu_context;
 	atomic_t			exclusive_cnt; /* < 0: cpu; > 0: tsk */
 	int				task_ctx_nr;
 	int				hrtimer_interval_ms;
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
#1 lore raw

Hi All,

Can you please review the change ?

Thanks,
Mukesh

Quoted 35 lines · Mukesh Ojha

Sparse reports the current declaration of percpu variable with below warning

warning: incorrect type in initializer (different address spaces)
expected void const [noderef] <asn:3>*__vpp_verify got struct perf_cpu_context *<noident>

Fix it by declaring it properly.

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
---
  include/linux/perf_event.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/perf_event.h +2 -2
index 53c500f..1d5c551 100644
@@ -262,8 +262,8 @@ struct pmu {
  	 */
  	int				capabilities;
 
-	int * __percpu			pmu_disable_count;
-	struct perf_cpu_context * __percpu pmu_cpu_context;
+	int __percpu			*pmu_disable_count;
+	struct perf_cpu_context __percpu *pmu_cpu_context;
  	atomic_t			exclusive_cnt; /* < 0: cpu; > 0: tsk */
  	int				task_ctx_nr;
  	int				hrtimer_interval_ms;
#2 lore raw

[tip:perf/core] perf/core: Declare the __percpu attribute on non-deref types

In reply to Mukesh Ojha
perf/core: Declare the __percpu attribute on non-deref types
Commit-ID:  43b9e4febc66b98d83cc1560196d56ac7fef3c32
Gitweb:     https://git.kernel.org/tip/43b9e4febc66b98d83cc1560196d56ac7fef3c32
Author:     Mukesh Ojha <[email protected]>
AuthorDate: Tue, 27 Nov 2018 14:43:32 +0530
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 11 Dec 2018 15:01:48 +0100

perf/core: Declare the __percpu attribute on non-deref types

Sparse reports the current declaration of two perf percpu variables with this warning:

warning: incorrect type in initializer (different address spaces)
expected void const [noderef] <asn:3>*__vpp_verify got struct perf_cpu_context *<noident>

While it's normally perfectly fine to place GCC attributes anywhere in the definition, this particular attribute is for a checking compiler's such as Sparse's benefit, which doesn't want __percpu on pointers.

So reorder the attribute to come after the structure type, not after the pointer type.

[ mingo: Rewrote the changelog. ]

---
 include/linux/perf_event.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/perf_event.h +2 -2
index 53c500f0ca79..1d5c551a5add 100644
@@ -262,8 +262,8 @@ struct pmu {
 	 */
 	int				capabilities;
 
-	int * __percpu			pmu_disable_count;
-	struct perf_cpu_context * __percpu pmu_cpu_context;
+	int __percpu			*pmu_disable_count;
+	struct perf_cpu_context __percpu *pmu_cpu_context;
 	atomic_t			exclusive_cnt; /* < 0: cpu; > 0: tsk */
 	int				task_ctx_nr;
 	int				hrtimer_interval_ms;