]> git.itanic.dy.fi Git - linux-stable/commit
perf/rapl: Fix sysfs_show() initialization for RAPL PMU
authorStephane Eranian <eranian@google.com>
Tue, 13 Jan 2015 22:59:53 +0000 (23:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 10 Nov 2018 15:39:16 +0000 (07:39 -0800)
commit34215ab7b93379221ad4fd359d13a330afef5147
tree1af0ca9d05062540fb218e57a13f54be854a5239
parentac6e3ff93519eb4f76f2566fa9df4c1c04954f1e
perf/rapl: Fix sysfs_show() initialization for RAPL PMU

[ Upstream commit 433678bdc6ed39f053c55da96b51de5bf0aeebb1 ]

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 <eranian@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150113225953.GA21525@thinkpad
Cc: vincent.weaver@maine.edu
Cc: jolsa@redhat.com
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/cpu/perf_event_intel_rapl.c