Skip to contentSkip to conversation

perf/x86/intel: Don't accidentally clear high bits in bdw_limit_period()

PATCH In review Dan Carpenter 3 participants 3 messages Mar 17, 2018 – Mar 20, 2018

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

PATCH 1/1 perf/x86/intel: Don't accidentally clear high bits in bdw_limit_period()

We intended to clear the lowest 6 bits but because of a type bug we clear the high 32 bits as well. Andi says that periods are rarely more than U32_MAX so this bug probably doesn't have a huge runtime impact.

Fixes 294fe0f52a44 ("perf/x86/intel: Add INST_RETIRED.ALL workarounds")
arch/x86/events/intel/core.c +1 -1
index 41c68d337e84..f23f52b9de8e 100644
@@ -3210,7 +3210,7 @@ static u64 bdw_limit_period(struct perf_event *event, u64 left)
 			X86_CONFIG(.event=0xc0, .umask=0x01)) {
 		if (left < 128)
 			left = 128;
-		left &= ~0x3fu;
+		left &= ~0x3fULL;
 	}
 	return left;
 }
maintainer
#1 lore raw
Quoted 3 lines · Dan Carpenter

We intended to clear the lowest 6 bits but because of a type bug we clear the high 32 bits as well. Andi says that periods are rarely more than U32_MAX so this bug probably doesn't have a huge runtime impact.

Thanks Dan!

#2 lore raw
In reply to Dan Carpenter
perf/x86/intel: Don't accidentally clear high bits in bdw_limit_period()
Commit-ID:  e5ea9b54a055619160bbfe527ebb7d7191823d66
Gitweb:     https://git.kernel.org/tip/e5ea9b54a055619160bbfe527ebb7d7191823d66
Author:     Dan Carpenter <[email protected]>
AuthorDate: Sat, 17 Mar 2018 14:52:16 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 20 Mar 2018 08:53:31 +0100

perf/x86/intel: Don't accidentally clear high bits in bdw_limit_period()

We intended to clear the lowest 6 bits but because of a type bug we clear the high 32 bits as well. Andi says that periods are rarely more than U32_MAX so this bug probably doesn't have a huge runtime impact.

Cc Alexander Shishkin <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vince Weaver <[email protected]>
Fixes 294fe0f52a44 ("perf/x86/intel: Add INST_RETIRED.ALL workarounds")
---
 arch/x86/events/intel/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/core.c +1 -1
index 56457cb73448..9b18a227fff7 100644
@@ -3194,7 +3194,7 @@ static unsigned bdw_limit_period(struct perf_event *event, unsigned left)
 			X86_CONFIG(.event=0xc0, .umask=0x01)) {
 		if (left < 128)
 			left = 128;
-		left &= ~0x3fu;
+		left &= ~0x3fULL;
 	}
 	return left;
 }