perf/rapl: Fix sysfs_show() initialization for RAPL PMU
authorStephane Eranian <[email protected]>
Tue, 13 Jan 2015 22:59:53 +0000 (23:59 +0100)
committerIngo Molnar <[email protected]>
Fri, 16 Jan 2015 08:06:58 +0000 (09:06 +0100)
commit433678bdc6ed39f053c55da96b51de5bf0aeebb1
tree4f8d1cb9a64d8d4f6b8836099c40d666553ba592
parentf800c25b7a762d445ba1439a2428c8362157eba6
perf/rapl: Fix sysfs_show() initialization for RAPL PMU

This patch fixes a problem with the initialization of the
sysfs_show() routine for the RAPL PMU.

The current code was wrongly relying on the EVENT_ATTR_STR()
macro which uses the events_sysfs_show() function in the x86
PMU code. That function itself was relying on the x86_pmu data
structure. Yet RAPL and the core PMU (x86_pmu) have nothing to
do with each other. They should therefore not interact with
each other.

The x86_pmu structure is initialized at boot time based on
the host CPU model. When the host CPU is not supported, the
x86_pmu remains uninitialized and some of the callbacks it
contains are NULL.

The false dependency with x86_pmu could potentially cause crashes
in case the x86_pmu is not initialized while the RAPL PMU is. This
may, for instance, be the case in virtualized environments.

This patch fixes the problem by using a private sysfs_show()
routine for exporting the RAPL PMU events.

Signed-off-by: Stephane Eranian <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: http://lkml.kernel.org/r/20150113225953.GA21525@thinkpad
Cc: [email protected]
Cc: [email protected]
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Linus Torvalds <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/kernel/cpu/perf_event_intel_rapl.c