linux/arch/powerpc/kernel
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
..
vdso32 [PATCH] powerpc: Add some missing .gitignore's 2006-01-11 15:35:35 +11:00
vdso64 [PATCH] powerpc: vdso 64bits gettimeofday bug 2006-02-28 16:25:54 +11:00
align.c [PATCH] powerpc: merge align.c 2005-11-18 14:39:23 +11:00
asm-offsets.c Merge ../linux-2.6 2006-03-09 14:32:05 +11:00
binfmt_elf32.c ppc64: merge binfmt_elf32.c 2005-10-13 13:40:54 +10:00
btext.c [PATCH] powerpc: Remove device_node addrs/n_addr 2006-01-09 14:53:55 +11:00
cpu_setup_power4.S [PATCH] powerpc: Cleanup LOADADDR etc. asm macros 2006-01-13 21:16:23 +11:00
cputable.c Merge ../linux-2.6 2006-03-09 14:32:05 +11:00
crash.c [PATCH] powerpc: Trivial fix to set the proper timeout value for kdump 2006-02-24 11:36:21 +11:00
crash_dump.c powerpc: Fix compile error when CONFIG_PROC_VMCORE is not defined 2006-01-11 15:30:07 +11:00
dma_64.c [PATCH] powerpc: IBMEBUS bus support 2006-01-09 14:49:06 +11:00
entry_32.S powerpc: Fix various syscall/signal/swapcontext bugs 2006-03-08 13:24:22 +11:00
entry_64.S Merge ../linux-2.6 2006-03-09 14:32:05 +11:00
firmware.c [PATCH] powerpc: Move pSeries firmware feature setup into platforms/pseries 2006-02-10 16:52:03 +11:00
fpu.S powerpc/64: Fix bug in setting floating-point exception mode 2006-02-07 13:55:30 +11:00
head_4xx.S powerpc: Rename asm offset TRAP to _TRAP for 32-bit 2005-10-28 22:45:25 +10:00
head_8xx.S [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
head_32.S [PATCH] powerpc: fix altivec_unavailable_exception Oopses 2006-02-24 11:36:23 +11:00
head_44x.S [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
head_64.S Merge ../linux-2.6 2006-03-09 14:32:05 +11:00
head_booke.h [PATCH] powerpc: Fix Kernel FP unavail exception for BookE 2006-02-10 16:51:50 +11:00
head_fsl_booke.S [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
ibmebus.c [PATCH] powerpc: IBMEBUS bus support 2006-01-09 14:49:06 +11:00
idle_6xx.S powerpc: Use reg.h instead of processor.h when we just want reg names 2005-10-10 22:20:10 +10:00
idle_64.c powerpc: Move remaining .c files from arch/ppc64 to arch/powerpc 2005-11-18 15:43:34 +11:00
idle_power4.S [PATCH] powerpc: Cleanup LOADADDR etc. asm macros 2006-01-13 21:16:23 +11:00
init_task.c powerpc: make process.c suitable for both 32-bit and 64-bit 2005-10-10 22:29:05 +10:00
iomap.c [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
iommu.c [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
irq.c [PATCH] more for_each_cpu() conversions 2006-03-23 07:38:17 -08:00
kprobes.c [PATCH] kprobes: fix broken fault handling for powerpc64 2006-03-26 08:57:04 -08:00
legacy_serial.c [PATCH] CONFIG_ISA does not make sense for CONFIG_PPC_PSERIES 2006-02-01 08:53:08 -08:00
lparcfg.c [PATCH] powerpc: Fix OOPS in lparcfg on G5 2006-02-20 10:44:34 +11:00
lparmap.c [PATCH] powerpc: Fix iSeries bug in VMALLOCBASE/VMALLOC_START consolidation 2006-01-09 15:06:06 +11:00
machine_kexec.c [PATCH] powerpc: remove remaining crash_notes variable from machine_kexec.c 2006-01-11 14:48:02 +11:00
machine_kexec_32.c [PATCH] powerpc: Merge kexec 2006-01-09 14:48:52 +11:00
machine_kexec_64.c [PATCH] powerpc: Only calculate htab_size in one place for kexec 2006-02-24 11:36:18 +11:00
Makefile ppc: Use the system call table from arch/powerpc/kernel/systbl.S 2006-02-10 16:02:20 +11:00
misc_32.S [PATCH] powerpc: Cleanup LOADADDR etc. asm macros 2006-01-13 21:16:23 +11:00
misc_64.S [PATCH] powerpc: Cleanup LOADADDR etc. asm macros 2006-01-13 21:16:23 +11:00
module_64.c powerpc: Move most remaining ppc64 files over to arch/powerpc 2005-11-14 17:30:17 +11:00
nvram_64.c [PATCH] powerpc: fix large nvram access 2006-01-09 14:53:31 +11:00
of_device.c [PATCH] powerpc: tidy-up of_register_driver()/driver_register() return values 2006-03-23 14:40:54 +11:00
paca.c [PATCH] powerpc: Remove lppaca structure from the PACA 2006-01-13 21:17:39 +11:00
pci_32.c powerpc/32: Restore previous version of 32-bit PCI code 2006-01-15 22:05:47 +11:00
pci_64.c [PATCH] powerpc: properly configure DDR/P5IOC children devs 2006-03-16 16:55:07 +11:00
pci_direct_iommu.c powerpc: Move most remaining ppc64 files over to arch/powerpc 2005-11-14 17:30:17 +11:00
pci_dn.c powerpc: Move most remaining ppc64 files over to arch/powerpc 2005-11-14 17:30:17 +11:00
pci_iommu.c [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
pmc.c [PATCH] powerpc: G4+ oprofile support 2006-01-09 15:06:03 +11:00
ppc32.h powerpc: move include/asm-ppc64/ppc32.h to arch/powerpc/kernel 2005-11-03 16:03:28 +11:00
ppc_ksyms.c Merge ../linux-2.6 2006-03-17 12:01:19 +11:00
proc_ppc64.c [PATCH] powerpc: Merge vdso's and add vdso support to 32 bits kernel 2005-11-11 22:25:39 +11:00
process.c [PATCH] kretprobe instance recycled by parent process 2006-03-26 08:57:04 -08:00
prom.c Merge ../powerpc-merge 2006-02-28 16:35:24 +11:00
prom_init.c [PATCH] powerpc: incorrect rmo_top handling in prom_init 2006-03-03 22:01:05 +11:00
prom_parse.c [PATCH] powerpc: add refcounting to setup_peg2 and of_get_pci_address 2006-02-07 21:32:45 +11:00
ptrace-common.h [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
ptrace.c powerpc: Fix various syscall/signal/swapcontext bugs 2006-03-08 13:24:22 +11:00
ptrace32.c [PATCH] use ptrace_get_task_struct in various places 2006-01-08 20:13:51 -08:00
rtas-proc.c [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
rtas-rtc.c [PATCH] powerpc: RTC memory corruption 2006-03-16 16:55:03 +11:00
rtas.c [PATCH] powerpc: remove useless call to touch_softlockup_watchdog 2006-02-07 21:32:44 +11:00
rtas_flash.c [PATCH] Don't check pointer for NULL before passing it to kfree [arch/powerpc/kernel/rtas_flash.c] 2006-02-07 21:51:53 +11:00
rtas_pci.c Merge ../linux-2.6 2006-03-17 12:01:19 +11:00
semaphore.c powerpc: Merge enough to start building in arch/powerpc. 2005-09-26 16:04:21 +10:00
setup-common.c [PATCH] more for_each_cpu() conversions 2006-03-23 07:38:17 -08:00
setup.h powerpc: create kernel/setup.h 2005-11-09 11:35:26 +11:00
setup_32.c [PATCH] more for_each_cpu() conversions 2006-03-23 07:38:17 -08:00
setup_64.c [PATCH] Notifier chain update: API changes 2006-03-27 08:44:50 -08:00
signal_32.c powerpc: Fix various syscall/signal/swapcontext bugs 2006-03-08 13:24:22 +11:00
signal_64.c Merge ../linux-2.6 2006-03-09 14:32:05 +11:00
smp-tbsync.c powerpc: Merge smp-tbsync.c (the generic timebase sync routine) 2005-11-04 13:28:58 +11:00
smp.c powerpc: Implement accurate task and CPU time accounting 2006-02-24 14:05:56 +11:00
sys_ppc32.c [PATCH] consolidate sys32/compat_adjtimex 2006-03-26 08:56:57 -08:00
syscalls.c [PATCH] ppc64: fix time syscall 2006-01-09 15:47:13 +11:00
sysfs.c [PATCH] powerpc: Merge vdso's and add vdso support to 32 bits kernel 2005-11-11 22:25:39 +11:00
systbl.S powerpc: Fix various syscall/signal/swapcontext bugs 2006-03-08 13:24:22 +11:00
time.c Merge ../linux-2.6 2006-03-17 12:01:19 +11:00
traps.c [PATCH] Notifier chain update: API changes 2006-03-27 08:44:50 -08:00
udbg.c [PATCH] powerpc: Make early debugging configurable via Kconfig 2006-01-11 14:48:26 +11:00
udbg_16550.c [PATCH] powerpc: fix compile warning in udbg_init_maple_realmode 2006-02-07 21:51:52 +11:00
vdso.c Merge ../linux-2.6 2006-03-09 14:32:05 +11:00
vecemu.c [PATCH] powerpc: Move arch/ppc*/kernel/vecemu.c to arch/powerpc 2005-09-21 19:21:07 +10:00
vector.S powerpc: Use reg.h instead of processor.h when we just want reg names 2005-10-10 22:20:10 +10:00
vio.c [PATCH] Add vio_bus_type probe and remove methods 2006-01-13 11:26:07 -08:00
vmlinux.lds.S powerpc: Fix vmlinux.lds.S for 32-bit 2005-11-05 10:36:59 +11:00