linux/include/asm-powerpc
Alan Stern e041c68341 [PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe.  There is no
protection against entries being added to or removed from a chain while the
chain is in use.  The issues were discussed in this thread:

    http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2

We noticed that notifier chains in the kernel fall into two basic usage
classes:

	"Blocking" chains are always called from a process context
	and the callout routines are allowed to sleep;

	"Atomic" chains can be called from an atomic context and
	the callout routines are not allowed to sleep.

We decided to codify this distinction and make it part of the API.  Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name).  New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain.  The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.

With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed.  For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections.  (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)

There are some limitations, which should not be too hard to live with.  For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem.  Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain.  (This did happen in a couple of places and the code
had to be changed to avoid it.)

Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization.  Instead we use RCU.  The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.

Here is the list of chains that we adjusted and their classifications.  None
of them use the raw API, so for the moment it is only a placeholder.

  ATOMIC CHAINS
  -------------
arch/i386/kernel/traps.c:		i386die_chain
arch/ia64/kernel/traps.c:		ia64die_chain
arch/powerpc/kernel/traps.c:		powerpc_die_chain
arch/sparc64/kernel/traps.c:		sparc64die_chain
arch/x86_64/kernel/traps.c:		die_chain
drivers/char/ipmi/ipmi_si_intf.c:	xaction_notifier_list
kernel/panic.c:				panic_notifier_list
kernel/profile.c:			task_free_notifier
net/bluetooth/hci_core.c:		hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c:	ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c:	ip_conntrack_expect_chain
net/ipv6/addrconf.c:			inet6addr_chain
net/netfilter/nf_conntrack_core.c:	nf_conntrack_chain
net/netfilter/nf_conntrack_core.c:	nf_conntrack_expect_chain
net/netlink/af_netlink.c:		netlink_chain

  BLOCKING CHAINS
  ---------------
arch/powerpc/platforms/pseries/reconfig.c:	pSeries_reconfig_chain
arch/s390/kernel/process.c:		idle_chain
arch/x86_64/kernel/process.c		idle_notifier
drivers/base/memory.c:			memory_chain
drivers/cpufreq/cpufreq.c		cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c		cpufreq_transition_notifier_list
drivers/macintosh/adb.c:		adb_client_list
drivers/macintosh/via-pmu.c		sleep_notifier_list
drivers/macintosh/via-pmu68k.c		sleep_notifier_list
drivers/macintosh/windfarm_core.c	wf_client_list
drivers/usb/core/notify.c		usb_notifier_list
drivers/video/fbmem.c			fb_notifier_list
kernel/cpu.c				cpu_chain
kernel/module.c				module_notify_list
kernel/profile.c			munmap_notifier
kernel/profile.c			task_exit_notifier
kernel/sys.c				reboot_notifier_list
net/core/dev.c				netdev_chain
net/decnet/dn_dev.c:			dnaddr_chain
net/ipv4/devinet.c:			inetaddr_chain

It's possible that some of these classifications are wrong.  If they are,
please let us know or submit a patch to fix them.  Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)

The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.

