Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1283392 > unrolled thread

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

Started byAndi Kleen <andi@firstfloor.org>
First post2015-12-03 22:30 +0100
Last post2015-12-03 22:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] x86, perf: Allow zero PEBS status with only single active event Andi Kleen <andi@firstfloor.org> - 2015-12-03 22:30 +0100
    Re: [PATCH 2/2] x86, perf: Allow zero PEBS status with only single  active event Peter Zijlstra <peterz@infradead.org> - 2015-12-03 22:30 +0100

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

FromAndi Kleen <andi@firstfloor.org>
Date2015-12-03 22:30 +0100
Subject[PATCH 2/2] x86, perf: Allow zero PEBS status with only single active event
Message-ID<qBJBT-22d-1@gated-at.bofh.it>
From: Andi Kleen <ak@linux.intel.com>

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.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index da294de..1259065 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -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)
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


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

FromPeter Zijlstra <peterz@infradead.org>
Date2015-12-03 22:30 +0100
SubjectRe: [PATCH 2/2] x86, perf: Allow zero PEBS status with only single active event
Message-ID<qBJBV-22d-25@gated-at.bofh.it>
In reply to#1283392
On Thu, Dec 03, 2015 at 01:22:20PM -0800, Andi Kleen wrote:
> +		/*
> +		 * 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)


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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web