: changes notifier head of diechains and add notify_chain_unregister
PATCH 4/7 : changes notifier head of diechains and add notify_chain_unregister
This patch updates the usages of the various die_chains. It includes the changes posted by Keith Owens. Among them is addition of an unregister routine; with the new fixes unregister will not race with callouts.
-----
arch/i386/kernel/traps.c | 16 ++++++++-------- arch/ia64/kernel/traps.c | 2 +- arch/powerpc/kernel/traps.c | 16 ++++++++-------- arch/sparc64/kernel/traps.c | 17 +++++++++-------- arch/x86_64/kernel/traps.c | 17 +++++++++-------- include/asm-i386/kdebug.h | 8 +++----- include/asm-ia64/kdebug.h | 2 +- include/asm-powerpc/kdebug.h | 10 +++------- include/asm-sparc64/kdebug.h | 9 +++------ include/asm-x86_64/kdebug.h | 29 ++++++++++++++--------------- 10 files changed, 59 insertions(+), 67 deletions(-)
include/asm-i386/kdebug.h +3 -5
@@ -17,11 +17,9 @@ struct die_args {int signr; }; -/* Note - you should never unregister because that can race with NMIs. -If you really want to do it first unregister - then synchronize_sched - then free. -*/ -int register_die_notifier (struct notifier_block *nb); -extern struct notifier_block *i386die_chain; +extern int register_die_notifier (struct notifier_block *); +extern int unregister_die_notifier (struct notifier_block *); +extern struct notifier_head i386die_chain;/* Grossly misnamed. */
arch/i386/kernel/traps.c +8 -8
@@ -92,20 +92,20 @@ asmlinkage void spurious_interrupt_bug(v asmlinkage void machine_check(void);static int kstack_depth_to_print =24 ; -struct notifier_block *i386die_chain; -static DEFINE_SPINLOCK (die_notifier_lock); +ATOMIC_NOTIFIER_HEAD (i386die_chain);int register_die_notifier (struct notifier_block *nb) { -int err =0 ; -unsigned long flags; -spin_lock_irqsave (&die_notifier_lock, flags); - err =notifier_chain_register (&i386die_chain, nb); -spin_unlock_irqrestore (&die_notifier_lock, flags); -return err; +return notifier_chain_register (&i386die_chain, nb); }EXPORT_SYMBOL (register_die_notifier); +int unregister_die_notifier (struct notifier_block *nb) +{ +return notifier_chain_unregister (&i386die_chain, nb); +} +EXPORT_SYMBOL (unregister_die_notifier); +static inline int valid_stack_ptr (struct thread_info *tinfo,void *p) { return p > (void *)tinfo &&
include/asm-ia64/kdebug.h +1 -1
@@ -40,7 +40,7 @@ struct die_args {extern int register_die_notifier (struct notifier_block *);extern int unregister_die_notifier (struct notifier_block *); -extern struct notifier_block *ia64die_chain; +extern struct notifier_head ia64die_chain;enum die_val {DIE_BREAK =1 ,
arch/ia64/kernel/traps.c +1 -1
@@ -29,7 +29,7 @@ extern spinlock_t timerlist_lock;fpswa_interface_t *fpswa_interface;EXPORT_SYMBOL (fpswa_interface); -struct notifier_block *ia64die_chain; +ATOMIC_NOTIFIER_HEAD (ia64die_chain);int register_die_notifier (struct notifier_block *nb)
include/asm-powerpc/kdebug.h +3 -7
@@ -15,13 +15,9 @@ struct die_args {int signr; }; -/* -Note - you should never unregister because that can race with NMIs. -If you really want to do it first unregister - then synchronize_sched - -then free. -*/ -int register_die_notifier (struct notifier_block *nb); -extern struct notifier_block *powerpc_die_chain; +extern int register_die_notifier (struct notifier_block *); +extern int unregister_die_notifier (struct notifier_block *); +extern struct notifier_head powerpc_die_chain;/* Grossly misnamed. */ enum die_val {
arch/powerpc/kernel/traps.c +8 -8
@@ -73,19 +73,19 @@ EXPORT_SYMBOL(__debugger_dabr_match);EXPORT_SYMBOL (__debugger_fault_handler);#endif -struct notifier_block *powerpc_die_chain; -static DEFINE_SPINLOCK (die_notifier_lock); +ATOMIC_NOTIFIER_HEAD (powerpc_die_chain);int register_die_notifier (struct notifier_block *nb) { -int err =0 ; -unsigned long flags; +return notifier_chain_register (&powerpc_die_chain, nb); +} +EXPORT_SYMBOL (register_die_notifier); -spin_lock_irqsave (&die_notifier_lock, flags); - err =notifier_chain_register (&powerpc_die_chain, nb); -spin_unlock_irqrestore (&die_notifier_lock, flags); -return err; +int unregister_die_notifier (struct notifier_block *nb) +{ +return notifier_chain_unregister (&powerpc_die_chain, nb); } +EXPORT_SYMBOL (unregister_die_notifier);/* * Trap & Exception support
include/asm-sparc64/kdebug.h +3 -6
@@ -15,12 +15,9 @@ struct die_args {int signr; }; -/* Note - you should never unregister because that can race with NMIs. -* If you really want to do it first unregister - then synchronize_sched -* - then free. -*/ -int register_die_notifier (struct notifier_block *nb); -extern struct notifier_block *sparc64die_chain; +extern int register_die_notifier (struct notifier_block *); +extern int unregister_die_notifier (struct notifier_block *); +extern struct notifier_head sparc64die_chain;extern void bad_trap (struct pt_regs *,long );
arch/sparc64/kernel/traps.c +9 -8
@@ -42,18 +42,19 @@#include <linux/kmod.h> #endif -struct notifier_block *sparc64die_chain; -static DEFINE_SPINLOCK (die_notifier_lock); +ATOMIC_NOTIFIER_HEAD (sparc64die_chain);int register_die_notifier (struct notifier_block *nb) { -int err =0 ; -unsigned long flags; -spin_lock_irqsave (&die_notifier_lock, flags); - err =notifier_chain_register (&sparc64die_chain, nb); -spin_unlock_irqrestore (&die_notifier_lock, flags); -return err; +return notifier_chain_register (&sparc64die_chain, nb); } +EXPORT_SYMBOL (register_die_notifier); + +int unregister_die_notifier (struct notifier_block *nb) +{ +return notifier_chain_unregister (&sparc64die_chain, nb); +} +EXPORT_SYMBOL (unregister_die_notifier);/* When an irrecoverable trap occurs at tl > 0, the trap entry * code logs the trap state registers at every level in the trap
include/asm-x86_64/kdebug.h +14 -15
@@ -5,21 +5,20 @@struct pt_regs ; -struct die_args { +struct die_args {struct pt_regs *regs;const char *str; -long err; +long err;int trapnr;int signr; -}; +}; + +extern int register_die_notifier (struct notifier_block *); +extern int unregister_die_notifier (struct notifier_block *); +extern struct notifier_head die_chain; -/* Note - you should never unregister because that can race with NMIs. -If you really want to do it first unregister - then synchronize_sched - then free. -*/ -int register_die_notifier (struct notifier_block *nb); -extern struct notifier_block *die_chain;/* Grossly misnamed. */ -enum die_val { +enum die_val {DIE_OOPS =1 ,DIE_INT3 ,DIE_DEBUG ,
@@ -33,13 +32,13 @@ enum die_val {DIE_CALL ,DIE_NMI_IPI , DIE_PAGE_FAULT, -}; - +}; +static inline int notify_die (enum die_val val,char *str,struct pt_regs *regs,long err,int trap,int sig) -{ -struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig }; -return notifier_call_chain (&die_chain, val, &args); -} +{ +struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig }; +return notifier_call_chain (&die_chain, val, &args); +}extern int printk_address (unsigned long address);extern void die (const char *,struct pt_regs *,long );
arch/x86_64/kernel/traps.c +9 -8
@@ -72,18 +72,19 @@ asmlinkage void machine_check(void); asmlinkage void spurious_interrupt_bug(void); asmlinkage void call_debug(void); -struct notifier_block *die_chain; -static DEFINE_SPINLOCK (die_notifier_lock); +ATOMIC_NOTIFIER_HEAD (die_chain);int register_die_notifier (struct notifier_block *nb) { -int err =0 ; -unsigned long flags; -spin_lock_irqsave (&die_notifier_lock, flags); - err =notifier_chain_register (&die_chain, nb); -spin_unlock_irqrestore (&die_notifier_lock, flags); -return err; +return notifier_chain_register (&die_chain, nb); +} +EXPORT_SYMBOL (register_die_notifier); + +int unregister_die_notifier (struct notifier_block *nb) +{ +return notifier_chain_unregister (&die_chain, nb); } +EXPORT_SYMBOL (unregister_die_notifier);static inline void conditional_sti (struct pt_regs *regs) {
Signature · 4 lines
----------------------------------------------------------------------
Chandra Seetharaman | Be careful what you choose....
- [email protected] | .......you may get it.
----------------------------------------------------------------------include/asm-x86_64/kdebug.h line 8
Quoted 10 lines
Index:
l2615-rc1-notifiers/include/asm-x86_64/kdebug.h
===================================================================include/asm-x86_64/kdebug.h +1
-1@@ -5,21 +5,20 @@struct pt_regs ; -struct die_args { +struct die_args {
etc. lots more occurrences.
Can you please repost the patch without arbitary white space changes everywhere? They make it hard to review what you actually changed.
-Andi
Quoted 8 lines · Andi Kleen
Quoted 8 lines
Index:
l2615-rc1-notifiers/include/asm-x86_64/kdebug.h
===================================================================include/asm-x86_64/kdebug.h +0
-0@@ -5,21 +5,20 @@struct pt_regs ;
Quoted 7 lines
include/asm-x86_64/kdebug.h line 8
Quoted 2 lines
include/asm-x86_64/kdebug.h +1
-1-struct die_args { +struct die_args {etc. lots more occurrences.
Can you please repost the patch without arbitary white space changes everywhere?
Not everywhere, only include/asm-x86_64/kdebug.h has trailing white space and there was not enough white space changes to justify splitting its change into two patches. But since you insist ...
White space changes first.
include/asm-x86_64/kdebug.h +10 -10
@@ -5,13 +5,13 @@struct pt_regs ; -struct die_args { +struct die_args {struct pt_regs *regs;const char *str; -long err; +long err;int trapnr;int signr; -}; +};/* Note - you should never unregister because that can race with NMIs. If you really want to do it first unregister - then synchronize_sched - then free.
@@ -19,7 +19,7 @@ struct die_args {int register_die_notifier (struct notifier_block *nb);extern struct notifier_block *die_chain;/* Grossly misnamed. */ -enum die_val { +enum die_val {DIE_OOPS =1 ,DIE_INT3 ,DIE_DEBUG ,
@@ -33,13 +33,13 @@ enum die_val {DIE_CALL ,DIE_NMI_IPI , DIE_PAGE_FAULT, -}; - +}; +static inline int notify_die (enum die_val val,char *str,struct pt_regs *regs,long err,int trap,int sig) -{ -struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig }; -return notifier_call_chain (&die_chain, val, &args); -} +{ +struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig }; +return notifier_call_chain (&die_chain, val, &args); +}extern int printk_address (unsigned long address);extern void die (const char *,struct pt_regs *,long );
This is what is really changed in include/asm-x86_64/kdebug.h, the same basic change as in i386.
include/asm-x86_64/kdebug.h +4 -5
@@ -13,11 +13,10 @@ struct die_args {int signr; }; -/* Note - you should never unregister because that can race with NMIs. -If you really want to do it first unregister - then synchronize_sched - then free. -*/ -int register_die_notifier (struct notifier_block *nb); -extern struct notifier_block *die_chain; +extern int register_die_notifier (struct notifier_block *); +extern int unregister_die_notifier (struct notifier_block *); +extern struct notifier_head die_chain; +/* Grossly misnamed. */ enum die_val {DIE_OOPS =1 ,