alistair23-linux/arch
Steven Rostedt 78d904b46a ring-buffer: add NMI protection for spinlocks
Impact: prevent deadlock in NMI

The ring buffers are not yet totally lockless with writing to
the buffer. When a writer crosses a page, it grabs a per cpu spinlock
to protect against a reader. The spinlocks taken by a writer are not
to protect against other writers, since a writer can only write to
its own per cpu buffer. The spinlocks protect against readers that
can touch any cpu buffer. The writers are made to be reentrant
with the spinlocks disabling interrupts.

The problem arises when an NMI writes to the buffer, and that write
crosses a page boundary. If it grabs a spinlock, it can be racing
with another writer (since disabling interrupts does not protect
against NMIs) or with a reader on the same CPU. Luckily, most of the
users are not reentrant and protects against this issue. But if a
user of the ring buffer becomes reentrant (which is what the ring
buffers do allow), if the NMI also writes to the ring buffer then
we risk the chance of a deadlock.

This patch moves the ftrace_nmi_enter called by nmi_enter() to the
ring buffer code. It replaces the current ftrace_nmi_enter that is
used by arch specific code to arch_ftrace_nmi_enter and updates
the Kconfig to handle it.

When an NMI is called, it will set a per cpu variable in the ring buffer
code and will clear it when the NMI exits. If a write to the ring buffer
crosses page boundaries inside an NMI, a trylock is used on the spin
lock instead. If the spinlock fails to be acquired, then the entry
is discarded.

This bug appeared in the ftrace work in the RT tree, where event tracing
is reentrant. This workaround solved the deadlocks that appeared there.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
2009-02-07 20:00:17 -05:00
..
alpha alpha: fix the BUG() macro 2009-01-29 18:04:44 -08:00
arm Merge master.kernel.org:/home/rmk/linux-2.6-arm 2009-02-03 16:52:10 -08:00
avr32 eeprom: More consistent symbol names 2009-01-26 21:19:57 +01:00
blackfin Blackfin arch: Remove outdated code 2009-02-04 16:49:45 +08:00
cris Merge branch 'syscalls' of git://git390.osdl.marist.edu/pub/scm/linux-2.6 2009-01-14 19:58:40 -08:00
frv NOMMU: Make VMAs per MM as for MMU-mode linux 2009-01-08 12:04:47 +00:00
h8300 Merge branch 'syscalls' of git://git390.osdl.marist.edu/pub/scm/linux-2.6 2009-01-14 19:58:40 -08:00
ia64 Merge branches 'tracing/ftrace', 'tracing/kmemtrace' and 'linus' into tracing/core 2009-02-03 06:25:38 +01:00
m32r eeprom: More consistent symbol names 2009-01-26 21:19:57 +01:00
m68k m68knommu: remove the no longer used PCI support option 2009-01-27 16:42:02 +10:00
m68knommu m68knommu: fix 5329 ColdFire periphal addressing 2009-01-27 16:42:03 +10:00
mips MIPS: Alchemy: time.c build fix 2009-01-30 21:33:01 +00:00
mn10300 [CVE-2009-0029] Rename old_readdir to sys_old_readdir 2009-01-14 14:15:15 +01:00
parisc Documentation: move DMA-mapping.txt to Doc/PCI/ 2009-01-29 18:19:29 -08:00
powerpc powerpc: Fix oops on some machines due to incorrect pr_debug() 2009-02-02 17:08:25 +11:00
s390 [S390] Add missing compat system call wrappers. 2009-01-23 16:40:29 +01:00
sh Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6 2009-01-26 15:11:41 -08:00
sparc sparc64: Kill bogus TPC/address truncation during 32-bit faults. 2009-02-03 16:28:23 -08:00
um
x86 ring-buffer: add NMI protection for spinlocks 2009-02-07 20:00:17 -05:00
xtensa byteorder: make swab.h include asm/swab.h like a regular header 2009-01-14 19:56:50 -08:00
.gitignore
Kconfig [CVE-2009-0029] System call wrapper infrastructure 2009-01-14 14:15:16 +01:00