aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-03-27 04:16:30 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 11:44:50 -0500
commite041c683412d5bf44dc2b109053e3b837b71742d (patch)
tree9d271066ef379da0c0fb3b8cb4137abd5d2ebba0 /arch
parent76b81e2b0e2241accebcc68e126bc5ab958661b9 (diff)
[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>
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/kernel/setup.c5
-rw-r--r--arch/arm/mach-omap1/board-netstar.c2
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c2
-rw-r--r--arch/i386/kernel/traps.c17
-rw-r--r--arch/ia64/kernel/traps.c6
-rw-r--r--arch/mips/lasat/setup.c3
-rw-r--r--arch/mips/sgi-ip22/ip22-reset.c2
-rw-r--r--arch/mips/sgi-ip32/ip32-reset.c2
-rw-r--r--arch/parisc/kernel/pdc_chassis.c3
-rw-r--r--arch/powerpc/kernel/setup_64.c3
-rw-r--r--arch/powerpc/kernel/traps.c16
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c10
-rw-r--r--arch/ppc/platforms/prep_setup.c2
-rw-r--r--arch/s390/kernel/process.c11
-rw-r--r--arch/sparc64/kernel/traps.c17
-rw-r--r--arch/um/drivers/mconsole_kern.c3
-rw-r--r--arch/um/kernel/um_arch.c3
-rw-r--r--arch/x86_64/kernel/process.c17
-rw-r--r--arch/x86_64/kernel/traps.c18
-rw-r--r--arch/xtensa/platform-iss/setup.c2
20 files changed, 72 insertions, 72 deletions
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 9402624453c2..dd8769670596 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -43,7 +43,7 @@
43#include <asm/setup.h> 43#include <asm/setup.h>
44#include <asm/io.h> 44#include <asm/io.h>
45 45
46extern struct notifier_block *panic_notifier_list; 46extern struct atomic_notifier_head panic_notifier_list;
47static int alpha_panic_event(struct notifier_block *, unsigned long, void *); 47static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
48static struct notifier_block alpha_panic_block = { 48static struct notifier_block alpha_panic_block = {
49 alpha_panic_event, 49 alpha_panic_event,
@@ -500,7 +500,8 @@ setup_arch(char **cmdline_p)
500 } 500 }
501 501
502 /* Register a call for panic conditions. */ 502 /* Register a call for panic conditions. */
503 notifier_chain_register(&panic_notifier_list, &alpha_panic_block); 503 atomic_notifier_chain_register(&panic_notifier_list,
504 &alpha_panic_block);
504 505
505#ifdef CONFIG_ALPHA_GENERIC 506#ifdef CONFIG_ALPHA_GENERIC
506 /* Assume that we've booted from SRM if we haven't booted from MILO. 507 /* Assume that we've booted from SRM if we haven't booted from MILO.
diff --git a/arch/arm/mach-omap1/board-netstar.c b/arch/arm/mach-omap1/board-netstar.c
index 60d5f8a3339c..7520e602d7a2 100644
--- a/arch/arm/mach-omap1/board-netstar.c
+++ b/arch/arm/mach-omap1/board-netstar.c
@@ -141,7 +141,7 @@ static int __init netstar_late_init(void)
141 /* TODO: Setup front panel switch here */ 141 /* TODO: Setup front panel switch here */
142 142
143 /* Setup panic notifier */ 143 /* Setup panic notifier */
144 notifier_chain_register(&panic_notifier_list, &panic_block); 144 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
145 145
146 return 0; 146 return 0;
147} 147}
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index bfd5fdd1a875..52e4a9d69642 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -235,7 +235,7 @@ static struct notifier_block panic_block = {
235static int __init voiceblue_setup(void) 235static int __init voiceblue_setup(void)
236{ 236{
237 /* Setup panic notifier */ 237 /* Setup panic notifier */
238 notifier_chain_register(&panic_notifier_list, &panic_block); 238 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
239 239
240 return 0; 240 return 0;
241} 241}
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 4624f8ca2459..6b63a5aa1e46 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -92,22 +92,21 @@ asmlinkage void spurious_interrupt_bug(void);
92asmlinkage void machine_check(void); 92asmlinkage void machine_check(void);
93 93
94static int kstack_depth_to_print = 24; 94static int kstack_depth_to_print = 24;
95struct notifier_block *i386die_chain; 95ATOMIC_NOTIFIER_HEAD(i386die_chain);
96static DEFINE_SPINLOCK(die_notifier_lock);
97 96
98int register_die_notifier(struct notifier_block *nb) 97int register_die_notifier(struct notifier_block *nb)
99{ 98{
100 int err = 0;
101 unsigned long flags;
102
103 vmalloc_sync_all(); 99 vmalloc_sync_all();
104 spin_lock_irqsave(&die_notifier_lock, flags); 100 return atomic_notifier_chain_register(&i386die_chain, nb);
105 err = notifier_chain_register(&i386die_chain, nb);
106 spin_unlock_irqrestore(&die_notifier_lock, flags);
107 return err;
108} 101}
109EXPORT_SYMBOL(register_die_notifier); 102EXPORT_SYMBOL(register_die_notifier);
110 103
104int unregister_die_notifier(struct notifier_block *nb)
105{
106 return atomic_notifier_chain_unregister(&i386die_chain, nb);
107}
108EXPORT_SYMBOL(unregister_die_notifier);
109
111static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) 110static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
112{ 111{
113 return p > (void *)tinfo && 112 return p > (void *)tinfo &&
diff --git a/arch/ia64/kernel/traps.c b/arch/ia64/kernel/traps.c
index dabd6c32641e..7c1ddc8ac443 100644
--- a/arch/ia64/kernel/traps.c
+++ b/arch/ia64/kernel/traps.c
@@ -30,19 +30,19 @@ extern spinlock_t timerlist_lock;
30fpswa_interface_t *fpswa_interface; 30fpswa_interface_t *fpswa_interface;
31EXPORT_SYMBOL(fpswa_interface); 31EXPORT_SYMBOL(fpswa_interface);
32 32
33struct notifier_block *ia64die_chain; 33ATOMIC_NOTIFIER_HEAD(ia64die_chain);
34 34
35int 35int
36register_die_notifier(struct notifier_block *nb) 36register_die_notifier(struct notifier_block *nb)
37{ 37{
38 return notifier_chain_register(&ia64die_chain, nb); 38 return atomic_notifier_chain_register(&ia64die_chain, nb);
39} 39}
40EXPORT_SYMBOL_GPL(register_die_notifier); 40EXPORT_SYMBOL_GPL(register_die_notifier);
41 41
42int 42int
43unregister_die_notifier(struct notifier_block *nb) 43unregister_die_notifier(struct notifier_block *nb)
44{ 44{
45 return notifier_chain_unregister(&ia64die_chain, nb); 45 return atomic_notifier_chain_unregister(&ia64die_chain, nb);
46} 46}
47EXPORT_SYMBOL_GPL(unregister_die_notifier); 47EXPORT_SYMBOL_GPL(unregister_die_notifier);
48 48
diff --git a/arch/mips/lasat/setup.c b/arch/mips/lasat/setup.c
index 83eb08b7a072..e9e9a89c6741 100644
--- a/arch/mips/lasat/setup.c
+++ b/arch/mips/lasat/setup.c
@@ -165,7 +165,8 @@ void __init plat_setup(void)
165 165
166 /* Set up panic notifier */ 166 /* Set up panic notifier */
167 for (i = 0; i < sizeof(lasat_panic_block) / sizeof(struct notifier_block); i++) 167 for (i = 0; i < sizeof(lasat_panic_block) / sizeof(struct notifier_block); i++)
168 notifier_chain_register(&panic_notifier_list, &lasat_panic_block[i]); 168 atomic_notifier_chain_register(&panic_notifier_list,
169 &lasat_panic_block[i]);
169 170
170 lasat_reboot_setup(); 171 lasat_reboot_setup();
171 172
diff --git a/arch/mips/sgi-ip22/ip22-reset.c b/arch/mips/sgi-ip22/ip22-reset.c
index 92a3b3c15ed3..a9c58e067b53 100644
--- a/arch/mips/sgi-ip22/ip22-reset.c
+++ b/arch/mips/sgi-ip22/ip22-reset.c
@@ -238,7 +238,7 @@ static int __init reboot_setup(void)
238 request_irq(SGI_PANEL_IRQ, panel_int, 0, "Front Panel", NULL); 238 request_irq(SGI_PANEL_IRQ, panel_int, 0, "Front Panel", NULL);
239 init_timer(&blink_timer); 239 init_timer(&blink_timer);
240 blink_timer.function = blink_timeout; 240 blink_timer.function = blink_timeout;
241 notifier_chain_register(&panic_notifier_list, &panic_block); 241 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
242 242
243 return 0; 243 return 0;
244} 244}
diff --git a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c
index 0c948008b023..ab9d9cef089e 100644
--- a/arch/mips/sgi-ip32/ip32-reset.c
+++ b/arch/mips/sgi-ip32/ip32-reset.c
@@ -193,7 +193,7 @@ static __init int ip32_reboot_setup(void)
193 193
194 init_timer(&blink_timer); 194 init_timer(&blink_timer);
195 blink_timer.function = blink_timeout; 195 blink_timer.function = blink_timeout;
196 notifier_chain_register(&panic_notifier_list, &panic_block); 196 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
197 197
198 request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL); 198 request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL);
199 199
diff --git a/arch/parisc/kernel/pdc_chassis.c b/arch/parisc/kernel/pdc_chassis.c
index 2a01fe1bdc98..0cea6958f427 100644
--- a/arch/parisc/kernel/pdc_chassis.c
+++ b/arch/parisc/kernel/pdc_chassis.c
@@ -150,7 +150,8 @@ void __init parisc_pdc_chassis_init(void)
150 150
151 if (handle) { 151 if (handle) {
152 /* initialize panic notifier chain */ 152 /* initialize panic notifier chain */
153 notifier_chain_register(&panic_notifier_list, &pdc_chassis_panic_block); 153 atomic_notifier_chain_register(&panic_notifier_list,
154 &pdc_chassis_panic_block);
154 155
155 /* initialize reboot notifier chain */ 156 /* initialize reboot notifier chain */
156 register_reboot_notifier(&pdc_chassis_reboot_block); 157 register_reboot_notifier(&pdc_chassis_reboot_block);
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 2f3fdad35594..e20c1fae3423 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -579,7 +579,8 @@ void __init setup_arch(char **cmdline_p)
579 panic_timeout = 180; 579 panic_timeout = 180;
580 580
581 if (ppc_md.panic) 581 if (ppc_md.panic)
582 notifier_chain_register(&panic_notifier_list, &ppc64_panic_block); 582 atomic_notifier_chain_register(&panic_notifier_list,
583 &ppc64_panic_block);
583 584
584 init_mm.start_code = PAGE_OFFSET; 585 init_mm.start_code = PAGE_OFFSET;
585 init_mm.end_code = (unsigned long) _etext; 586 init_mm.end_code = (unsigned long) _etext;
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 98660aedeeb7..9763faab6739 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -74,19 +74,19 @@ EXPORT_SYMBOL(__debugger_dabr_match);
74EXPORT_SYMBOL(__debugger_fault_handler); 74EXPORT_SYMBOL(__debugger_fault_handler);
75#endif 75#endif
76 76
77struct notifier_block *powerpc_die_chain; 77ATOMIC_NOTIFIER_HEAD(powerpc_die_chain);
78static DEFINE_SPINLOCK(die_notifier_lock);
79 78
80int register_die_notifier(struct notifier_block *nb) 79int register_die_notifier(struct notifier_block *nb)
81{ 80{
82 int err = 0; 81 return atomic_notifier_chain_register(&powerpc_die_chain, nb);
83 unsigned long flags; 82}
83EXPORT_SYMBOL(register_die_notifier);
84 84
85 spin_lock_irqsave(&die_notifier_lock, flags); 85int unregister_die_notifier(struct notifier_block *nb)
86 err = notifier_chain_register(&powerpc_die_chain, nb); 86{
87 spin_unlock_irqrestore(&die_notifier_lock, flags); 87 return atomic_notifier_chain_unregister(&powerpc_die_chain, nb);
88 return err;
89} 88}
89EXPORT_SYMBOL(unregister_die_notifier);
90 90
91/* 91/*
92 * Trap & Exception support 92 * Trap & Exception support
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index 86cfa6ecdcf3..5ad90676567a 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -94,16 +94,16 @@ static struct device_node *derive_parent(const char *path)
94 return parent; 94 return parent;
95} 95}
96 96
97static struct notifier_block *pSeries_reconfig_chain; 97static BLOCKING_NOTIFIER_HEAD(pSeries_reconfig_chain);
98 98
99int pSeries_reconfig_notifier_register(struct notifier_block *nb) 99int pSeries_reconfig_notifier_register(struct notifier_block *nb)
100{ 100{
101 return notifier_chain_register(&pSeries_reconfig_chain, nb); 101 return blocking_notifier_chain_register(&pSeries_reconfig_chain, nb);
102} 102}
103 103
104void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) 104void pSeries_reconfig_notifier_unregister(struct notifier_block *nb)
105{ 105{
106 notifier_chain_unregister(&pSeries_reconfig_chain, nb); 106 blocking_notifier_chain_unregister(&pSeries_reconfig_chain, nb);
107} 107}
108 108
109static int pSeries_reconfig_add_node(const char *path, struct property *proplist) 109static int pSeries_reconfig_add_node(const char *path, struct property *proplist)
@@ -131,7 +131,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist
131 goto out_err; 131 goto out_err;
132 } 132 }
133 133
134 err = notifier_call_chain(&pSeries_reconfig_chain, 134 err = blocking_notifier_call_chain(&pSeries_reconfig_chain,
135 PSERIES_RECONFIG_ADD, np); 135 PSERIES_RECONFIG_ADD, np);
136 if (err == NOTIFY_BAD) { 136 if (err == NOTIFY_BAD) {
137 printk(KERN_ERR "Failed to add device node %s\n", path); 137 printk(KERN_ERR "Failed to add device node %s\n", path);
@@ -171,7 +171,7 @@ static int pSeries_reconfig_remove_node(struct device_node *np)
171 171
172 remove_node_proc_entries(np); 172 remove_node_proc_entries(np);
173 173
174 notifier_call_chain(&pSeries_reconfig_chain, 174 blocking_notifier_call_chain(&pSeries_reconfig_chain,
175 PSERIES_RECONFIG_REMOVE, np); 175 PSERIES_RECONFIG_REMOVE, np);
176 of_detach_node(np); 176 of_detach_node(np);
177 177
diff --git a/arch/ppc/platforms/prep_setup.c b/arch/ppc/platforms/prep_setup.c
index a0fc628ffb1e..d95c05d9824d 100644
--- a/arch/ppc/platforms/prep_setup.c
+++ b/arch/ppc/platforms/prep_setup.c
@@ -736,7 +736,7 @@ ibm_statusled_progress(char *s, unsigned short hex)
736 hex = 0xfff; 736 hex = 0xfff;
737 if (!notifier_installed) { 737 if (!notifier_installed) {
738 ++notifier_installed; 738 ++notifier_installed;
739 notifier_chain_register(&panic_notifier_list, 739 atomic_notifier_chain_register(&panic_notifier_list,
740 &ibm_statusled_block); 740 &ibm_statusled_block);
741 } 741 }
742 } 742 }
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 99182a415fe7..4a0f5a1551ea 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -76,17 +76,17 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
76/* 76/*
77 * Need to know about CPUs going idle? 77 * Need to know about CPUs going idle?
78 */ 78 */
79static struct notifier_block *idle_chain; 79static ATOMIC_NOTIFIER_HEAD(idle_chain);
80 80
81int register_idle_notifier(struct notifier_block *nb) 81int register_idle_notifier(struct notifier_block *nb)
82{ 82{
83 return notifier_chain_register(&idle_chain, nb); 83 return atomic_notifier_chain_register(&idle_chain, nb);
84} 84}
85EXPORT_SYMBOL(register_idle_notifier); 85EXPORT_SYMBOL(register_idle_notifier);
86 86
87int unregister_idle_notifier(struct notifier_block *nb) 87int unregister_idle_notifier(struct notifier_block *nb)
88{ 88{
89 return notifier_chain_unregister(&idle_chain, nb); 89 return atomic_notifier_chain_unregister(&idle_chain, nb);
90} 90}
91EXPORT_SYMBOL(unregister_idle_notifier); 91EXPORT_SYMBOL(unregister_idle_notifier);
92 92
@@ -95,7 +95,7 @@ void do_monitor_call(struct pt_regs *regs, long interruption_code)
95 /* disable monitor call class 0 */ 95 /* disable monitor call class 0 */
96 __ctl_clear_bit(8, 15); 96 __ctl_clear_bit(8, 15);
97 97
98 notifier_call_chain(&idle_chain, CPU_NOT_IDLE, 98 atomic_notifier_call_chain(&idle_chain, CPU_NOT_IDLE,
99 (void *)(long) smp_processor_id()); 99 (void *)(long) smp_processor_id());
100} 100}
101 101
@@ -116,7 +116,8 @@ static void default_idle(void)
116 return; 116 return;
117 } 117 }
118 118
119 rc = notifier_call_chain(&idle_chain, CPU_IDLE, (void *)(long) cpu); 119 rc = atomic_notifier_call_chain(&idle_chain,
120 CPU_IDLE, (void *)(long) cpu);
120 if (rc != NOTIFY_OK && rc != NOTIFY_DONE) 121 if (rc != NOTIFY_OK && rc != NOTIFY_DONE)
121 BUG(); 122 BUG();
122 if (rc != NOTIFY_OK) { 123 if (rc != NOTIFY_OK) {
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index df612e4f75f9..ff090bb9734b 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -43,18 +43,19 @@
43#include <linux/kmod.h> 43#include <linux/kmod.h>
44#endif 44#endif
45 45
46struct notifier_block *sparc64die_chain; 46ATOMIC_NOTIFIER_HEAD(sparc64die_chain);
47static DEFINE_SPINLOCK(die_notifier_lock);
48 47
49int register_die_notifier(struct notifier_block *nb) 48int register_die_notifier(struct notifier_block *nb)
50{ 49{
51 int err = 0; 50 return atomic_notifier_chain_register(&sparc64die_chain, nb);
52 unsigned long flags;
53 spin_lock_irqsave(&die_notifier_lock, flags);
54 err = notifier_chain_register(&sparc64die_chain, nb);
55 spin_unlock_irqrestore(&die_notifier_lock, flags);
56 return err;
57} 51}
52EXPORT_SYMBOL(register_die_notifier);
53
54int unregister_die_notifier(struct notifier_block *nb)
55{
56 return atomic_notifier_chain_unregister(&sparc64die_chain, nb);
57}
58EXPORT_SYMBOL(unregister_die_notifier);
58 59
59/* When an irrecoverable trap occurs at tl > 0, the trap entry 60/* When an irrecoverable trap occurs at tl > 0, the trap entry
60 * code logs the trap state registers at every level in the trap 61 * code logs the trap state registers at every level in the trap
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 54388d10bcf9..1488816588ea 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -762,7 +762,8 @@ static struct notifier_block panic_exit_notifier = {
762 762
763static int add_notifier(void) 763static int add_notifier(void)
764{ 764{
765 notifier_chain_register(&panic_notifier_list, &panic_exit_notifier); 765 atomic_notifier_chain_register(&panic_notifier_list,
766 &panic_exit_notifier);
766 return(0); 767 return(0);
767} 768}
768 769
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index bb1c87211ac1..7d51dd7201c3 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -477,7 +477,8 @@ static struct notifier_block panic_exit_notifier = {
477 477
478void __init setup_arch(char **cmdline_p) 478void __init setup_arch(char **cmdline_p)
479{ 479{
480 notifier_chain_register(&panic_notifier_list, &panic_exit_notifier); 480 atomic_notifier_chain_register(&panic_notifier_list,
481 &panic_exit_notifier);
481 paging_init(); 482 paging_init();
482 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); 483 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
483 *cmdline_p = command_line; 484 *cmdline_p = command_line;
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 0370720515f1..70dd8e5c6889 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -66,24 +66,17 @@ EXPORT_SYMBOL(boot_option_idle_override);
66void (*pm_idle)(void); 66void (*pm_idle)(void);
67static DEFINE_PER_CPU(unsigned int, cpu_idle_state); 67static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
68 68
69static struct notifier_block *idle_notifier; 69static ATOMIC_NOTIFIER_HEAD(idle_notifier);
70static DEFINE_SPINLOCK(idle_notifier_lock);
71 70
72void idle_notifier_register(struct notifier_block *n) 71void idle_notifier_register(struct notifier_block *n)
73{ 72{
74 unsigned long flags; 73 atomic_notifier_chain_register(&idle_notifier, n);
75 spin_lock_irqsave(&idle_notifier_lock, flags);
76 notifier_chain_register(&idle_notifier, n);
77 spin_unlock_irqrestore(&idle_notifier_lock, flags);
78} 74}
79EXPORT_SYMBOL_GPL(idle_notifier_register); 75EXPORT_SYMBOL_GPL(idle_notifier_register);
80 76
81void idle_notifier_unregister(struct notifier_block *n) 77void idle_notifier_unregister(struct notifier_block *n)
82{ 78{
83 unsigned long flags; 79 atomic_notifier_chain_unregister(&idle_notifier, n);
84 spin_lock_irqsave(&idle_notifier_lock, flags);
85 notifier_chain_unregister(&idle_notifier, n);
86 spin_unlock_irqrestore(&idle_notifier_lock, flags);
87} 80}
88EXPORT_SYMBOL(idle_notifier_unregister); 81EXPORT_SYMBOL(idle_notifier_unregister);
89 82
@@ -93,13 +86,13 @@ static DEFINE_PER_CPU(enum idle_state, idle_state) = CPU_NOT_IDLE;
93void enter_idle(void) 86void enter_idle(void)
94{ 87{
95 __get_cpu_var(idle_state) = CPU_IDLE; 88 __get_cpu_var(idle_state) = CPU_IDLE;
96 notifier_call_chain(&idle_notifier, IDLE_START, NULL); 89 atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL);
97} 90}
98 91
99static void __exit_idle(void) 92static void __exit_idle(void)
100{ 93{
101 __get_cpu_var(idle_state) = CPU_NOT_IDLE; 94 __get_cpu_var(idle_state) = CPU_NOT_IDLE;
102 notifier_call_chain(&idle_notifier, IDLE_END, NULL); 95 atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL);
103} 96}
104 97
105/* Called from interrupts to signify idle end */ 98/* Called from interrupts to signify idle end */
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 7b148309c529..edaa9fe654dc 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -69,20 +69,20 @@ asmlinkage void alignment_check(void);
69asmlinkage void machine_check(void); 69asmlinkage void machine_check(void);
70asmlinkage void spurious_interrupt_bug(void); 70asmlinkage void spurious_interrupt_bug(void);
71 71
72struct notifier_block *die_chain; 72ATOMIC_NOTIFIER_HEAD(die_chain);
73static DEFINE_SPINLOCK(die_notifier_lock);
74 73
75int register_die_notifier(struct notifier_block *nb) 74int register_die_notifier(struct notifier_block *nb)
76{ 75{
77 int err = 0;
78 unsigned long flags;
79
80 vmalloc_sync_all(); 76 vmalloc_sync_all();
81 spin_lock_irqsave(&die_notifier_lock, flags); 77 return atomic_notifier_chain_register(&die_chain, nb);
82 err = notifier_chain_register(&die_chain, nb); 78}
83 spin_unlock_irqrestore(&die_notifier_lock, flags); 79EXPORT_SYMBOL(register_die_notifier);
84 return err; 80
81int unregister_die_notifier(struct notifier_block *nb)
82{
83 return atomic_notifier_chain_unregister(&die_chain, nb);
85} 84}
85EXPORT_SYMBOL(unregister_die_notifier);
86 86
87static inline void conditional_sti(struct pt_regs *regs) 87static inline void conditional_sti(struct pt_regs *regs)
88{ 88{
diff --git a/arch/xtensa/platform-iss/setup.c b/arch/xtensa/platform-iss/setup.c
index 2e6dcbf0cc04..23790a5610e2 100644
--- a/arch/xtensa/platform-iss/setup.c
+++ b/arch/xtensa/platform-iss/setup.c
@@ -108,5 +108,5 @@ static struct notifier_block iss_panic_block = {
108 108
109void __init platform_setup(char **p_cmdline) 109void __init platform_setup(char **p_cmdline)
110{ 110{
111 notifier_chain_register(&panic_notifier_list, &iss_panic_block); 111 atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block);
112} 112}