[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-27 08:44:50 -08:00
..
iseries [PATCH] powerpc: iseries: Make more stuff static in platforms/iseries/mf.c 2006-03-22 15:04:23 +11:00
8253pit.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
a.out.h [PATCH] powerpc: Merge include/asm-ppc*/a.out.h into include/asm-powerpc 2005-09-21 19:21:08 +10:00
abs_addr.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
agp.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
asm-compat.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
atomic.h [PATCH] powerpc: native atomic_add_unless 2006-02-24 14:06:02 +11:00
auxvec.h [PATCH] powerpc: Merge vdso's and add vdso support to 32 bits kernel 2005-11-11 22:25:39 +11:00
backlight.h powerpc: Merged asm/backlight.h 2005-10-11 09:59:38 +10:00
bitops.h [PATCH] bitops: powerpc: use generic bitops 2006-03-26 08:57:14 -08:00
bootx.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
btext.h [PATCH] powerpc: Unify udbg (#2) 2006-01-09 14:49:54 +11:00
bug.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
bugs.h [PATCH] powerpc: Make check_bugs() static inline 2005-09-09 22:11:35 +10:00
byteorder.h [PATCH] powerpc: merge byteorder.h 2005-09-28 15:42:53 +10:00
cache.h [PATCH] Kill L1_CACHE_SHIFT_MAX 2006-01-08 20:13:39 -08:00
cacheflush.h [PATCH] powerpc: Merge cacheflush.h and cache.h 2005-11-10 13:09:22 +11:00
checksum.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
compat.h [PATCH] powerpc signal __user annotations 2006-02-08 01:03:46 -05:00
cputable.h [PATCH] powerpc: trivial: Cleanup whitespace in cputable.h 2006-03-22 15:04:15 +11:00
cputime.h powerpc: Implement accurate task and CPU time accounting 2006-02-24 14:05:56 +11:00
current.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
dbdma.h powerpc: Merge various powermac-related header files. 2005-10-20 20:53:39 +10:00
delay.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
div64.h [PATCH] Move the identical files from include/asm-ppc{,64} 2005-08-30 13:32:05 +10:00
dma-mapping.h [PATCH] remove bogus asm/bug.h includes. 2006-02-07 20:56:35 -05:00
dma.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
eeh.h [PATCH] powerpc: restore eeh_add_device_late() prototype stub 2006-03-08 14:14:00 -08:00
eeh_event.h [PATCH] powerpc: PCI Error Recovery: PPC64 core recovery routines 2006-01-10 15:28:32 +11:00
elf.h powerpc: Provide a suitable AT_PLATFORM value 2006-01-14 10:11:39 +11:00
emergency-restart.h [PATCH] Move the identical files from include/asm-ppc{,64} 2005-08-30 13:32:05 +10:00
errno.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
fcntl.h [PATCH] Consolidate the asm-ppc*/fcntl.h files into asm-powerpc 2005-09-07 16:57:39 -07:00
firmware.h [PATCH] powerpc: Replace platform_is_lpar() with a firmware feature 2006-03-22 15:04:17 +11:00
floppy.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
futex.h [PATCH] lightweight robust futexes updates 2006-03-27 08:44:49 -08:00
grackle.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
hardirq.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
heathrow.h powerpc: Fix some #ifndef __KERNEL__ that should be #ifdef 2006-01-09 15:14:05 +11:00
hvcall.h [PATCH] powerpc: Add some more pSeries hypervisor call constants 2006-01-13 20:56:38 +11:00
hvconsole.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
hvcserver.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
hw_irq.h ppc64: remove ppc_irq_dispatch_handler 2005-11-09 16:19:53 +11:00
i8259.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
ibmebus.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
ide.h powerpc: merge ide.h 2005-11-08 12:20:34 +11:00
io.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
ioctl.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
ioctls.h powerpc: remove duplicate ioctl definitions 2005-11-01 14:36:30 +11:00
iommu.h [PATCH] powerpc: clean up iommu.h a bit 2006-01-12 20:09:30 +11:00
ipc.h [PATCH] Move the identical files from include/asm-ppc{,64} 2005-08-30 13:32:05 +10:00
ipcbuf.h [PATCH] powerpc: Keep fixing merged ipcbuf.h 2005-11-03 16:58:17 +11:00
ipic.h [PATCH] powerpc: moved ipic code to arch/powerpc 2006-01-09 14:48:57 +11:00
irq.h powerpc: Implement accurate task and CPU time accounting 2006-02-24 14:05:56 +11:00
kdebug.h [PATCH] Notifier chain update: API changes 2006-03-27 08:44:50 -08:00
kdump.h [PATCH] powerpc: Reroute interrupts from 0 + offset to PHYSICAL_START + offset 2006-01-09 14:52:21 +11:00
kexec.h [PATCH] fix kexec asm 2006-03-08 14:15:04 -08:00
keylargo.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
kmap_types.h [PATCH] powerpc: Merge kmap_types.h 2005-09-19 09:38:49 +10:00
kprobes.h [PATCH] kprobes: fix build breakage 2006-01-10 08:01:40 -08:00
linkage.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
lmb.h [PATCH] powerpc: Remove calculation of io hole 2006-03-22 15:04:30 +11:00
local.h [PATCH] Move all the very similar files to asm-powerpc 2005-08-30 13:32:06 +10:00
lppaca.h [PATCH] Fix sparse parse error in lppaca.h 2006-01-17 17:18:25 -08:00
machdep.h [PATCH] cell: enable pause(0) in cpu_idle 2006-01-09 15:44:32 +11:00
macio.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
mc146818rtc.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
mediabay.h powerpc: Merge various powermac-related header files. 2005-10-20 20:53:39 +10:00
mman.h [PATCH] add asm-generic/mman.h 2006-02-15 15:32:22 -08:00
mmu.h [PATCH] powerpc: Remove calculation of io hole 2006-03-22 15:04:30 +11:00
mmu_context.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
mmzone.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
module.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
mpic.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
msgbuf.h [PATCH] powerpc: Merge a few more include files 2005-09-09 22:11:35 +10:00
mutex.h [PATCH] mutex subsystem, add default include/asm-*/mutex.h files 2006-01-09 15:59:19 -08:00
namei.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
numnodes.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
nvram.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
of_device.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
ohare.h powerpc: Fix some #ifndef __KERNEL__ that should be #ifdef 2006-01-09 15:14:05 +11:00
oprofile_impl.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
pSeries_reconfig.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
paca.h powerpc: Implement accurate task and CPU time accounting 2006-02-24 14:05:56 +11:00
page.h [PATCH] unify pfn_to_page: powerpc pfn_to_page 2006-03-27 08:44:44 -08:00
page_32.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
page_64.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
param.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
parport.h [PATCH] powerpc: parallel port init fix 2006-01-11 14:49:24 +11:00
pci-bridge.h [PATCH] powerpc: small pci cleanups 2006-01-12 20:09:30 +11:00
pci.h [PATCH] powerpc: make pcibios_claim_one_bus available to other code 2006-01-09 14:51:08 +11:00
percpu.h [PATCH] more for_each_cpu() conversions 2006-03-23 07:38:17 -08:00
pgalloc.h [PATCH] powerpc: Fix accidentally-working typo in __pud_free_tlb 2006-02-17 13:59:27 -08:00
pgtable-4k.h Merge ../linux-2.6 2006-03-09 14:32:05 +11:00
pgtable-64k.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
pgtable.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc 2006-03-22 22:20:46 -08:00
pmac_feature.h [PATCH] 3/5 powerpc: Add platform functions interpreter 2006-01-09 15:47:18 +11:00
pmac_low_i2c.h [PATCH] 3/5 powerpc: Add platform functions interpreter 2006-01-09 15:47:18 +11:00
pmac_pfunc.h [PATCH] powerpc: enable irq's for platform functions. 2006-02-01 08:53:10 -08:00
pmc.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
poll.h [PATCH] POLLRDHUP/EPOLLRDHUP handling for half-closed devices notifications 2006-03-25 08:22:56 -08:00
posix_types.h [PATCH] powerpc: Merge asm-ppc*/posix_types.h 2005-09-21 19:21:07 +10:00
ppc-pci.h [PATCH] powerpc: properly configure DDR/P5IOC children devs 2006-03-16 16:55:07 +11:00
ppc_asm.h powerpc: Implement accurate task and CPU time accounting 2006-02-24 14:05:56 +11:00
processor.h [PATCH] powerpc: Replace platform_is_lpar() with a firmware feature 2006-03-22 15:04:17 +11:00
prom.h [PATCH] powerpc: add for_each_node_by_foo helpers 2006-03-17 13:21:09 +11:00
ptrace.h [PATCH] syscall entry/exit revamp 2006-01-09 14:49:01 +11:00
reg.h [PATCH] powerpc: Fix runlatch performance issues 2006-02-24 11:36:31 +11:00
reg_8xx.h [PATCH] powerpc: Merge cacheflush.h and cache.h 2005-11-10 13:09:22 +11:00
resource.h [PATCH] Move all the very similar files to asm-powerpc 2005-08-30 13:32:06 +10:00
rtas.h [PATCH] powerpc: Make early debugging configurable via Kconfig 2006-01-11 14:48:26 +11:00
rtc.h powerpc: Make set_rtc_time() return error code from lower-level function 2005-10-22 15:57:55 +10:00
rwsem.h [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
scatterlist.h [PATCH] powerpc: merge scatterlist.h 2005-10-27 16:45:52 +10:00
seccomp.h powerpc: Fix some #ifndef __KERNEL__ that should be #ifdef 2006-01-09 15:14:05 +11:00
sections.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
semaphore.h Merge ../linux-2.6 by hand 2005-10-31 13:37:12 +11:00
sembuf.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
serial.h powerpc: Introduce a new config symbol to control 16550 early debug code 2006-01-10 16:19:05 +11:00
setup.h [PATCH] powerpc: Merge a few more include files 2005-09-09 22:11:35 +10:00
shmbuf.h [PATCH] powerpc: Fix __power64__ typos that should be __powerpc64__ 2005-09-09 22:11:35 +10:00
shmparam.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
sigcontext.h powerpc: merge sigcontext.h 2005-11-03 16:24:25 +11:00
siginfo.h [PATCH] ppc64: Add definitions for new PTRACE calls 2005-09-12 17:19:12 +10:00
signal.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
smp.h powerpc: Various UP build fixes 2005-11-07 13:18:13 +11:00
smu.h [PATCH] powerpc: Thermal control for dual core G5s 2006-02-07 22:05:14 -08:00
socket.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
sockios.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
sparsemem.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
spinlock.h [PATCH] powerpc: use lwsync in atomics, bitops, lock functions 2006-01-13 21:18:50 +11:00
spinlock_types.h [PATCH] powerpc: merge include/asm-ppc*/spinlock_types.h into include/asm-powerpc/spinlock_types.h 2005-09-21 19:21:09 +10:00
spu.h [PATCH] spufs: set irq affinity for running threads 2006-01-09 15:44:57 +11:00
spu_csa.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
sstep.h powerpc: Make single-stepping emulation (mostly) usable on 32-bit 2005-10-28 22:48:08 +10:00
stat.h powerpc: merge stat.h 2005-11-03 16:02:23 +11:00
statfs.h [PATCH] powerpc: merge include/asm-ppc*/statfs.h into include/asm-powerpc/statfs.h 2005-09-21 19:21:10 +10:00
string.h powerpc: fix strncasecmp prototype 2006-03-25 09:41:40 -08:00
synch.h [PATCH] powerpc: newline for ISYNC_ON_SMP 2006-02-24 14:06:00 +11:00
system.h [PATCH] powerpc: Add strne2a() to convert a string from EBCDIC to ASCII 2006-03-22 15:04:25 +11:00
tce.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
termbits.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
termios.h powerpc: use asm-generic/termios.h 2005-11-01 14:36:55 +11:00
thread_info.h powerpc: Fix various syscall/signal/swapcontext bugs 2006-03-08 13:24:22 +11:00
time.h powerpc: Implement accurate task and CPU time accounting 2006-02-24 14:05:56 +11:00
timex.h [PATCH] ppc32: Fix timekeeping 2005-10-12 08:24:47 -07:00
tlb.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
tlbflush.h [PATCH] ppc64: support 64k pages 2005-11-06 16:56:47 -08:00
topology.h [PATCH] scheduler cache-hot-autodetect 2006-01-12 09:08:50 -08:00
types.h [PATCH] 2TB files: add blkcnt_t 2006-03-26 08:57:00 -08:00
uaccess.h [PATCH] powerpc: Consolidate asm compatibility macros 2005-11-10 13:10:38 +11:00
ucontext.h powerpc: merge ucontext.h 2005-11-03 16:59:17 +11:00
udbg.h [PATCH] powerpc: Make early debugging configurable via Kconfig 2006-01-11 14:48:26 +11:00
unaligned.h [PATCH] powerpc: Standardize on _ASM_POWERPC header symbol prefix 2005-09-09 22:11:34 +10:00
uninorth.h powerpc: Merge various powermac-related header files. 2005-10-20 20:53:39 +10:00
unistd.h [PATCH] powerpc: unshare system call registration 2006-02-10 16:34:54 +11:00
user.h [PATCH] powerpc: Merge a few more include files 2005-09-09 22:11:35 +10:00
vdso.h [PATCH] powerpc: Make the vDSO functions set error code (#2) 2005-11-16 14:05:11 +11:00
vdso_datapage.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
vga.h [PATCH] powerpc: Merge asm-ppc*/vga.h 2005-09-21 19:21:09 +10:00
vio.h [PATCH] powerpc: sanitize header files for user space includes 2006-01-09 15:13:08 +11:00
xmon.h powerpc: Simplify and clean up the xmon terminal I/O 2005-11-08 22:55:08 +11:00
xor.h [PATCH] Move the identical files from include/asm-ppc{,64} 2005-08-30 13:32:05 +10:00