* [PATCH] perf_events: fix BTS interrupt handling to avoid being dazed by NMI (v2)
@ 2010-09-10 11:28 Stephane Eranian
2010-09-10 13:25 ` Don Zickus
2010-09-13 8:33 ` [tip:perf/core] perf_events: Fix " tip-bot for Stephane Eranian
0 siblings, 2 replies; 3+ messages in thread
From: Stephane Eranian @ 2010-09-10 11:28 UTC (permalink / raw)
To: linux-kernel
Cc: peterz, mingo, paulus, davem, fweisbec, perfmon2-devel, eranian,
eranian, robert.richter, dzickus
Fix a bug introduced with commit de725de and the change in the meaning of the
return value of intel_pmu_handle_irq(). With the current code, when you are
using the BTS, you get 'dazed by NMI' each time the BTS buffer fills up.
BTS does interrupt on the PMU vector, thus NMI. You need to take this
into account in the return value of the function.
This version fixes initial patch which was missing changes to
perf_event_intel_ds.c.
Signed-off-by: Stephane Eranian <eranian@google.com>
--
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index ee05c90..b4d2e1c 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -713,18 +713,18 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
struct cpu_hw_events *cpuc;
int bit, loops;
u64 status;
- int handled = 0;
+ int handled;
perf_sample_data_init(&data, 0);
cpuc = &__get_cpu_var(cpu_hw_events);
intel_pmu_disable_all();
- intel_pmu_drain_bts_buffer();
+ handled = intel_pmu_drain_bts_buffer();
status = intel_pmu_get_status();
if (!status) {
intel_pmu_enable_all(0);
- return 0;
+ return handled;
}
loops = 0;
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 18018d1..44c8cfd 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -214,7 +214,7 @@ static void intel_pmu_disable_bts(void)
update_debugctlmsr(debugctlmsr);
}
-static void intel_pmu_drain_bts_buffer(void)
+static int intel_pmu_drain_bts_buffer(void)
{
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
struct debug_store *ds = cpuc->ds;
@@ -231,16 +231,16 @@ static void intel_pmu_drain_bts_buffer(void)
struct pt_regs regs;
if (!event)
- return;
+ return 0;
if (!ds)
- return;
+ return 0;
at = (struct bts_record *)(unsigned long)ds->bts_buffer_base;
top = (struct bts_record *)(unsigned long)ds->bts_index;
if (top <= at)
- return;
+ return 0;
ds->bts_index = ds->bts_buffer_base;
@@ -256,7 +256,7 @@ static void intel_pmu_drain_bts_buffer(void)
perf_prepare_sample(&header, &data, event, ®s);
if (perf_output_begin(&handle, event, header.size * (top - at), 1, 1))
- return;
+ return 1;
for (; at < top; at++) {
data.ip = at->from;
@@ -270,6 +270,7 @@ static void intel_pmu_drain_bts_buffer(void)
/* There's new data available. */
event->hw.interrupts++;
event->pending_kill = POLL_IN;
+ return 1;
}
/*
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf_events: fix BTS interrupt handling to avoid being dazed by NMI (v2)
2010-09-10 11:28 [PATCH] perf_events: fix BTS interrupt handling to avoid being dazed by NMI (v2) Stephane Eranian
@ 2010-09-10 13:25 ` Don Zickus
2010-09-13 8:33 ` [tip:perf/core] perf_events: Fix " tip-bot for Stephane Eranian
1 sibling, 0 replies; 3+ messages in thread
From: Don Zickus @ 2010-09-10 13:25 UTC (permalink / raw)
To: Stephane Eranian
Cc: linux-kernel, peterz, mingo, paulus, davem, fweisbec,
perfmon2-devel, eranian, robert.richter
On Fri, Sep 10, 2010 at 01:28:01PM +0200, Stephane Eranian wrote:
> Fix a bug introduced with commit de725de and the change in the meaning of the
> return value of intel_pmu_handle_irq(). With the current code, when you are
> using the BTS, you get 'dazed by NMI' each time the BTS buffer fills up.
>
> BTS does interrupt on the PMU vector, thus NMI. You need to take this
> into account in the return value of the function.
>
> This version fixes initial patch which was missing changes to
> perf_event_intel_ds.c.
Great work!
So does this mean my other patch that ack'd the intel pmu earlier than
before is unnecessary now? Or was this patch solving a different problem?
Cheers,
Don
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:perf/core] perf_events: Fix BTS interrupt handling to avoid being dazed by NMI (v2)
2010-09-10 11:28 [PATCH] perf_events: fix BTS interrupt handling to avoid being dazed by NMI (v2) Stephane Eranian
2010-09-10 13:25 ` Don Zickus
@ 2010-09-13 8:33 ` tip-bot for Stephane Eranian
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Stephane Eranian @ 2010-09-13 8:33 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, eranian, hpa, mingo, tglx, mingo, dzickus
Commit-ID: b0b2072df3b544f56b90173c2cde7a374c51546b
Gitweb: http://git.kernel.org/tip/b0b2072df3b544f56b90173c2cde7a374c51546b
Author: Stephane Eranian <eranian@google.com>
AuthorDate: Fri, 10 Sep 2010 13:28:01 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 13 Sep 2010 08:43:40 +0200
perf_events: Fix BTS interrupt handling to avoid being dazed by NMI (v2)
Fix a bug introduced with commit de725de and the change in the
meaning of the return value of intel_pmu_handle_irq(). With the
current code, when you are using the BTS, you get 'dazed by NMI'
each time the BTS buffer fills up.
BTS does interrupt on the PMU vector, thus NMI. You need to take
this into account in the return value of the function.
This version fixes initial patch which was missing changes to
perf_event_intel_ds.c.
Signed-off-by: Stephane Eranian <eranian@google.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Cc: peterz@infradead.org
Cc: paulus@samba.org
Cc: davem@davemloft.net
Cc: fweisbec@gmail.com
Cc: perfmon2-devel@lists.sf.net
Cc: eranian@gmail.com
Cc: robert.richter@amd.com
LKML-Reference: <4c8a1686.aae9d80a.5aa4.5e35@mx.google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/cpu/perf_event_intel.c | 6 +++---
arch/x86/kernel/cpu/perf_event_intel_ds.c | 11 ++++++-----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 82395f2..c8f5c08 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -713,18 +713,18 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
struct cpu_hw_events *cpuc;
int bit, loops;
u64 status;
- int handled = 0;
+ int handled;
perf_sample_data_init(&data, 0);
cpuc = &__get_cpu_var(cpu_hw_events);
intel_pmu_disable_all();
- intel_pmu_drain_bts_buffer();
+ handled = intel_pmu_drain_bts_buffer();
status = intel_pmu_get_status();
if (!status) {
intel_pmu_enable_all(0);
- return 0;
+ return handled;
}
loops = 0;
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 9893a2f..4977f9c 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -214,7 +214,7 @@ static void intel_pmu_disable_bts(void)
update_debugctlmsr(debugctlmsr);
}
-static void intel_pmu_drain_bts_buffer(void)
+static int intel_pmu_drain_bts_buffer(void)
{
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
struct debug_store *ds = cpuc->ds;
@@ -231,16 +231,16 @@ static void intel_pmu_drain_bts_buffer(void)
struct pt_regs regs;
if (!event)
- return;
+ return 0;
if (!ds)
- return;
+ return 0;
at = (struct bts_record *)(unsigned long)ds->bts_buffer_base;
top = (struct bts_record *)(unsigned long)ds->bts_index;
if (top <= at)
- return;
+ return 0;
ds->bts_index = ds->bts_buffer_base;
@@ -256,7 +256,7 @@ static void intel_pmu_drain_bts_buffer(void)
perf_prepare_sample(&header, &data, event, ®s);
if (perf_output_begin(&handle, event, header.size * (top - at), 1, 1))
- return;
+ return 1;
for (; at < top; at++) {
data.ip = at->from;
@@ -270,6 +270,7 @@ static void intel_pmu_drain_bts_buffer(void)
/* There's new data available. */
event->hw.interrupts++;
event->pending_kill = POLL_IN;
+ return 1;
}
/*
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-13 8:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-10 11:28 [PATCH] perf_events: fix BTS interrupt handling to avoid being dazed by NMI (v2) Stephane Eranian
2010-09-10 13:25 ` Don Zickus
2010-09-13 8:33 ` [tip:perf/core] perf_events: Fix " tip-bot for Stephane Eranian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox