diff options
author | Peter Zijlstra <peterz@infradead.org> | 2016-09-07 08:42:55 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-09-10 05:15:39 -0400 |
commit | 8ef9b8455a2a3049efa9e46e8a6402b972a3eb41 (patch) | |
tree | bd285322b8602641ffed3ccaa84036f46a90e032 | |
parent | ef9ef3befa0d76008e988a9ed9fe439e803351b9 (diff) |
perf/x86/intel: Fix PEBSv3 record drain
Alexander hit the WARN_ON_ONCE(!event) on his Skylake while running
the perf fuzzer.
This means the PEBSv3 record included a status bit for an inactive
event, something that _should_ not happen.
Move the code that filters the status bits against our known PEBS
events up a spot to guarantee we only deal with events we know about.
Further add "continue" statements to the WARN_ON_ONCE()s such that
we'll not die nor generate silly events in case we ever do hit them
again.
Reported-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vince@deater.net>
Cc: stable@vger.kernel.org
Fixes: a3d86542de88 ("perf/x86/intel/pebs: Add PEBSv3 decoding")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/events/intel/ds.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 7ce9f3f669e6..9b983a474253 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c | |||
@@ -1274,18 +1274,18 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) | |||
1274 | struct pebs_record_nhm *p = at; | 1274 | struct pebs_record_nhm *p = at; |
1275 | u64 pebs_status; | 1275 | u64 pebs_status; |
1276 | 1276 | ||
1277 | /* PEBS v3 has accurate status bits */ | 1277 | pebs_status = p->status & cpuc->pebs_enabled; |
1278 | pebs_status &= (1ULL << x86_pmu.max_pebs_events) - 1; | ||
1279 | |||
1280 | /* PEBS v3 has more accurate status bits */ | ||
1278 | if (x86_pmu.intel_cap.pebs_format >= 3) { | 1281 | if (x86_pmu.intel_cap.pebs_format >= 3) { |
1279 | for_each_set_bit(bit, (unsigned long *)&p->status, | 1282 | for_each_set_bit(bit, (unsigned long *)&pebs_status, |
1280 | MAX_PEBS_EVENTS) | 1283 | x86_pmu.max_pebs_events) |
1281 | counts[bit]++; | 1284 | counts[bit]++; |
1282 | 1285 | ||
1283 | continue; | 1286 | continue; |
1284 | } | 1287 | } |
1285 | 1288 | ||
1286 | pebs_status = p->status & cpuc->pebs_enabled; | ||
1287 | pebs_status &= (1ULL << x86_pmu.max_pebs_events) - 1; | ||
1288 | |||
1289 | /* | 1289 | /* |
1290 | * On some CPUs the PEBS status can be zero when PEBS is | 1290 | * On some CPUs the PEBS status can be zero when PEBS is |
1291 | * racing with clearing of GLOBAL_STATUS. | 1291 | * racing with clearing of GLOBAL_STATUS. |
@@ -1333,8 +1333,11 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) | |||
1333 | continue; | 1333 | continue; |
1334 | 1334 | ||
1335 | event = cpuc->events[bit]; | 1335 | event = cpuc->events[bit]; |
1336 | WARN_ON_ONCE(!event); | 1336 | if (WARN_ON_ONCE(!event)) |
1337 | WARN_ON_ONCE(!event->attr.precise_ip); | 1337 | continue; |
1338 | |||
1339 | if (WARN_ON_ONCE(!event->attr.precise_ip)) | ||
1340 | continue; | ||
1338 | 1341 | ||
1339 | /* log dropped samples number */ | 1342 | /* log dropped samples number */ |
1340 | if (error[bit]) | 1343 | if (error[bit]) |