linux-kernel-test/arch
Stephane Eranian 90151c35b1 perf_events: Fix event scheduling issues introduced by transactional API
The transactional API patch between the generic and model-specific
code introduced several important bugs with event scheduling, at
least on X86. If you had pinned events, e.g., watchdog,  and were
over-committing the PMU, you would get bogus counts. The bug was
showing up on Intel CPU because events would move around more
often that on AMD. But the problem also existed on AMD, though
harder to expose.

The issues were:

 - group_sched_in() was missing a cancel_txn() in the error path

 - cpuc->n_added was not properly maintained, leading to missing
   actions in hw_perf_enable(), i.e., n_running being 0. You cannot
   update n_added until you know the transaction has succeeded. In
   case of failed transaction n_added was not adjusted back.

 - in case of failed transactions, event_sched_out() was called
   and eventually invoked x86_disable_event() to touch the HW reg.
   But with transactions, on X86, event_sched_in() does not touch
   HW registers, it simply collects events into a list. Thus, you
   could end up calling x86_disable_event() on a counter which
   did not correspond to the current event when idx != -1.

The patch modifies the generic and X86 code to avoid all those problems.

First, we keep track of the number of events added last. In case the
transaction fails, we substract them from n_added. This approach is
necessary (as opposed to delaying updates to n_added) because not all
event updates use the transaction API, e.g., single events.

Second, we encapsulate the event_sched_in() and event_sched_out() in
group_sched_in() inside the transaction. That makes the operations
symmetrical and you can also detect that you are inside a transaction
and skip the HW reg access by checking cpuc->group_flag.

With this patch, you can now overcommit the PMU even with pinned
system-wide events present and still get valid counts.

Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1274796225.5882.1389.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-05-31 08:46:10 +02:00
..
alpha asm-generic: remove ARCH_HAS_SG_CHAIN in scatterlist.h 2010-05-27 09:12:54 -07:00
arm Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6 2010-05-30 09:13:08 -07:00
avr32 avr32: use asm-generic/scatterlist.h 2010-05-27 09:12:54 -07:00
blackfin blackfin: use use asm-generic/scatterlist.h 2010-05-27 09:12:55 -07:00
cris cris: use asm-generic/scatterlist.h 2010-05-27 09:12:55 -07:00
frv FRV: ARCH_KMALLOC_MINALIGN was already defined 2010-05-28 10:17:21 -07:00
h8300 h8300: use asm-generic/scatterlist.h 2010-05-27 09:12:55 -07:00
ia64 ia64: revert __node_random addition 2010-05-30 10:08:03 -07:00
m32r m32r: use use asm-generic/scatterlist.h 2010-05-27 09:12:55 -07:00
m68k Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k 2010-05-27 10:19:19 -07:00
m68knommu arch/m68knommu/platform/68360/commproc.c: Checkpatch cleanup 2010-05-24 14:44:25 +10:00
microblaze asm-generic: remove ARCH_HAS_SG_CHAIN in scatterlist.h 2010-05-27 09:12:54 -07:00
mips mips: use use asm-generic/scatterlist.h 2010-05-27 09:12:55 -07:00
mn10300 mn10300: use asm-generic/scatterlist.h 2010-05-27 09:12:55 -07:00
parisc Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6 2010-05-30 09:02:02 -07:00
powerpc tracing: fix for tracepoint API change 2010-05-28 10:20:14 -07:00
s390 Merge branch 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6 2010-05-27 10:48:46 -07:00
score asm-generic: remove ISA_DMA_THRESHOLD in scatterlist.h 2010-05-27 09:12:54 -07:00
sh asm-generic: add NEED_SG_DMA_LENGTH to define sg_dma_len() 2010-05-27 09:12:54 -07:00
sparc Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-05-27 15:23:47 -07:00
um Merge branch 'bkl/ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing 2010-05-24 08:01:10 -07:00
x86 perf_events: Fix event scheduling issues introduced by transactional API 2010-05-31 08:46:10 +02:00
xtensa xtensa: use use asm-generic/scatterlist.h 2010-05-27 09:12:55 -07:00
.gitignore
Kconfig hw-breakpoints: Separate constraint space for data and instruction breakpoints 2010-05-01 04:32:11 +02:00