Skip to contentSkip to conversation

x86, perf: Remove warning for zero PEBS status

PATCH In review Andi Kleen 3 participants 6 messages Dec 3, 2015 – Jan 6, 2016

Subsystems (2)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/2 x86, perf: Remove warning for zero PEBS status

From: Andi Kleen <[email protected]>

The recent change 75f80859b1 (... Robustify PEBS buffer drain) causes lots of warnings on different CPUs before Skylake when running PEBS intensive workloads.

They can have a zero status field in the PEBS record when PEBS is racing with clearing of GLOBAl_STATUS.

This also can cause hangs (it seems there are still problems with printk in NMI)

Disable the warning, but still ignore the record.

---
 arch/x86/kernel/cpu/perf_event_intel_ds.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/cpu/perf_event_intel_ds.c +1 -4
index 7f11784..da294de 100644
@@ -1237,10 +1237,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
 
 		bit = find_first_bit((unsigned long *)&pebs_status,
 					x86_pmu.max_pebs_events);
-		if (WARN(bit >= x86_pmu.max_pebs_events,
-			 "PEBS record without PEBS event! status=%Lx pebs_enabled=%Lx active_mask=%Lx",
-			 (unsigned long long)p->status, (unsigned long long)cpuc->pebs_enabled,
-			 *(unsigned long long *)cpuc->active_mask))
+		if (bit >= x86_pmu.max_pebs_events)
 			continue;
 
 		/*
Signature · 1 line
2.4.3
author
#1 lore raw

PATCH 2/2 x86, perf: Allow zero PEBS status with only single active event

From: Andi Kleen <[email protected]>

Normally we drop PEBS events with a zero status field. But when there is only a single PEBS event active we can assume the PEBS record is for that event. The PEBS buffer is always flushed when PEBS events are disabled, so there is no risk of mishandling state PEBS records this way.

---
 arch/x86/kernel/cpu/perf_event_intel_ds.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/kernel/cpu/perf_event_intel_ds.c +12 -0
index da294de..1259065 100644
@@ -1235,6 +1235,18 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
 		pebs_status = p->status & cpuc->pebs_enabled;
 		pebs_status &= (1ULL << x86_pmu.max_pebs_events) - 1;
 
+		/*
+		 * On some CPUs the PEBS status can be zero when PEBS is
+		 * racing with clearing of GLOBAL_STATUS.
+		 *
+		 * Normally we would drop that record, but in the
+		 * case when there is only a single active PEBS event
+		 * we can assume it's for that event.
+		 */
+		if (!pebs_status && cpuc->pebs_enabled &&
+			!(cpuc->pebs_enabled & (cpuc->pebs_enabled-1)))
+			pebs_status = cpuc->pebs_enabled;
+
 		bit = find_first_bit((unsigned long *)&pebs_status,
 					x86_pmu.max_pebs_events);
 		if (bit >= x86_pmu.max_pebs_events)
Signature · 1 line
2.4.3
maintainer
#2 lore raw

Re: [PATCH 2/2] x86, perf: Allow zero PEBS status with only single active event

Quoted 5 lines · Andi Kleen
arch/x86/kernel/cpu/perf_event_intel_ds.c +5 -0
+		/*
+		 * On some CPUs the PEBS status can be zero when PEBS is
+		 * racing with clearing of GLOBAL_STATUS.
+		 *
+		 * Normally we would drop that record, but in the

arch/x86/kernel/cpu/perf_event_intel_ds.c static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) · line 1252

Quoted 10 lines
arch/x86/kernel/cpu/perf_event_intel_ds.c +7 -0
+		 * case when there is only a single active PEBS event
+		 * we can assume it's for that event.
+		 */
+		if (!pebs_status && cpuc->pebs_enabled &&
+			!(cpuc->pebs_enabled & (cpuc->pebs_enabled-1)))
+			pebs_status = cpuc->pebs_enabled;
+
 		bit = find_first_bit((unsigned long *)&pebs_status,
 					x86_pmu.max_pebs_events);
 		if (bit >= x86_pmu.max_pebs_events)

Ah! I think this is the comment I just asked for.

#3 lore raw

[tip:perf/core] perf/x86: Allow zero PEBS status with only single active event

In reply to Andi Kleen
perf/x86: Allow zero PEBS status with only single active event
Commit-ID:  01330d7288e0050c5aaabc558059ff91589e67cd
Gitweb:     http://git.kernel.org/tip/01330d7288e0050c5aaabc558059ff91589e67cd
Author:     Andi Kleen <[email protected]>
AuthorDate: Thu, 3 Dec 2015 13:22:20 -0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 6 Jan 2016 11:15:31 +0100

perf/x86: Allow zero PEBS status with only single active event

Normally we drop PEBS events with a zero status field. But when there is only a single PEBS event active we can assume the PEBS record is for that event. The PEBS buffer is always flushed when PEBS events are disabled, so there is no risk of mishandling state PEBS records this way.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vince Weaver <[email protected]>
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/kernel/cpu/perf_event_intel_ds.c +12 -0
index 0e3a9c7..cd1993e 100644
@@ -1230,6 +1230,18 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
 		pebs_status = p->status & cpuc->pebs_enabled;
 		pebs_status &= (1ULL << x86_pmu.max_pebs_events) - 1;
 
+		/*
+		 * On some CPUs the PEBS status can be zero when PEBS is
+		 * racing with clearing of GLOBAL_STATUS.
+		 *
+		 * Normally we would drop that record, but in the
+		 * case when there is only a single active PEBS event
+		 * we can assume it's for that event.
+		 */
+		if (!pebs_status && cpuc->pebs_enabled &&
+			!(cpuc->pebs_enabled & (cpuc->pebs_enabled-1)))
+			pebs_status = cpuc->pebs_enabled;
+
 		bit = find_first_bit((unsigned long *)&pebs_status,
 					x86_pmu.max_pebs_events);
 		if (bit >= x86_pmu.max_pebs_events)
maintainer
#4 lore raw
In reply to Andi Kleen
Quoted 8 lines · Andi Kleen

From: Andi Kleen <[email protected]>

The recent change 75f80859b1 (... Robustify PEBS buffer drain) causes lots of warnings on different CPUs before Skylake when running PEBS intensive workloads.

They can have a zero status field in the PEBS record when PEBS is racing with clearing of GLOBAl_STATUS.

Ah, so _that_ is the explanation! Please put that in a comment near that code. This has long puzzled me.

Thanks for digging into that.

#5 lore raw

[tip:perf/core] perf/x86: Remove warning for zero PEBS status

In reply to Andi Kleen
perf/x86: Remove warning for zero PEBS status
Commit-ID:  957ea1fdbcdb909e1540f06f06f1a9ce6e696efa
Gitweb:     http://git.kernel.org/tip/957ea1fdbcdb909e1540f06f06f1a9ce6e696efa
Author:     Andi Kleen <[email protected]>
AuthorDate: Thu, 3 Dec 2015 13:22:19 -0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 6 Jan 2016 11:15:30 +0100

perf/x86: Remove warning for zero PEBS status

The recent commit:

75f80859b130 ("perf/x86/intel/pebs: Robustify PEBS buffer drain")

causes lots of warnings on different CPUs before Skylake when running PEBS intensive workloads.

They can have a zero status field in the PEBS record when PEBS is racing with clearing of GLOBAl_STATUS.

This also can cause hangs (it seems there are still problems with printk in NMI).

Disable the warning, but still ignore the record.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vince Weaver <[email protected]>
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/cpu/perf_event_intel_ds.c +1 -4
index 5db1c77..0e3a9c7 100644
@@ -1232,10 +1232,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
 
 		bit = find_first_bit((unsigned long *)&pebs_status,
 					x86_pmu.max_pebs_events);
-		if (WARN(bit >= x86_pmu.max_pebs_events,
-			 "PEBS record without PEBS event! status=%Lx pebs_enabled=%Lx active_mask=%Lx",
-			 (unsigned long long)p->status, (unsigned long long)cpuc->pebs_enabled,
-			 *(unsigned long long *)cpuc->active_mask))
+		if (bit >= x86_pmu.max_pebs_events)
 			continue;
 
 		/*