LKML Archive on
help / color / mirror / Atom feed
From: Stephane Eranian <>
Subject: [PATCH] perf/rapl: fix crash in rapl_scale()
Date: Thu, 22 Jan 2015 21:38:34 +0100	[thread overview]
Message-ID: <20150122203834.GA10228@thinkpad> (raw)

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 <>
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

Reported-by: Vince Weaver <>
Signed-off-by: Stephane Eranian <>
Tested-by: Vince Weaver <>

diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
index 6e434f8..c4bb8b8 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
@@ -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)

             reply	other threads:[~2015-01-22 20:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-22 20:38 Stephane Eranian [this message]
2015-01-23  8:39 ` Peter Zijlstra
2015-01-28 14:29 ` [tip:perf/urgent] perf/rapl: Fix " tip-bot for Stephane Eranian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150122203834.GA10228@thinkpad \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] perf/rapl: fix crash in rapl_scale()' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).