Skip to contentSkip to conversation

perf/x86/intel: Make cpuc allocations consistent

PATCH Guenter Roeck 3 participants 3 messages Mar 14, 2019 – Mar 15, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

Quoted 5 lines · Peter Zijlstra (Intel)

The cpuc data structure allocation is different between fake and real cpuc's; use the same code to init/free both.

With allmodconfig-CONFIG_CPU_SUP_INTEL, this patch results in:

In file included from arch/x86/events/amd/core.c:8:0:
arch/x86/events/amd/../perf_event.h:1036:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration
static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu)

                                             ^~~~~~~~~~~~
arch/x86/events/amd/../perf_event.h:1041:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration
 static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc)
                                             ^~~~~~~~~~~~

With -Werror, this is fatal, and I think it may be buggy (should it be cpu_hw_events) ?

The patch has been applied to stable releases. Any idea, anyone, why this is the case ? It doesn't look like a bug fix to me, and reverting it from v4.14.106 didn't seem to have a negative impact.

Guenter

maintainer
#1 lore raw
Quoted 12 lines · Guenter Roeck
Quoted 5 lines · Peter Zijlstra (Intel)

The cpuc data structure allocation is different between fake and real cpuc's; use the same code to init/free both.

With allmodconfig-CONFIG_CPU_SUP_INTEL, this patch results in:

In file included from arch/x86/events/amd/core.c:8:0:
arch/x86/events/amd/../perf_event.h:1036:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration
static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu)

Quoted 7 lines
                                             ^~~~~~~~~~~~
arch/x86/events/amd/../perf_event.h:1041:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration
 static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc)
                                             ^~~~~~~~~~~~

With -Werror, this is fatal, and I think it may be buggy (should it be cpu_hw_events) ?

Yep it should be. Won't result in a bug though, an unused pointer is an unused poiner, no matter what known or unknown type it points to.

Quoted 3 lines

The patch has been applied to stable releases. Any idea, anyone, why this is the case ? It doesn't look like a bug fix to me, and reverting it from v4.14.106 didn't seem to have a negative impact.

Reverting just this one patch will make your kernel go boom when you run on a skylake or more recent Intel cpu, have updated your microcode and do:

echo 0 > /sys/bus/event_source/devices/cpu/allow_tsx_force_abort

And then try and create perf events. See also commit:

400816f60c54 ("perf/x86/intel: Implement support for TSX Force Abort")

---
Subject: perf/x86: Fixup typo in stub functions

Guenter reported a build warning for CONFIG_CPU_SUP_INTEL=n. While harmless (an unsed pointer is an unused pointer, no matter the type) it needs fixing.

Fixes d01b1f96a82e ("perf/x86/intel: Make cpuc allocations consistent")
---
 arch/x86/events/perf_event.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/events/perf_event.h +2 -2
index b04ae6c8775e..a75955741c50 100644
@@ -1033,12 +1033,12 @@ static inline int intel_pmu_init(void)
 	return 0;
 }
 
-static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu)
+static inline int intel_cpuc_prepare(struct cpu_hw_events *cpuc, int cpu)
 {
 	return 0;
 }
 
-static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc)
+static inline void intel_cpuc_finish(struct cpu_hw_events *cpuc)
 {
 }
 
#2 lore raw

[tip:perf/urgent] perf/x86: Fixup typo in stub functions

perf/x86: Fixup typo in stub functions
Commit-ID:  f764c58b7faa26f5714e6907f892abc2bc0de4f8
Gitweb:     https://git.kernel.org/tip/f764c58b7faa26f5714e6907f892abc2bc0de4f8
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Fri, 15 Mar 2019 09:14:10 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 15 Mar 2019 13:12:42 +0100

perf/x86: Fixup typo in stub functions

Guenter reported a build warning for CONFIG_CPU_SUP_INTEL=n:

Quoted 5 lines

With allmodconfig-CONFIG_CPU_SUP_INTEL, this patch results in:

In file included from arch/x86/events/amd/core.c:8:0:
arch/x86/events/amd/../perf_event.h:1036:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration
static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu)

While harmless (an unsed pointer is an unused pointer, no matter the type) it needs fixing.

Cc Greg Kroah-Hartman <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Fixes d01b1f96a82e ("perf/x86/intel: Make cpuc allocations consistent")
---
 arch/x86/events/perf_event.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/events/perf_event.h +2 -2
index b04ae6c8775e..a75955741c50 100644
@@ -1033,12 +1033,12 @@ static inline int intel_pmu_init(void)
 	return 0;
 }
 
-static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu)
+static inline int intel_cpuc_prepare(struct cpu_hw_events *cpuc, int cpu)
 {
 	return 0;
 }
 
-static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc)
+static inline void intel_cpuc_finish(struct cpu_hw_events *cpuc)
 {
 }