Re: [PATCH] perf_events: fix broken intr throttling (v3)

From: Sukadev Bhattiprolu
Date: Thu Feb 09 2012 - 22:18:13 EST


Stephane Eranian [eranian@xxxxxxxxxx] wrote:
| On Wed, Feb 8, 2012 at 12:32 PM, Anton Blanchard <anton@xxxxxxxxx> wrote:
| >
| > Hi,
| >
| > On Thu, 26 Jan 2012 17:03:19 +0100
| > Stephane Eranian <eranian@xxxxxxxxxx> wrote:
| >
| >> This patch fixes the throttling mechanism. It was broken
| >> in 3.2.0. Events were not being unthrottled. The unthrottling
| >> mechanism required that events be checked at each timer tick.
| >
| > This patch breaks perf on POWER. I haven't had a chance to work out why
| > yet, but will investigate tomorrow.
| >
| Did you apply the subsequent patch I posted yesterday:
|
| https://lkml.org/lkml/2012/2/7/185

I applied both patches to the powerpc.git tree - following hunk already
exists in the powerpc tree (and even Jan 27 mainline) so I skipped this
hunk.

--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -988,6 +988,9 @@ static void x86_pmu_start(struct perf_event *event, int flags)
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
int idx = event->hw.idx;

+ if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)))
+ return;
+
if (WARN_ON_ONCE(idx == -1))
return;

I tried this on Power7 system with a simple 'nooploop' program that loops
in while(1) for 10 seconds.

Results before the patches were applied:

# /tmp/perf record -e cycles,cycles /tmp/nooploop 10
[ perf record: Woken up 4 times to write data ]
[ perf record: Captured and wrote 0.886 MB perf.data (~38714 samples) ]

# /tmp/perf report -D | tail -15

Aggregated stats:
TOTAL events: 19307
MMAP events: 42
COMM events: 2
EXIT events: 2
SAMPLE events: 19261
cycles stats:
TOTAL events: 9993
MMAP events: 4
COMM events: 1
EXIT events: 2
SAMPLE events: 9986
cycles stats:
TOTAL events: 9275
SAMPLE events: 9275

After applying both patches:

# /tmp/perf record -e cycles,cycles /tmp/nooploop 10
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.006 MB perf.data (~260 samples) ]

# /tmp/perf report -D | tail -15

Aggregated stats:
TOTAL events: 80
MMAP events: 42
COMM events: 2
EXIT events: 2
SAMPLE events: 34
cycles stats:
TOTAL events: 24
MMAP events: 4
COMM events: 1
EXIT events: 2
SAMPLE events: 17

cycles stats:
TOTAL events: 17
SAMPLE events: 17

Sukadev

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