Skip to contentSkip to conversation

perf/rapl: fix crash in rapl_scale()

PATCH In review Stephane Eranian 3 participants 3 messages Jan 22, 2015 – Jan 28, 2015

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

PATCH 1/1 perf/rapl: fix crash in rapl_scale()

This patch fixes a systematic crash in rapl_scale() due to an invalid pointer.

The bug was introduced by commit:
commit 89cbc76768c2fa4ed95545bf961f3a14ddfeed21

Author: Christoph Lameter <[email protected]>
Date:   Sun Aug 17 12:30:40 2014 -0500

x86: Replace __get_cpu_var uses

The fix is simple. Just put the parenthesis where it needs to be, i.e., around rapl_pmu. To my surprise, the compiler was not complaining about passing an integer instead of a pointer.

--

arch/x86/kernel/cpu/perf_event_intel_rapl.c +1 -1
index 6e434f8..c4bb8b8 100644
@@ -142,7 +142,7 @@ static inline u64 rapl_scale(u64 v)
 	 * or use ldexp(count, -32).
 	 * Watts = Joules/Time delta
 	 */
-	return v << (32 - __this_cpu_read(rapl_pmu->hw_unit));
+	return v << (32 - __this_cpu_read(rapl_pmu)->hw_unit);
 }
 
 static u64 rapl_event_update(struct perf_event *event)
maintainer
#1 lore raw
Quoted 12 lines · Stephane Eranian

This patch fixes a systematic crash in rapl_scale() due to an invalid pointer.

The bug was introduced by commit:
commit 89cbc76768c2fa4ed95545bf961f3a14ddfeed21

Author: Christoph Lameter <[email protected]>
Date:   Sun Aug 17 12:30:40 2014 -0500

x86: Replace __get_cpu_var uses

Quoted 8 lines

The fix is simple. Just put the parenthesis where it needs to be, i.e., around rapl_pmu. To my surprise, the compiler was not complaining about passing an integer instead of a pointer.

Thanks!

#2 lore raw

[tip:perf/urgent] perf/rapl: Fix crash in rapl_scale()

In reply to Stephane Eranian
perf/rapl: Fix crash in rapl_scale()
Commit-ID:  98b008dff8452653909d9263efda925873e8d8bb
Gitweb:     http://git.kernel.org/tip/98b008dff8452653909d9263efda925873e8d8bb
Author:     Stephane Eranian <[email protected]>
AuthorDate: Thu, 22 Jan 2015 21:38:34 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 28 Jan 2015 13:04:35 +0100

perf/rapl: Fix crash in rapl_scale()

This patch fixes a systematic crash in rapl_scale() due to an invalid pointer.

The bug was introduced by commit:

89cbc76768c2 ("x86: Replace __get_cpu_var uses")

The fix is simple. Just put the parenthesis where it needs to be, i.e., around rapl_pmu. To my surprise, the compiler was not complaining about passing an integer instead of a pointer.

---
 arch/x86/kernel/cpu/perf_event_intel_rapl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel_rapl.c +1 -1
index 6e434f8..c4bb8b8 100644
@@ -142,7 +142,7 @@ static inline u64 rapl_scale(u64 v)
 	 * or use ldexp(count, -32).
 	 * Watts = Joules/Time delta
 	 */
-	return v << (32 - __this_cpu_read(rapl_pmu->hw_unit));
+	return v << (32 - __this_cpu_read(rapl_pmu)->hw_unit);
 }
 
 static u64 rapl_event_update(struct perf_event *event)