* [PATCH 1/2] add tunable_notifier function ,take2
[not found] <4716FFDB.7090502@ah.jp.nec.com>
@ 2007-10-18 6:45 ` Takenori Nagano
2007-10-18 6:45 ` [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2 Takenori Nagano
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Takenori Nagano @ 2007-10-18 6:45 UTC (permalink / raw)
To: linux-kernel
Cc: vgoyal, Eric W. Biederman, k-miyoshi, kexec, Bernhard Walle,
Keith Owens, Andrew Morton, kdb
This patch adds new notifier function tunable_notifier_chain. Its base is
atomic_notifier_chain.
Thanks,
---
Signed-off-by: Takenori Nagano <t-nagano@ah.jp.nec.com>
---
diff -uprN linux-2.6.23.orig/include/linux/notifier.h
linux-2.6.23/include/linux/notifier.h
--- linux-2.6.23.orig/include/linux/notifier.h 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/include/linux/notifier.h 2007-10-18 09:59:13.732000000 +0900
@@ -13,6 +13,7 @@
#include <linux/mutex.h>
#include <linux/rwsem.h>
#include <linux/srcu.h>
+#include <linux/kobject.h>
/*
* Notifier chains are of four types:
@@ -53,6 +54,14 @@ struct notifier_block {
int priority;
};
+struct tunable_atomic_notifier_block {
+ struct notifier_block *nb;
+ struct tunable_atomic_notifier_head *head;
+ struct dentry *dir;
+ struct dentry *pri_dentry;
+ struct dentry *desc_dentry;
+};
+
struct atomic_notifier_head {
spinlock_t lock;
struct notifier_block *head;
@@ -63,6 +72,13 @@ struct blocking_notifier_head {
struct notifier_block *head;
};
+struct tunable_atomic_notifier_head {
+ spinlock_t lock;
+ struct notifier_block *head;
+ char *name;
+ struct dentry *dir;
+};
+
struct raw_notifier_head {
struct notifier_block *head;
};
@@ -81,6 +97,12 @@ struct srcu_notifier_head {
init_rwsem(&(name)->rwsem); \
(name)->head = NULL; \
} while (0)
+#define TUNABLE_ATOMIC_INIT_NOTIFIER(val1, val2) do { \
+ spin_lock_init(&(val1)->lock); \
+ (val1)->head = NULL; \
+ (val1)->name = val2; \
+ (val1)->dir = NULL; \
+ } while (0)
#define RAW_INIT_NOTIFIER_HEAD(name) do { \
(name)->head = NULL; \
} while (0)
@@ -96,6 +118,11 @@ extern void srcu_init_notifier_head(stru
#define BLOCKING_NOTIFIER_INIT(name) { \
.rwsem = __RWSEM_INITIALIZER((name).rwsem), \
.head = NULL }
+#define TUNABLE_ATOMIC_NOTIFIER_INIT(val1, val2) { \
+ .lock =__SPIN_LOCK_UNLOCKED(val1.lock), \
+ .head = NULL, \
+ .name = val2, \
+ .dir = NULL }
#define RAW_NOTIFIER_INIT(name) { \
.head = NULL }
/* srcu_notifier_heads cannot be initialized statically */
@@ -106,6 +133,9 @@ extern void srcu_init_notifier_head(stru
#define BLOCKING_NOTIFIER_HEAD(name) \
struct blocking_notifier_head name = \
BLOCKING_NOTIFIER_INIT(name)
+#define TUNABLE_ATOMIC_NOTIFIER_HEAD(name, val) \
+ struct tunable_atomic_notifier_head name = \
+ TUNABLE_ATOMIC_NOTIFIER_INIT(name, val)
#define RAW_NOTIFIER_HEAD(name) \
struct raw_notifier_head name = \
RAW_NOTIFIER_INIT(name)
@@ -116,6 +146,10 @@ extern int atomic_notifier_chain_registe
struct notifier_block *nb);
extern int blocking_notifier_chain_register(struct blocking_notifier_head *nh,
struct notifier_block *nb);
+extern int tunable_atomic_notifier_chain_register(
+ struct tunable_atomic_notifier_head *nh,
+ struct tunable_atomic_notifier_block *nb,
+ char *name, char *desc);
extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
@@ -125,6 +159,9 @@ extern int atomic_notifier_chain_unregis
struct notifier_block *nb);
extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh,
struct notifier_block *nb);
+extern int tunable_atomic_notifier_chain_unregister(
+ struct tunable_atomic_notifier_head *nh,
+ struct tunable_atomic_notifier_block *nb);
extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
@@ -138,6 +175,13 @@ extern int blocking_notifier_call_chain(
unsigned long val, void *v);
extern int __blocking_notifier_call_chain(struct blocking_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
+extern int tunable_atomic_notifier_call_chain(
+ struct tunable_atomic_notifier_head *nh,
+ unsigned long val, void *v);
+extern int __tunable_atomic_notifier_call_chain(
+ struct tunable_atomic_notifier_head *nh,
+ unsigned long val, void *v,
+ int nr_to_call, int *nr_calls);
extern int raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v);
extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
diff -uprN linux-2.6.23.orig/kernel/sys.c linux-2.6.23/kernel/sys.c
--- linux-2.6.23.orig/kernel/sys.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/kernel/sys.c 2007-10-18 10:08:52.728000000 +0900
@@ -38,6 +38,7 @@
#include <linux/syscalls.h>
#include <linux/kprobes.h>
#include <linux/user_namespace.h>
+#include <linux/debugfs.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -393,6 +394,243 @@ int blocking_notifier_call_chain(struct
EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
/*
+ * Tunable atomic notifier chain routines. Registration and unregistration
+ * use a spinlock, and call_chain is synchronized by RCU (no locks).
+ * User can change the list order to use /sys/kernel/debug/list-name/.
+ */
+
+static ssize_t priority_read(struct file *file,
+ char __user *user_buf, size_t count, loff_t *ppos)
+{
+ struct tunable_atomic_notifier_block *n =
+ file->f_dentry->d_inode->i_private;
+ int priority = n->nb->priority;
+ char buf[64], *s;
+
+ s = buf;
+ s += sprintf(s, "%d\n", priority);
+
+ return simple_read_from_buffer((void __user *)user_buf, count,
+ ppos, buf, s - buf);
+}
+
+static ssize_t priority_write(struct file *file,
+ const char __user *user_buf, size_t count, loff_t *ppos)
+{
+ struct tunable_atomic_notifier_block *n =
+ file->f_dentry->d_inode->i_private;
+ struct tunable_atomic_notifier_head *nh = n->head;
+ char *buf, *end;
+ int ret = -ENOMEM, priority;
+ unsigned long tmp, flags;
+
+ buf = kmalloc(count + 1, GFP_KERNEL);
+ if (!buf)
+ goto out;
+
+ buf[count] = 0;
+ ret = -EFAULT;
+ if (copy_from_user(buf, user_buf, count))
+ goto out_free;
+
+ ret = -EINVAL;
+ tmp = simple_strtoul(buf, &end, 10);
+ if ((end == buf) || (tmp > INT_MAX))
+ goto out_free;
+
+ priority = (int)tmp;
+ n->nb->priority = priority;
+
+ spin_lock_irqsave(&nh->lock, flags);
+ ret = notifier_chain_unregister(&nh->head, n->nb);
+ if (ret)
+ goto out_unlock;
+ ret = notifier_chain_register(&nh->head, n->nb);
+ if (!ret)
+ ret = count;
+
+out_unlock:
+ spin_unlock_irqrestore(&nh->lock, flags);
+out_free:
+ kfree(buf);
+out:
+ return ret;
+
+}
+
+static const struct file_operations pri_fops = {
+ .read = priority_read,
+ .write = priority_write,
+};
+
+static ssize_t description_read(struct file *file,
+ char __user *user_buf, size_t count, loff_t *ppos)
+{
+ char *desc = file->f_dentry->d_inode->i_private;
+ int avail = strlen(desc);
+
+ return simple_read_from_buffer(user_buf, count, ppos, desc, avail);
+}
+
+static const struct file_operations desc_fops = {
+ .read = description_read,
+};
+
+/**
+ * tunable_atomic_notifier_chain_register
+ * - Add notifier to an tunable notifier chain
+ * @nh: Pointer to head of the tunable notifier chain
+ * @n: New entry in notifier chain
+ * @name: Pointer to the name of the new notifier entry
+ * @desc: Pointer to the description of new entry
+ *
+ * Adds a notifier to an tunable notifier chain and makes control dir.
+ *
+ * Returns zero on success or %-ENODEV on failure.
+ */
+
+int tunable_atomic_notifier_chain_register(
+ struct tunable_atomic_notifier_head *nh,
+ struct tunable_atomic_notifier_block *n, char *name, char *desc)
+{
+ unsigned long flags;
+ int ret = -EINVAL;
+ struct dentry *nh_dir, *nb_dir, *pri_dentry, *desc_dentry = NULL;
+
+ if (!name)
+ goto nb_fail;
+
+ ret = -ENOMEM;
+ if (!nh->dir) {
+ nh_dir = debugfs_create_dir(nh->name, NULL);
+ if (!nh_dir)
+ return ret;
+ nh->dir = nh_dir;
+ } else
+ nh_dir = nh->dir;
+
+ nb_dir = debugfs_create_dir(name, nh_dir);
+ if (!nb_dir)
+ goto nb_fail;
+ n->dir = nb_dir;
+
+ pri_dentry = debugfs_create_file("priority",0600, nb_dir, n, &pri_fops);
+ if (!pri_dentry)
+ goto pri_fail;
+ n->pri_dentry = pri_dentry;
+
+ if (desc) {
+ desc_dentry = debugfs_create_file("description", 0400, nb_dir,
+ desc, &desc_fops);
+ if (!desc_dentry)
+ goto desc_fail;
+ n->desc_dentry = desc_dentry;
+ }
+
+ spin_lock_irqsave(&nh->lock, flags);
+ ret = notifier_chain_register(&nh->head, n->nb);
+ spin_unlock_irqrestore(&nh->lock, flags);
+
+ if (ret)
+ goto reg_fail;
+
+ n->head = nh;
+
+ return ret;
+
+reg_fail:
+ debugfs_remove(desc_dentry);
+desc_fail:
+ debugfs_remove(pri_dentry);
+pri_fail:
+ debugfs_remove(nb_dir);
+nb_fail:
+ return ret;
+}
+
+EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_register);
+
+/**
+ * tunable_atomic_notifier_chain_unregister
+ * - Remove notifier from a tunable notifier chain
+ * @nh: Pointer to head of the tunable notifier chain
+ * @n: Entry to remove from notifier chain
+ *
+ * Removes a notifier from a tunable notifier chain.
+ *
+ * Retunrns zero on success or %-ENOENT on failure.
+ */
+
+int tunable_atomic_notifier_chain_unregister(
+ struct tunable_atomic_notifier_head *nh,
+ struct tunable_atomic_notifier_block *n)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&nh->lock, flags);
+ ret = notifier_chain_unregister(&nh->head, n->nb);
+ spin_unlock_irqrestore(&nh->lock, flags);
+ synchronize_rcu();
+
+ if (ret)
+ return ret;
+
+ debugfs_remove(n->desc_dentry);
+ debugfs_remove(n->pri_dentry);
+ debugfs_remove(n->dir);
+
+ return 0;
+}
+
+EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_unregister);
+
+/**
+ * __tunable_atomic_notifier_call_chain
+ * - Call functions in a tunable notifier chain
+ * @nh: Pointer to head of the tunable notifier chain
+ * @val: Value passed unmodified to notifier function
+ * @v: Pointer passed unmodified to notifier function
+ * @nt_to_call: See the comment for notifier_call_chain
+ * @nr_calls: See the comment for notifier_call_chain
+ *
+ * Calls each function in a notifier chain in turn. The functions
+ * run in an atomic context, so they must not block.
+ * This routine uses RCU to synchronize with changes to the chain.
+ *
+ * If the return value of the notifier can be and'ed
+ * with %NOTIFY_STOP_MASK then tunable_atomic_notifier_call_chain()
+ * will return immediately, with the return value of
+ * the notifier function which halted execution.
+ * Otherwise the return value is the return value
+ * of the last notifier function called.
+ */
+
+int __kprobes __tunable_atomic_notifier_call_chain(
+ struct tunable_atomic_notifier_head *nh,
+ unsigned long val, void *v,
+ int nr_to_call, int *nr_calls)
+{
+ int ret;
+
+ rcu_read_lock();
+ ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls);
+ rcu_read_unlock();
+ return ret;
+}
+
+EXPORT_SYMBOL_GPL(__tunable_atomic_notifier_call_chain);
+
+int __kprobes tunable_atomic_notifier_call_chain(
+ struct tunable_atomic_notifier_head *nh,
+ unsigned long val, void *v)
+{
+ return __tunable_atomic_notifier_call_chain(nh, val, v, -1, NULL);
+}
+
+EXPORT_SYMBOL_GPL(tunable_atomic_notifier_call_chain);
+
+/*
* Raw notifier chain routines. There is no protection;
* the caller must provide it. Use at your own risk!
*/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2
[not found] <4716FFDB.7090502@ah.jp.nec.com>
2007-10-18 6:45 ` [PATCH 1/2] add tunable_notifier function ,take2 Takenori Nagano
@ 2007-10-18 6:45 ` Takenori Nagano
2007-10-18 8:53 ` [PATCH 1/2] add tunable_notifier function ,take2 Takenori Nagano
2007-10-18 8:53 ` [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2 Takenori Nagano
3 siblings, 0 replies; 8+ messages in thread
From: Takenori Nagano @ 2007-10-18 6:45 UTC (permalink / raw)
To: linux-kernel
Cc: vgoyal, Eric W. Biederman, k-miyoshi, kexec, Bernhard Walle,
Keith Owens, Andrew Morton, kdb
This patch implements new notifier function to panic_notifier_list. We can
change the list of order by debugfs.
Thanks,
---
Signed-off-by: Takenori Nagano <t-nagano@ah.jp.nec.com>
---
diff -uprN linux-2.6.23.orig/arch/alpha/kernel/setup.c
linux-2.6.23/arch/alpha/kernel/setup.c
--- linux-2.6.23.orig/arch/alpha/kernel/setup.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/alpha/kernel/setup.c 2007-10-18 08:56:53.928000000 +0900
@@ -45,14 +45,22 @@
#include <asm/io.h>
#include <linux/log2.h>
-extern struct atomic_notifier_head panic_notifier_list;
+extern struct tunable_atomic_notifier_head panic_notifier_list;
static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
-static struct notifier_block alpha_panic_block = {
+static struct notifier_block alpha_panic_block_base = {
alpha_panic_event,
NULL,
INT_MAX /* try to do it first */
};
+static struct tunable_atomic_notifier_block alpha_panic_block = {
+ &alpha_panic_block_base,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/system.h>
@@ -522,8 +530,8 @@ setup_arch(char **cmdline_p)
}
/* Register a call for panic conditions. */
- atomic_notifier_chain_register(&panic_notifier_list,
- &alpha_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &alpha_panic_block, "alpha_panic", NULL);
#ifdef CONFIG_ALPHA_GENERIC
/* Assume that we've booted from SRM if we haven't booted from MILO.
diff -uprN linux-2.6.23.orig/arch/arm/mach-omap1/board-voiceblue.c
linux-2.6.23/arch/arm/mach-omap1/board-voiceblue.c
--- linux-2.6.23.orig/arch/arm/mach-omap1/board-voiceblue.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/arch/arm/mach-omap1/board-voiceblue.c 2007-10-18
09:00:35.900000000 +0900
@@ -228,14 +228,23 @@ static int panic_event(struct notifier_b
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = panic_event,
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int __init voiceblue_setup(void)
{
/* Setup panic notifier */
- notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "VoiceBlue", NULL);
return 0;
}
diff -uprN linux-2.6.23.orig/arch/mips/sgi-ip22/ip22-reset.c
linux-2.6.23/arch/mips/sgi-ip22/ip22-reset.c
--- linux-2.6.23.orig/arch/mips/sgi-ip22/ip22-reset.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/arch/mips/sgi-ip22/ip22-reset.c 2007-10-18 09:01:33.408000000 +0900
@@ -226,10 +226,18 @@ static int panic_event(struct notifier_b
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = panic_event,
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int __init reboot_setup(void)
{
_machine_restart = sgi_machine_restart;
@@ -239,7 +247,8 @@ static int __init reboot_setup(void)
request_irq(SGI_PANEL_IRQ, panel_int, 0, "Front Panel", NULL);
init_timer(&blink_timer);
blink_timer.function = blink_timeout;
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "sgi-ip22", NULL);
return 0;
}
diff -uprN linux-2.6.23.orig/arch/mips/sgi-ip32/ip32-reset.c
linux-2.6.23/arch/mips/sgi-ip32/ip32-reset.c
--- linux-2.6.23.orig/arch/mips/sgi-ip32/ip32-reset.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/arch/mips/sgi-ip32/ip32-reset.c 2007-10-18 09:02:20.496000000 +0900
@@ -175,10 +175,18 @@ static int panic_event(struct notifier_b
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = panic_event,
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static __init int ip32_reboot_setup(void)
{
/* turn on the green led only */
@@ -193,7 +201,8 @@ static __init int ip32_reboot_setup(void
init_timer(&blink_timer);
blink_timer.function = blink_timeout;
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "sgi-ip32", NULL);
if (request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL))
panic("Can't allocate MACEISA RTC IRQ");
diff -uprN linux-2.6.23.orig/arch/parisc/kernel/pdc_chassis.c
linux-2.6.23/arch/parisc/kernel/pdc_chassis.c
--- linux-2.6.23.orig/arch/parisc/kernel/pdc_chassis.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/arch/parisc/kernel/pdc_chassis.c 2007-10-18 08:56:54.052000000
+0900
@@ -101,11 +101,18 @@ static int pdc_chassis_panic_event(struc
}
-static struct notifier_block pdc_chassis_panic_block = {
+static struct notifier_block pdc_chassis_panic_block_base = {
.notifier_call = pdc_chassis_panic_event,
.priority = INT_MAX,
};
+static struct tunable_atomic_notifier_block pdc_chassis_panic_block = {
+ .nb = &pdc_chassis_panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
/**
* parisc_reboot_event() - Called by the reboot handler.
@@ -144,8 +151,8 @@ void __init parisc_pdc_chassis_init(void
PDC_CHASSIS_VER);
/* initialize panic notifier chain */
- atomic_notifier_chain_register(&panic_notifier_list,
- &pdc_chassis_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &pdc_chassis_panic_block, "pdc_chassis", NULL);
/* initialize reboot notifier chain */
register_reboot_notifier(&pdc_chassis_reboot_block);
diff -uprN linux-2.6.23.orig/arch/powerpc/kernel/setup-common.c
linux-2.6.23/arch/powerpc/kernel/setup-common.c
--- linux-2.6.23.orig/arch/powerpc/kernel/setup-common.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/arch/powerpc/kernel/setup-common.c 2007-10-18
09:03:40.968000000 +0900
@@ -534,14 +534,23 @@ static int ppc_panic_event(struct notifi
return NOTIFY_DONE;
}
-static struct notifier_block ppc_panic_block = {
+static struct notifier_block ppc_panic_block_base = {
.notifier_call = ppc_panic_event,
.priority = INT_MIN /* may not return; must be done last */
};
+static struct tunable_atomic_notifier_block ppc_panic_block = {
+ .nb = &ppc_panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
void __init setup_panic(void)
{
- atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &ppc_panic_block, "powerpc", NULL);
}
#ifdef CONFIG_CHECK_CACHE_COHERENCY
diff -uprN linux-2.6.23.orig/arch/ppc/platforms/prep_setup.c
linux-2.6.23/arch/ppc/platforms/prep_setup.c
--- linux-2.6.23.orig/arch/ppc/platforms/prep_setup.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/arch/ppc/platforms/prep_setup.c 2007-10-18 09:04:56.352000000 +0900
@@ -712,12 +712,20 @@ ibm_statusled_panic(struct notifier_bloc
return NOTIFY_DONE;
}
-static struct notifier_block ibm_statusled_block = {
+static struct notifier_block ibm_statusled_block_base = {
ibm_statusled_panic,
NULL,
INT_MAX /* try to do it first */
};
+static struct tunable_atomic_notifier_block ibm_statusled_block = {
+ &ibm_statusled_block_base,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
static void
ibm_statusled_progress(char *s, unsigned short hex)
{
@@ -732,8 +740,9 @@ ibm_statusled_progress(char *s, unsigned
hex = 0xfff;
if (!notifier_installed) {
++notifier_installed;
- atomic_notifier_chain_register(&panic_notifier_list,
- &ibm_statusled_block);
+ tunable_atomic_notifier_chain_register(
+ &panic_notifier_list, &ibm_statusled_block,
+ "IBM_statusLED", NULL);
}
}
else
diff -uprN linux-2.6.23.orig/arch/s390/kernel/ipl.c
linux-2.6.23/arch/s390/kernel/ipl.c
--- linux-2.6.23.orig/arch/s390/kernel/ipl.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/s390/kernel/ipl.c 2007-10-18 08:56:54.132000000 +0900
@@ -1036,11 +1036,19 @@ static int shutdown_on_panic_notify(stru
return NOTIFY_OK;
}
-static struct notifier_block shutdown_on_panic_nb = {
+static struct notifier_block shutdown_on_panic_nb_base = {
.notifier_call = shutdown_on_panic_notify,
.priority = SHUTDOWN_ON_PANIC_PRIO
};
+static struct tunable_atomic_notifier_block shutdown_on_panic_nb = {
+ .nb = &shutdown_on_panic_nb_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int __init dump_init(void)
{
int rc;
@@ -1075,8 +1083,8 @@ static int __init shutdown_actions_init(
firmware_unregister(&shutdown_actions_subsys);
return rc;
}
- atomic_notifier_chain_register(&panic_notifier_list,
- &shutdown_on_panic_nb);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &shutdown_on_panic_nb, "s390_ipl", NULL);
return 0;
}
diff -uprN linux-2.6.23.orig/arch/s390/kernel/setup.c
linux-2.6.23/arch/s390/kernel/setup.c
--- linux-2.6.23.orig/arch/s390/kernel/setup.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/s390/kernel/setup.c 2007-10-18 08:56:54.144000000 +0900
@@ -173,11 +173,19 @@ static int vmpanic_notify(struct notifie
#define PANIC_PRI_VMPANIC 0
-static struct notifier_block vmpanic_nb = {
+static struct notifier_block vmpanic_nb_base = {
.notifier_call = vmpanic_notify,
.priority = PANIC_PRI_VMPANIC
};
+static struct tunable_atomic_notifier_block vmpanic_nb = {
+ .nb = &vmpanic_nb_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int __init vmpanic_setup(char *str)
{
static int register_done __initdata = 0;
@@ -186,8 +194,8 @@ static int __init vmpanic_setup(char *st
vmpanic_cmd[127] = 0;
if (!register_done) {
register_done = 1;
- atomic_notifier_chain_register(&panic_notifier_list,
- &vmpanic_nb);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &vmpanic_nb, "s390_panic", NULL);
}
return 1;
}
diff -uprN linux-2.6.23.orig/arch/sparc64/kernel/sstate.c
linux-2.6.23/arch/sparc64/kernel/sstate.c
--- linux-2.6.23.orig/arch/sparc64/kernel/sstate.c 2007-10-10 05:31:38.000000000
+0900
+++ linux-2.6.23/arch/sparc64/kernel/sstate.c 2007-10-18 09:05:46.620000000 +0900
@@ -82,11 +82,19 @@ static int sstate_panic_event(struct not
return NOTIFY_DONE;
}
-static struct notifier_block sstate_panic_block = {
+static struct notifier_block sstate_panic_block_base = {
.notifier_call = sstate_panic_event,
.priority = INT_MAX,
};
+static struct tunable_atomic_notifier_block sstate_panic_block = {
+ .nb = &sstate_panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
void __init sun4v_sstate_init(void)
{
unsigned long major, minor;
@@ -99,6 +107,6 @@ void __init sun4v_sstate_init(void)
hv_supports_soft_state = 1;
prom_sun4v_guest_soft_state();
- atomic_notifier_chain_register(&panic_notifier_list,
- &sstate_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &sstate_panic_block, "sstate" ,NULL);
}
diff -uprN linux-2.6.23.orig/arch/um/drivers/mconsole_kern.c
linux-2.6.23/arch/um/drivers/mconsole_kern.c
--- linux-2.6.23.orig/arch/um/drivers/mconsole_kern.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/arch/um/drivers/mconsole_kern.c 2007-10-18 09:06:25.144000000 +0900
@@ -928,16 +928,24 @@ static int notify_panic(struct notifier_
return(0);
}
-static struct notifier_block panic_exit_notifier = {
+static struct notifier_block panic_exit_notifier_base = {
.notifier_call = notify_panic,
.next = NULL,
.priority = 1
};
+static struct tunable_atomic_notifier_block panic_exit_notifier = {
+ .nb = &panic_exit_notifier_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int add_notifier(void)
{
- atomic_notifier_chain_register(&panic_notifier_list,
- &panic_exit_notifier);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_exit_notifier, "mconsole", NULL);
return(0);
}
diff -uprN linux-2.6.23.orig/arch/um/kernel/um_arch.c
linux-2.6.23/arch/um/kernel/um_arch.c
--- linux-2.6.23.orig/arch/um/kernel/um_arch.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/um/kernel/um_arch.c 2007-10-18 09:06:45.360000000 +0900
@@ -478,16 +478,24 @@ static int panic_exit(struct notifier_bl
return 0;
}
-static struct notifier_block panic_exit_notifier = {
+static struct notifier_block panic_exit_notifier_base = {
.notifier_call = panic_exit,
.next = NULL,
.priority = 0
};
+static struct tunable_atomic_notifier_block panic_exit_notifier = {
+ .nb = &panic_exit_notifier_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
void __init setup_arch(char **cmdline_p)
{
- atomic_notifier_chain_register(&panic_notifier_list,
- &panic_exit_notifier);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_exit_notifier, "um", NULL);
paging_init();
strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
*cmdline_p = command_line;
diff -uprN linux-2.6.23.orig/arch/xtensa/platform-iss/setup.c
linux-2.6.23/arch/xtensa/platform-iss/setup.c
--- linux-2.6.23.orig/arch/xtensa/platform-iss/setup.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/arch/xtensa/platform-iss/setup.c 2007-10-18 09:07:25.468000000
+0900
@@ -98,13 +98,22 @@ iss_panic_event(struct notifier_block *t
return NOTIFY_DONE;
}
-static struct notifier_block iss_panic_block = {
+static struct notifier_block iss_panic_block_base = {
iss_panic_event,
NULL,
0
};
+static struct tunable_atomic_notifier_block iss_panic_block = {
+ &iss_panic_block_base,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
void __init platform_setup(char **p_cmdline)
{
- atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &iss_panic_block, "iss_panic", NULL);
}
diff -uprN linux-2.6.23.orig/drivers/char/ipmi/ipmi_msghandler.c
linux-2.6.23/drivers/char/ipmi/ipmi_msghandler.c
--- linux-2.6.23.orig/drivers/char/ipmi/ipmi_msghandler.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/char/ipmi/ipmi_msghandler.c 2007-10-18
09:08:31.012000000 +0900
@@ -4070,12 +4070,20 @@ static int panic_event(struct notifier_b
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = panic_event,
.next = NULL,
.priority = 200 /* priority: INT_MAX >= x >= 0 */
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int ipmi_init_msghandler(void)
{
int rv;
@@ -4105,7 +4113,8 @@ static int ipmi_init_msghandler(void)
setup_timer(&ipmi_timer, ipmi_timeout, 0);
mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "ipmi_msghandler", NULL);
initialized = 1;
@@ -4125,7 +4134,8 @@ static __exit void cleanup_ipmi(void)
if (!initialized)
return;
- atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &panic_block);
/* This can't be called if any interfaces exist, so no worry about
shutting down the interfaces. */
diff -uprN linux-2.6.23.orig/drivers/char/ipmi/ipmi_watchdog.c
linux-2.6.23/drivers/char/ipmi/ipmi_watchdog.c
--- linux-2.6.23.orig/drivers/char/ipmi/ipmi_watchdog.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/char/ipmi/ipmi_watchdog.c 2007-10-18 09:09:20.660000000
+0900
@@ -1055,12 +1055,19 @@ static int wdog_panic_handler(struct not
return NOTIFY_OK;
}
-static struct notifier_block wdog_panic_notifier = {
+static struct notifier_block wdog_panic_notifier_base = {
.notifier_call = wdog_panic_handler,
.next = NULL,
.priority = 150 /* priority: INT_MAX >= x >= 0 */
};
+static struct tunable_atomic_notifier_block wdog_panic_notifier = {
+ .nb = &wdog_panic_notifier_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
static void ipmi_new_smi(int if_num, struct device *device)
{
@@ -1212,8 +1219,8 @@ static int __init ipmi_wdog_init(void)
check_parms();
register_reboot_notifier(&wdog_reboot_notifier);
- atomic_notifier_chain_register(&panic_notifier_list,
- &wdog_panic_notifier);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &wdog_panic_notifier, "ipmi_wdog", NULL);
rv = ipmi_smi_watcher_register(&smi_watcher);
if (rv) {
@@ -1221,8 +1228,8 @@ static int __init ipmi_wdog_init(void)
if (preaction_val == WDOG_PRETIMEOUT_NMI)
release_nmi(&ipmi_nmi_handler);
#endif
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &wdog_panic_notifier);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &wdog_panic_notifier);
unregister_reboot_notifier(&wdog_reboot_notifier);
printk(KERN_WARNING PFX "can't register smi watcher\n");
return rv;
@@ -1243,8 +1250,8 @@ static void __exit ipmi_wdog_exit(void)
release_nmi(&ipmi_nmi_handler);
#endif
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &wdog_panic_notifier);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &wdog_panic_notifier);
unregister_reboot_notifier(&wdog_reboot_notifier);
}
module_exit(ipmi_wdog_exit);
diff -uprN linux-2.6.23.orig/drivers/lguest/lguest.c
linux-2.6.23/drivers/lguest/lguest.c
--- linux-2.6.23.orig/drivers/lguest/lguest.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/lguest/lguest.c 2007-10-18 08:56:54.212000000 +0900
@@ -880,16 +880,25 @@ static int lguest_panic(struct notifier_
return NOTIFY_DONE;
}
-static struct notifier_block paniced = {
+static struct notifier_block paniced_base = {
.notifier_call = lguest_panic
};
+static struct tunable_atomic_notifier_block paniced = {
+ .nb = &paniced_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
/* Setting up memory is fairly easy. */
static __init char *lguest_memory_setup(void)
{
/* We do this here and not earlier because lockcheck barfs if we do it
* before start_kernel() */
- atomic_notifier_chain_register(&panic_notifier_list, &paniced);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list, &paniced,
+ "lguest", NULL);
/* The Linux bootloader header contains an "e820" memory map: the
* Launcher populated the first entry with our memory limit. */
diff -uprN linux-2.6.23.orig/drivers/misc/ibmasm/heartbeat.c
linux-2.6.23/drivers/misc/ibmasm/heartbeat.c
--- linux-2.6.23.orig/drivers/misc/ibmasm/heartbeat.c 2007-10-10
05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/misc/ibmasm/heartbeat.c 2007-10-18 09:11:07.696000000 +0900
@@ -48,17 +48,21 @@ static int panic_happened(struct notifie
return 0;
}
-static struct notifier_block panic_notifier = { panic_happened, NULL, 1 };
+static struct notifier_block panic_notifier_base = { panic_happened, NULL, 1 };
+
+static struct tunable_atomic_notifier_block panic_notifier = {
&panic_notifier_base,
+ NULL, NULL, NULL, NULL};
void ibmasm_register_panic_notifier(void)
{
- atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_notifier, "ibmasm", NULL);
}
void ibmasm_unregister_panic_notifier(void)
{
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &panic_notifier);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &panic_notifier);
}
diff -uprN linux-2.6.23.orig/drivers/parisc/power.c
linux-2.6.23/drivers/parisc/power.c
--- linux-2.6.23.orig/drivers/parisc/power.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/parisc/power.c 2007-10-18 09:11:36.880000000 +0900
@@ -189,11 +189,18 @@ static int parisc_panic_event(struct not
return NOTIFY_DONE;
}
-static struct notifier_block parisc_panic_block = {
+static struct notifier_block parisc_panic_block_base = {
.notifier_call = parisc_panic_event,
.priority = INT_MAX,
};
+static struct tunable_atomic_notifier_block parisc_panic_block = {
+ .nb = &parisc_panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
static int __init power_init(void)
{
@@ -231,8 +238,8 @@ static int __init power_init(void)
}
/* Register a call for panic conditions. */
- atomic_notifier_chain_register(&panic_notifier_list,
- &parisc_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &parisc_panic_block, "parisc_panic", NULL);
return 0;
}
@@ -241,8 +248,8 @@ static void __exit power_exit(void)
{
kthread_stop(power_task);
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &parisc_panic_block);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &parisc_panic_block);
pdc_soft_power_button(0);
}
diff -uprN linux-2.6.23.orig/include/linux/kernel.h
linux-2.6.23/include/linux/kernel.h
--- linux-2.6.23.orig/include/linux/kernel.h 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/include/linux/kernel.h 2007-10-18 08:56:54.216000000 +0900
@@ -104,7 +104,7 @@ extern int cond_resched(void);
(__x < 0) ? -__x : __x; \
})
-extern struct atomic_notifier_head panic_notifier_list;
+extern struct tunable_atomic_notifier_head panic_notifier_list;
extern long (*panic_blink)(long time);
NORET_TYPE void panic(const char * fmt, ...)
__attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
diff -uprN linux-2.6.23.orig/kernel/panic.c linux-2.6.23/kernel/panic.c
--- linux-2.6.23.orig/kernel/panic.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/kernel/panic.c 2007-10-18 09:12:28.188000000 +0900
@@ -28,7 +28,7 @@ static DEFINE_SPINLOCK(pause_on_oops_loc
int panic_timeout;
-ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
+TUNABLE_ATOMIC_NOTIFIER_HEAD(panic_notifier_list, "panic_notifier_list");
EXPORT_SYMBOL(panic_notifier_list);
@@ -96,7 +96,7 @@ NORET_TYPE void panic(const char * fmt,
smp_send_stop();
#endif
- atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
+ tunable_atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
if (!panic_blink)
panic_blink = no_blink;
diff -uprN linux-2.6.23.orig/kernel/softlockup.c linux-2.6.23/kernel/softlockup.c
--- linux-2.6.23.orig/kernel/softlockup.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/kernel/softlockup.c 2007-10-18 09:13:09.260000000 +0900
@@ -31,10 +31,18 @@ softlock_panic(struct notifier_block *th
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = softlock_panic,
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
/*
* Returns seconds, approximately. We don't need nanosecond
* resolution, and we don't need to waste time with a big divide when
@@ -193,5 +201,6 @@ __init void spawn_softlockup_task(void)
cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
register_cpu_notifier(&cpu_nfb);
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "softlockup", NULL);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] add tunable_notifier function ,take2
[not found] <4716FFDB.7090502@ah.jp.nec.com>
2007-10-18 6:45 ` [PATCH 1/2] add tunable_notifier function ,take2 Takenori Nagano
2007-10-18 6:45 ` [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2 Takenori Nagano
@ 2007-10-18 8:53 ` Takenori Nagano
2007-10-24 18:16 ` Randy Dunlap
2007-10-18 8:53 ` [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2 Takenori Nagano
3 siblings, 1 reply; 8+ messages in thread
From: Takenori Nagano @ 2007-10-18 8:53 UTC (permalink / raw)
To: linux-kernel
Cc: vgoyal, Eric W. Biederman, k-miyoshi, kexec, Bernhard Walle,
Keith Owens, Andrew Morton, kdb
This patch adds new notifier function tunable_notifier_chain. Its base is
atomic_notifier_chain.
Thanks,
---
Signed-off-by: Takenori Nagano <t-nagano@ah.jp.nec.com>
---
diff -uprN linux-2.6.23.orig/include/linux/notifier.h linux-2.6.23/include/linux/notifier.h
--- linux-2.6.23.orig/include/linux/notifier.h 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/include/linux/notifier.h 2007-10-18 09:59:13.732000000 +0900
@@ -13,6 +13,7 @@
#include <linux/mutex.h>
#include <linux/rwsem.h>
#include <linux/srcu.h>
+#include <linux/kobject.h>
/*
* Notifier chains are of four types:
@@ -53,6 +54,14 @@ struct notifier_block {
int priority;
};
+struct tunable_atomic_notifier_block {
+ struct notifier_block *nb;
+ struct tunable_atomic_notifier_head *head;
+ struct dentry *dir;
+ struct dentry *pri_dentry;
+ struct dentry *desc_dentry;
+};
+
struct atomic_notifier_head {
spinlock_t lock;
struct notifier_block *head;
@@ -63,6 +72,13 @@ struct blocking_notifier_head {
struct notifier_block *head;
};
+struct tunable_atomic_notifier_head {
+ spinlock_t lock;
+ struct notifier_block *head;
+ char *name;
+ struct dentry *dir;
+};
+
struct raw_notifier_head {
struct notifier_block *head;
};
@@ -81,6 +97,12 @@ struct srcu_notifier_head {
init_rwsem(&(name)->rwsem); \
(name)->head = NULL; \
} while (0)
+#define TUNABLE_ATOMIC_INIT_NOTIFIER(val1, val2) do { \
+ spin_lock_init(&(val1)->lock); \
+ (val1)->head = NULL; \
+ (val1)->name = val2; \
+ (val1)->dir = NULL; \
+ } while (0)
#define RAW_INIT_NOTIFIER_HEAD(name) do { \
(name)->head = NULL; \
} while (0)
@@ -96,6 +118,11 @@ extern void srcu_init_notifier_head(stru
#define BLOCKING_NOTIFIER_INIT(name) { \
.rwsem = __RWSEM_INITIALIZER((name).rwsem), \
.head = NULL }
+#define TUNABLE_ATOMIC_NOTIFIER_INIT(val1, val2) { \
+ .lock =__SPIN_LOCK_UNLOCKED(val1.lock), \
+ .head = NULL, \
+ .name = val2, \
+ .dir = NULL }
#define RAW_NOTIFIER_INIT(name) { \
.head = NULL }
/* srcu_notifier_heads cannot be initialized statically */
@@ -106,6 +133,9 @@ extern void srcu_init_notifier_head(stru
#define BLOCKING_NOTIFIER_HEAD(name) \
struct blocking_notifier_head name = \
BLOCKING_NOTIFIER_INIT(name)
+#define TUNABLE_ATOMIC_NOTIFIER_HEAD(name, val) \
+ struct tunable_atomic_notifier_head name = \
+ TUNABLE_ATOMIC_NOTIFIER_INIT(name, val)
#define RAW_NOTIFIER_HEAD(name) \
struct raw_notifier_head name = \
RAW_NOTIFIER_INIT(name)
@@ -116,6 +146,10 @@ extern int atomic_notifier_chain_registe
struct notifier_block *nb);
extern int blocking_notifier_chain_register(struct blocking_notifier_head *nh,
struct notifier_block *nb);
+extern int tunable_atomic_notifier_chain_register(
+ struct tunable_atomic_notifier_head *nh,
+ struct tunable_atomic_notifier_block *nb,
+ char *name, char *desc);
extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
@@ -125,6 +159,9 @@ extern int atomic_notifier_chain_unregis
struct notifier_block *nb);
extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh,
struct notifier_block *nb);
+extern int tunable_atomic_notifier_chain_unregister(
+ struct tunable_atomic_notifier_head *nh,
+ struct tunable_atomic_notifier_block *nb);
extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
@@ -138,6 +175,13 @@ extern int blocking_notifier_call_chain(
unsigned long val, void *v);
extern int __blocking_notifier_call_chain(struct blocking_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
+extern int tunable_atomic_notifier_call_chain(
+ struct tunable_atomic_notifier_head *nh,
+ unsigned long val, void *v);
+extern int __tunable_atomic_notifier_call_chain(
+ struct tunable_atomic_notifier_head *nh,
+ unsigned long val, void *v,
+ int nr_to_call, int *nr_calls);
extern int raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v);
extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
diff -uprN linux-2.6.23.orig/kernel/sys.c linux-2.6.23/kernel/sys.c
--- linux-2.6.23.orig/kernel/sys.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/kernel/sys.c 2007-10-18 10:08:52.728000000 +0900
@@ -38,6 +38,7 @@
#include <linux/syscalls.h>
#include <linux/kprobes.h>
#include <linux/user_namespace.h>
+#include <linux/debugfs.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -393,6 +394,243 @@ int blocking_notifier_call_chain(struct
EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
/*
+ * Tunable atomic notifier chain routines. Registration and unregistration
+ * use a spinlock, and call_chain is synchronized by RCU (no locks).
+ * User can change the list order to use /sys/kernel/debug/list-name/.
+ */
+
+static ssize_t priority_read(struct file *file,
+ char __user *user_buf, size_t count, loff_t *ppos)
+{
+ struct tunable_atomic_notifier_block *n =
+ file->f_dentry->d_inode->i_private;
+ int priority = n->nb->priority;
+ char buf[64], *s;
+
+ s = buf;
+ s += sprintf(s, "%d\n", priority);
+
+ return simple_read_from_buffer((void __user *)user_buf, count,
+ ppos, buf, s - buf);
+}
+
+static ssize_t priority_write(struct file *file,
+ const char __user *user_buf, size_t count, loff_t *ppos)
+{
+ struct tunable_atomic_notifier_block *n =
+ file->f_dentry->d_inode->i_private;
+ struct tunable_atomic_notifier_head *nh = n->head;
+ char *buf, *end;
+ int ret = -ENOMEM, priority;
+ unsigned long tmp, flags;
+
+ buf = kmalloc(count + 1, GFP_KERNEL);
+ if (!buf)
+ goto out;
+
+ buf[count] = 0;
+ ret = -EFAULT;
+ if (copy_from_user(buf, user_buf, count))
+ goto out_free;
+
+ ret = -EINVAL;
+ tmp = simple_strtoul(buf, &end, 10);
+ if ((end == buf) || (tmp > INT_MAX))
+ goto out_free;
+
+ priority = (int)tmp;
+ n->nb->priority = priority;
+
+ spin_lock_irqsave(&nh->lock, flags);
+ ret = notifier_chain_unregister(&nh->head, n->nb);
+ if (ret)
+ goto out_unlock;
+ ret = notifier_chain_register(&nh->head, n->nb);
+ if (!ret)
+ ret = count;
+
+out_unlock:
+ spin_unlock_irqrestore(&nh->lock, flags);
+out_free:
+ kfree(buf);
+out:
+ return ret;
+
+}
+
+static const struct file_operations pri_fops = {
+ .read = priority_read,
+ .write = priority_write,
+};
+
+static ssize_t description_read(struct file *file,
+ char __user *user_buf, size_t count, loff_t *ppos)
+{
+ char *desc = file->f_dentry->d_inode->i_private;
+ int avail = strlen(desc);
+
+ return simple_read_from_buffer(user_buf, count, ppos, desc, avail);
+}
+
+static const struct file_operations desc_fops = {
+ .read = description_read,
+};
+
+/**
+ * tunable_atomic_notifier_chain_register
+ * - Add notifier to an tunable notifier chain
+ * @nh: Pointer to head of the tunable notifier chain
+ * @n: New entry in notifier chain
+ * @name: Pointer to the name of the new notifier entry
+ * @desc: Pointer to the description of new entry
+ *
+ * Adds a notifier to an tunable notifier chain and makes control dir.
+ *
+ * Returns zero on success or %-ENODEV on failure.
+ */
+
+int tunable_atomic_notifier_chain_register(
+ struct tunable_atomic_notifier_head *nh,
+ struct tunable_atomic_notifier_block *n, char *name, char *desc)
+{
+ unsigned long flags;
+ int ret = -EINVAL;
+ struct dentry *nh_dir, *nb_dir, *pri_dentry, *desc_dentry = NULL;
+
+ if (!name)
+ goto nb_fail;
+
+ ret = -ENOMEM;
+ if (!nh->dir) {
+ nh_dir = debugfs_create_dir(nh->name, NULL);
+ if (!nh_dir)
+ return ret;
+ nh->dir = nh_dir;
+ } else
+ nh_dir = nh->dir;
+
+ nb_dir = debugfs_create_dir(name, nh_dir);
+ if (!nb_dir)
+ goto nb_fail;
+ n->dir = nb_dir;
+
+ pri_dentry = debugfs_create_file("priority",0600, nb_dir, n, &pri_fops);
+ if (!pri_dentry)
+ goto pri_fail;
+ n->pri_dentry = pri_dentry;
+
+ if (desc) {
+ desc_dentry = debugfs_create_file("description", 0400, nb_dir,
+ desc, &desc_fops);
+ if (!desc_dentry)
+ goto desc_fail;
+ n->desc_dentry = desc_dentry;
+ }
+
+ spin_lock_irqsave(&nh->lock, flags);
+ ret = notifier_chain_register(&nh->head, n->nb);
+ spin_unlock_irqrestore(&nh->lock, flags);
+
+ if (ret)
+ goto reg_fail;
+
+ n->head = nh;
+
+ return ret;
+
+reg_fail:
+ debugfs_remove(desc_dentry);
+desc_fail:
+ debugfs_remove(pri_dentry);
+pri_fail:
+ debugfs_remove(nb_dir);
+nb_fail:
+ return ret;
+}
+
+EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_register);
+
+/**
+ * tunable_atomic_notifier_chain_unregister
+ * - Remove notifier from a tunable notifier chain
+ * @nh: Pointer to head of the tunable notifier chain
+ * @n: Entry to remove from notifier chain
+ *
+ * Removes a notifier from a tunable notifier chain.
+ *
+ * Retunrns zero on success or %-ENOENT on failure.
+ */
+
+int tunable_atomic_notifier_chain_unregister(
+ struct tunable_atomic_notifier_head *nh,
+ struct tunable_atomic_notifier_block *n)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&nh->lock, flags);
+ ret = notifier_chain_unregister(&nh->head, n->nb);
+ spin_unlock_irqrestore(&nh->lock, flags);
+ synchronize_rcu();
+
+ if (ret)
+ return ret;
+
+ debugfs_remove(n->desc_dentry);
+ debugfs_remove(n->pri_dentry);
+ debugfs_remove(n->dir);
+
+ return 0;
+}
+
+EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_unregister);
+
+/**
+ * __tunable_atomic_notifier_call_chain
+ * - Call functions in a tunable notifier chain
+ * @nh: Pointer to head of the tunable notifier chain
+ * @val: Value passed unmodified to notifier function
+ * @v: Pointer passed unmodified to notifier function
+ * @nt_to_call: See the comment for notifier_call_chain
+ * @nr_calls: See the comment for notifier_call_chain
+ *
+ * Calls each function in a notifier chain in turn. The functions
+ * run in an atomic context, so they must not block.
+ * This routine uses RCU to synchronize with changes to the chain.
+ *
+ * If the return value of the notifier can be and'ed
+ * with %NOTIFY_STOP_MASK then tunable_atomic_notifier_call_chain()
+ * will return immediately, with the return value of
+ * the notifier function which halted execution.
+ * Otherwise the return value is the return value
+ * of the last notifier function called.
+ */
+
+int __kprobes __tunable_atomic_notifier_call_chain(
+ struct tunable_atomic_notifier_head *nh,
+ unsigned long val, void *v,
+ int nr_to_call, int *nr_calls)
+{
+ int ret;
+
+ rcu_read_lock();
+ ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls);
+ rcu_read_unlock();
+ return ret;
+}
+
+EXPORT_SYMBOL_GPL(__tunable_atomic_notifier_call_chain);
+
+int __kprobes tunable_atomic_notifier_call_chain(
+ struct tunable_atomic_notifier_head *nh,
+ unsigned long val, void *v)
+{
+ return __tunable_atomic_notifier_call_chain(nh, val, v, -1, NULL);
+}
+
+EXPORT_SYMBOL_GPL(tunable_atomic_notifier_call_chain);
+
+/*
* Raw notifier chain routines. There is no protection;
* the caller must provide it. Use at your own risk!
*/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2
[not found] <4716FFDB.7090502@ah.jp.nec.com>
` (2 preceding siblings ...)
2007-10-18 8:53 ` [PATCH 1/2] add tunable_notifier function ,take2 Takenori Nagano
@ 2007-10-18 8:53 ` Takenori Nagano
2007-10-24 18:11 ` Randy Dunlap
3 siblings, 1 reply; 8+ messages in thread
From: Takenori Nagano @ 2007-10-18 8:53 UTC (permalink / raw)
To: linux-kernel
Cc: vgoyal, Eric W. Biederman, k-miyoshi, kexec, Bernhard Walle,
Keith Owens, Andrew Morton, kdb
This patch implements new notifier function to panic_notifier_list. We can
change the list of order by debugfs.
Thanks,
---
Signed-off-by: Takenori Nagano <t-nagano@ah.jp.nec.com>
---
diff -uprN linux-2.6.23.orig/arch/alpha/kernel/setup.c linux-2.6.23/arch/alpha/kernel/setup.c
--- linux-2.6.23.orig/arch/alpha/kernel/setup.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/alpha/kernel/setup.c 2007-10-18 08:56:53.928000000 +0900
@@ -45,14 +45,22 @@
#include <asm/io.h>
#include <linux/log2.h>
-extern struct atomic_notifier_head panic_notifier_list;
+extern struct tunable_atomic_notifier_head panic_notifier_list;
static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
-static struct notifier_block alpha_panic_block = {
+static struct notifier_block alpha_panic_block_base = {
alpha_panic_event,
NULL,
INT_MAX /* try to do it first */
};
+static struct tunable_atomic_notifier_block alpha_panic_block = {
+ &alpha_panic_block_base,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/system.h>
@@ -522,8 +530,8 @@ setup_arch(char **cmdline_p)
}
/* Register a call for panic conditions. */
- atomic_notifier_chain_register(&panic_notifier_list,
- &alpha_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &alpha_panic_block, "alpha_panic", NULL);
#ifdef CONFIG_ALPHA_GENERIC
/* Assume that we've booted from SRM if we haven't booted from MILO.
diff -uprN linux-2.6.23.orig/arch/arm/mach-omap1/board-voiceblue.c linux-2.6.23/arch/arm/mach-omap1/board-voiceblue.c
--- linux-2.6.23.orig/arch/arm/mach-omap1/board-voiceblue.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/arm/mach-omap1/board-voiceblue.c 2007-10-18 09:00:35.900000000 +0900
@@ -228,14 +228,23 @@ static int panic_event(struct notifier_b
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = panic_event,
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int __init voiceblue_setup(void)
{
/* Setup panic notifier */
- notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "VoiceBlue", NULL);
return 0;
}
diff -uprN linux-2.6.23.orig/arch/mips/sgi-ip22/ip22-reset.c linux-2.6.23/arch/mips/sgi-ip22/ip22-reset.c
--- linux-2.6.23.orig/arch/mips/sgi-ip22/ip22-reset.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/mips/sgi-ip22/ip22-reset.c 2007-10-18 09:01:33.408000000 +0900
@@ -226,10 +226,18 @@ static int panic_event(struct notifier_b
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = panic_event,
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int __init reboot_setup(void)
{
_machine_restart = sgi_machine_restart;
@@ -239,7 +247,8 @@ static int __init reboot_setup(void)
request_irq(SGI_PANEL_IRQ, panel_int, 0, "Front Panel", NULL);
init_timer(&blink_timer);
blink_timer.function = blink_timeout;
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "sgi-ip22", NULL);
return 0;
}
diff -uprN linux-2.6.23.orig/arch/mips/sgi-ip32/ip32-reset.c linux-2.6.23/arch/mips/sgi-ip32/ip32-reset.c
--- linux-2.6.23.orig/arch/mips/sgi-ip32/ip32-reset.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/mips/sgi-ip32/ip32-reset.c 2007-10-18 09:02:20.496000000 +0900
@@ -175,10 +175,18 @@ static int panic_event(struct notifier_b
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = panic_event,
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static __init int ip32_reboot_setup(void)
{
/* turn on the green led only */
@@ -193,7 +201,8 @@ static __init int ip32_reboot_setup(void
init_timer(&blink_timer);
blink_timer.function = blink_timeout;
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "sgi-ip32", NULL);
if (request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL))
panic("Can't allocate MACEISA RTC IRQ");
diff -uprN linux-2.6.23.orig/arch/parisc/kernel/pdc_chassis.c linux-2.6.23/arch/parisc/kernel/pdc_chassis.c
--- linux-2.6.23.orig/arch/parisc/kernel/pdc_chassis.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/parisc/kernel/pdc_chassis.c 2007-10-18 08:56:54.052000000 +0900
@@ -101,11 +101,18 @@ static int pdc_chassis_panic_event(struc
}
-static struct notifier_block pdc_chassis_panic_block = {
+static struct notifier_block pdc_chassis_panic_block_base = {
.notifier_call = pdc_chassis_panic_event,
.priority = INT_MAX,
};
+static struct tunable_atomic_notifier_block pdc_chassis_panic_block = {
+ .nb = &pdc_chassis_panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
/**
* parisc_reboot_event() - Called by the reboot handler.
@@ -144,8 +151,8 @@ void __init parisc_pdc_chassis_init(void
PDC_CHASSIS_VER);
/* initialize panic notifier chain */
- atomic_notifier_chain_register(&panic_notifier_list,
- &pdc_chassis_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &pdc_chassis_panic_block, "pdc_chassis", NULL);
/* initialize reboot notifier chain */
register_reboot_notifier(&pdc_chassis_reboot_block);
diff -uprN linux-2.6.23.orig/arch/powerpc/kernel/setup-common.c linux-2.6.23/arch/powerpc/kernel/setup-common.c
--- linux-2.6.23.orig/arch/powerpc/kernel/setup-common.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/powerpc/kernel/setup-common.c 2007-10-18 09:03:40.968000000 +0900
@@ -534,14 +534,23 @@ static int ppc_panic_event(struct notifi
return NOTIFY_DONE;
}
-static struct notifier_block ppc_panic_block = {
+static struct notifier_block ppc_panic_block_base = {
.notifier_call = ppc_panic_event,
.priority = INT_MIN /* may not return; must be done last */
};
+static struct tunable_atomic_notifier_block ppc_panic_block = {
+ .nb = &ppc_panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
void __init setup_panic(void)
{
- atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &ppc_panic_block, "powerpc", NULL);
}
#ifdef CONFIG_CHECK_CACHE_COHERENCY
diff -uprN linux-2.6.23.orig/arch/ppc/platforms/prep_setup.c linux-2.6.23/arch/ppc/platforms/prep_setup.c
--- linux-2.6.23.orig/arch/ppc/platforms/prep_setup.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/ppc/platforms/prep_setup.c 2007-10-18 09:04:56.352000000 +0900
@@ -712,12 +712,20 @@ ibm_statusled_panic(struct notifier_bloc
return NOTIFY_DONE;
}
-static struct notifier_block ibm_statusled_block = {
+static struct notifier_block ibm_statusled_block_base = {
ibm_statusled_panic,
NULL,
INT_MAX /* try to do it first */
};
+static struct tunable_atomic_notifier_block ibm_statusled_block = {
+ &ibm_statusled_block_base,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
static void
ibm_statusled_progress(char *s, unsigned short hex)
{
@@ -732,8 +740,9 @@ ibm_statusled_progress(char *s, unsigned
hex = 0xfff;
if (!notifier_installed) {
++notifier_installed;
- atomic_notifier_chain_register(&panic_notifier_list,
- &ibm_statusled_block);
+ tunable_atomic_notifier_chain_register(
+ &panic_notifier_list, &ibm_statusled_block,
+ "IBM_statusLED", NULL);
}
}
else
diff -uprN linux-2.6.23.orig/arch/s390/kernel/ipl.c linux-2.6.23/arch/s390/kernel/ipl.c
--- linux-2.6.23.orig/arch/s390/kernel/ipl.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/s390/kernel/ipl.c 2007-10-18 08:56:54.132000000 +0900
@@ -1036,11 +1036,19 @@ static int shutdown_on_panic_notify(stru
return NOTIFY_OK;
}
-static struct notifier_block shutdown_on_panic_nb = {
+static struct notifier_block shutdown_on_panic_nb_base = {
.notifier_call = shutdown_on_panic_notify,
.priority = SHUTDOWN_ON_PANIC_PRIO
};
+static struct tunable_atomic_notifier_block shutdown_on_panic_nb = {
+ .nb = &shutdown_on_panic_nb_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int __init dump_init(void)
{
int rc;
@@ -1075,8 +1083,8 @@ static int __init shutdown_actions_init(
firmware_unregister(&shutdown_actions_subsys);
return rc;
}
- atomic_notifier_chain_register(&panic_notifier_list,
- &shutdown_on_panic_nb);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &shutdown_on_panic_nb, "s390_ipl", NULL);
return 0;
}
diff -uprN linux-2.6.23.orig/arch/s390/kernel/setup.c linux-2.6.23/arch/s390/kernel/setup.c
--- linux-2.6.23.orig/arch/s390/kernel/setup.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/s390/kernel/setup.c 2007-10-18 08:56:54.144000000 +0900
@@ -173,11 +173,19 @@ static int vmpanic_notify(struct notifie
#define PANIC_PRI_VMPANIC 0
-static struct notifier_block vmpanic_nb = {
+static struct notifier_block vmpanic_nb_base = {
.notifier_call = vmpanic_notify,
.priority = PANIC_PRI_VMPANIC
};
+static struct tunable_atomic_notifier_block vmpanic_nb = {
+ .nb = &vmpanic_nb_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int __init vmpanic_setup(char *str)
{
static int register_done __initdata = 0;
@@ -186,8 +194,8 @@ static int __init vmpanic_setup(char *st
vmpanic_cmd[127] = 0;
if (!register_done) {
register_done = 1;
- atomic_notifier_chain_register(&panic_notifier_list,
- &vmpanic_nb);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &vmpanic_nb, "s390_panic", NULL);
}
return 1;
}
diff -uprN linux-2.6.23.orig/arch/sparc64/kernel/sstate.c linux-2.6.23/arch/sparc64/kernel/sstate.c
--- linux-2.6.23.orig/arch/sparc64/kernel/sstate.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/sparc64/kernel/sstate.c 2007-10-18 09:05:46.620000000 +0900
@@ -82,11 +82,19 @@ static int sstate_panic_event(struct not
return NOTIFY_DONE;
}
-static struct notifier_block sstate_panic_block = {
+static struct notifier_block sstate_panic_block_base = {
.notifier_call = sstate_panic_event,
.priority = INT_MAX,
};
+static struct tunable_atomic_notifier_block sstate_panic_block = {
+ .nb = &sstate_panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
void __init sun4v_sstate_init(void)
{
unsigned long major, minor;
@@ -99,6 +107,6 @@ void __init sun4v_sstate_init(void)
hv_supports_soft_state = 1;
prom_sun4v_guest_soft_state();
- atomic_notifier_chain_register(&panic_notifier_list,
- &sstate_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &sstate_panic_block, "sstate" ,NULL);
}
diff -uprN linux-2.6.23.orig/arch/um/drivers/mconsole_kern.c linux-2.6.23/arch/um/drivers/mconsole_kern.c
--- linux-2.6.23.orig/arch/um/drivers/mconsole_kern.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/um/drivers/mconsole_kern.c 2007-10-18 09:06:25.144000000 +0900
@@ -928,16 +928,24 @@ static int notify_panic(struct notifier_
return(0);
}
-static struct notifier_block panic_exit_notifier = {
+static struct notifier_block panic_exit_notifier_base = {
.notifier_call = notify_panic,
.next = NULL,
.priority = 1
};
+static struct tunable_atomic_notifier_block panic_exit_notifier = {
+ .nb = &panic_exit_notifier_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int add_notifier(void)
{
- atomic_notifier_chain_register(&panic_notifier_list,
- &panic_exit_notifier);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_exit_notifier, "mconsole", NULL);
return(0);
}
diff -uprN linux-2.6.23.orig/arch/um/kernel/um_arch.c linux-2.6.23/arch/um/kernel/um_arch.c
--- linux-2.6.23.orig/arch/um/kernel/um_arch.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/um/kernel/um_arch.c 2007-10-18 09:06:45.360000000 +0900
@@ -478,16 +478,24 @@ static int panic_exit(struct notifier_bl
return 0;
}
-static struct notifier_block panic_exit_notifier = {
+static struct notifier_block panic_exit_notifier_base = {
.notifier_call = panic_exit,
.next = NULL,
.priority = 0
};
+static struct tunable_atomic_notifier_block panic_exit_notifier = {
+ .nb = &panic_exit_notifier_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
void __init setup_arch(char **cmdline_p)
{
- atomic_notifier_chain_register(&panic_notifier_list,
- &panic_exit_notifier);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_exit_notifier, "um", NULL);
paging_init();
strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
*cmdline_p = command_line;
diff -uprN linux-2.6.23.orig/arch/xtensa/platform-iss/setup.c linux-2.6.23/arch/xtensa/platform-iss/setup.c
--- linux-2.6.23.orig/arch/xtensa/platform-iss/setup.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/arch/xtensa/platform-iss/setup.c 2007-10-18 09:07:25.468000000 +0900
@@ -98,13 +98,22 @@ iss_panic_event(struct notifier_block *t
return NOTIFY_DONE;
}
-static struct notifier_block iss_panic_block = {
+static struct notifier_block iss_panic_block_base = {
iss_panic_event,
NULL,
0
};
+static struct tunable_atomic_notifier_block iss_panic_block = {
+ &iss_panic_block_base,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
void __init platform_setup(char **p_cmdline)
{
- atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &iss_panic_block, "iss_panic", NULL);
}
diff -uprN linux-2.6.23.orig/drivers/char/ipmi/ipmi_msghandler.c linux-2.6.23/drivers/char/ipmi/ipmi_msghandler.c
--- linux-2.6.23.orig/drivers/char/ipmi/ipmi_msghandler.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/char/ipmi/ipmi_msghandler.c 2007-10-18 09:08:31.012000000 +0900
@@ -4070,12 +4070,20 @@ static int panic_event(struct notifier_b
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = panic_event,
.next = NULL,
.priority = 200 /* priority: INT_MAX >= x >= 0 */
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
static int ipmi_init_msghandler(void)
{
int rv;
@@ -4105,7 +4113,8 @@ static int ipmi_init_msghandler(void)
setup_timer(&ipmi_timer, ipmi_timeout, 0);
mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "ipmi_msghandler", NULL);
initialized = 1;
@@ -4125,7 +4134,8 @@ static __exit void cleanup_ipmi(void)
if (!initialized)
return;
- atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &panic_block);
/* This can't be called if any interfaces exist, so no worry about
shutting down the interfaces. */
diff -uprN linux-2.6.23.orig/drivers/char/ipmi/ipmi_watchdog.c linux-2.6.23/drivers/char/ipmi/ipmi_watchdog.c
--- linux-2.6.23.orig/drivers/char/ipmi/ipmi_watchdog.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/char/ipmi/ipmi_watchdog.c 2007-10-18 09:09:20.660000000 +0900
@@ -1055,12 +1055,19 @@ static int wdog_panic_handler(struct not
return NOTIFY_OK;
}
-static struct notifier_block wdog_panic_notifier = {
+static struct notifier_block wdog_panic_notifier_base = {
.notifier_call = wdog_panic_handler,
.next = NULL,
.priority = 150 /* priority: INT_MAX >= x >= 0 */
};
+static struct tunable_atomic_notifier_block wdog_panic_notifier = {
+ .nb = &wdog_panic_notifier_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
static void ipmi_new_smi(int if_num, struct device *device)
{
@@ -1212,8 +1219,8 @@ static int __init ipmi_wdog_init(void)
check_parms();
register_reboot_notifier(&wdog_reboot_notifier);
- atomic_notifier_chain_register(&panic_notifier_list,
- &wdog_panic_notifier);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &wdog_panic_notifier, "ipmi_wdog", NULL);
rv = ipmi_smi_watcher_register(&smi_watcher);
if (rv) {
@@ -1221,8 +1228,8 @@ static int __init ipmi_wdog_init(void)
if (preaction_val == WDOG_PRETIMEOUT_NMI)
release_nmi(&ipmi_nmi_handler);
#endif
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &wdog_panic_notifier);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &wdog_panic_notifier);
unregister_reboot_notifier(&wdog_reboot_notifier);
printk(KERN_WARNING PFX "can't register smi watcher\n");
return rv;
@@ -1243,8 +1250,8 @@ static void __exit ipmi_wdog_exit(void)
release_nmi(&ipmi_nmi_handler);
#endif
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &wdog_panic_notifier);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &wdog_panic_notifier);
unregister_reboot_notifier(&wdog_reboot_notifier);
}
module_exit(ipmi_wdog_exit);
diff -uprN linux-2.6.23.orig/drivers/lguest/lguest.c linux-2.6.23/drivers/lguest/lguest.c
--- linux-2.6.23.orig/drivers/lguest/lguest.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/lguest/lguest.c 2007-10-18 08:56:54.212000000 +0900
@@ -880,16 +880,25 @@ static int lguest_panic(struct notifier_
return NOTIFY_DONE;
}
-static struct notifier_block paniced = {
+static struct notifier_block paniced_base = {
.notifier_call = lguest_panic
};
+static struct tunable_atomic_notifier_block paniced = {
+ .nb = &paniced_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
/* Setting up memory is fairly easy. */
static __init char *lguest_memory_setup(void)
{
/* We do this here and not earlier because lockcheck barfs if we do it
* before start_kernel() */
- atomic_notifier_chain_register(&panic_notifier_list, &paniced);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list, &paniced,
+ "lguest", NULL);
/* The Linux bootloader header contains an "e820" memory map: the
* Launcher populated the first entry with our memory limit. */
diff -uprN linux-2.6.23.orig/drivers/misc/ibmasm/heartbeat.c linux-2.6.23/drivers/misc/ibmasm/heartbeat.c
--- linux-2.6.23.orig/drivers/misc/ibmasm/heartbeat.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/misc/ibmasm/heartbeat.c 2007-10-18 09:11:07.696000000 +0900
@@ -48,17 +48,21 @@ static int panic_happened(struct notifie
return 0;
}
-static struct notifier_block panic_notifier = { panic_happened, NULL, 1 };
+static struct notifier_block panic_notifier_base = { panic_happened, NULL, 1 };
+
+static struct tunable_atomic_notifier_block panic_notifier = { &panic_notifier_base,
+ NULL, NULL, NULL, NULL};
void ibmasm_register_panic_notifier(void)
{
- atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_notifier, "ibmasm", NULL);
}
void ibmasm_unregister_panic_notifier(void)
{
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &panic_notifier);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &panic_notifier);
}
diff -uprN linux-2.6.23.orig/drivers/parisc/power.c linux-2.6.23/drivers/parisc/power.c
--- linux-2.6.23.orig/drivers/parisc/power.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/drivers/parisc/power.c 2007-10-18 09:11:36.880000000 +0900
@@ -189,11 +189,18 @@ static int parisc_panic_event(struct not
return NOTIFY_DONE;
}
-static struct notifier_block parisc_panic_block = {
+static struct notifier_block parisc_panic_block_base = {
.notifier_call = parisc_panic_event,
.priority = INT_MAX,
};
+static struct tunable_atomic_notifier_block parisc_panic_block = {
+ .nb = &parisc_panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
static int __init power_init(void)
{
@@ -231,8 +238,8 @@ static int __init power_init(void)
}
/* Register a call for panic conditions. */
- atomic_notifier_chain_register(&panic_notifier_list,
- &parisc_panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &parisc_panic_block, "parisc_panic", NULL);
return 0;
}
@@ -241,8 +248,8 @@ static void __exit power_exit(void)
{
kthread_stop(power_task);
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &parisc_panic_block);
+ tunable_atomic_notifier_chain_unregister(&panic_notifier_list,
+ &parisc_panic_block);
pdc_soft_power_button(0);
}
diff -uprN linux-2.6.23.orig/include/linux/kernel.h linux-2.6.23/include/linux/kernel.h
--- linux-2.6.23.orig/include/linux/kernel.h 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/include/linux/kernel.h 2007-10-18 08:56:54.216000000 +0900
@@ -104,7 +104,7 @@ extern int cond_resched(void);
(__x < 0) ? -__x : __x; \
})
-extern struct atomic_notifier_head panic_notifier_list;
+extern struct tunable_atomic_notifier_head panic_notifier_list;
extern long (*panic_blink)(long time);
NORET_TYPE void panic(const char * fmt, ...)
__attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
diff -uprN linux-2.6.23.orig/kernel/panic.c linux-2.6.23/kernel/panic.c
--- linux-2.6.23.orig/kernel/panic.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/kernel/panic.c 2007-10-18 09:12:28.188000000 +0900
@@ -28,7 +28,7 @@ static DEFINE_SPINLOCK(pause_on_oops_loc
int panic_timeout;
-ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
+TUNABLE_ATOMIC_NOTIFIER_HEAD(panic_notifier_list, "panic_notifier_list");
EXPORT_SYMBOL(panic_notifier_list);
@@ -96,7 +96,7 @@ NORET_TYPE void panic(const char * fmt,
smp_send_stop();
#endif
- atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
+ tunable_atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
if (!panic_blink)
panic_blink = no_blink;
diff -uprN linux-2.6.23.orig/kernel/softlockup.c linux-2.6.23/kernel/softlockup.c
--- linux-2.6.23.orig/kernel/softlockup.c 2007-10-10 05:31:38.000000000 +0900
+++ linux-2.6.23/kernel/softlockup.c 2007-10-18 09:13:09.260000000 +0900
@@ -31,10 +31,18 @@ softlock_panic(struct notifier_block *th
return NOTIFY_DONE;
}
-static struct notifier_block panic_block = {
+static struct notifier_block panic_block_base = {
.notifier_call = softlock_panic,
};
+static struct tunable_atomic_notifier_block panic_block = {
+ .nb = &panic_block_base,
+ .head = NULL,
+ .dir = NULL,
+ .pri_dentry = NULL,
+ .desc_dentry = NULL
+};
+
/*
* Returns seconds, approximately. We don't need nanosecond
* resolution, and we don't need to waste time with a big divide when
@@ -193,5 +201,6 @@ __init void spawn_softlockup_task(void)
cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
register_cpu_notifier(&cpu_nfb);
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+ tunable_atomic_notifier_chain_register(&panic_notifier_list,
+ &panic_block, "softlockup", NULL);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2
2007-10-18 8:53 ` [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2 Takenori Nagano
@ 2007-10-24 18:11 ` Randy Dunlap
2007-10-25 7:59 ` Takenori Nagano
0 siblings, 1 reply; 8+ messages in thread
From: Randy Dunlap @ 2007-10-24 18:11 UTC (permalink / raw)
To: Takenori Nagano
Cc: linux-kernel, vgoyal, Eric W. Biederman, k-miyoshi, kexec,
Bernhard Walle, Keith Owens, Andrew Morton, kdb
On Thu, 18 Oct 2007 17:53:03 +0900 Takenori Nagano wrote:
> This patch implements new notifier function to panic_notifier_list. We can
> change the list of order by debugfs.
Should be sysfs IMO. debugfs isn't (should not be) required.
> Thanks,
>
> ---
>
> Signed-off-by: Takenori Nagano <t-nagano@ah.jp.nec.com>
>
> ---
> diff -uprN linux-2.6.23.orig/arch/alpha/kernel/setup.c linux-2.6.23/arch/alpha/kernel/setup.c
> --- linux-2.6.23.orig/arch/alpha/kernel/setup.c 2007-10-10 05:31:38.000000000 +0900
> +++ linux-2.6.23/arch/alpha/kernel/setup.c 2007-10-18 08:56:53.928000000 +0900
> @@ -45,14 +45,22 @@
> #include <asm/io.h>
> #include <linux/log2.h>
>
> -extern struct atomic_notifier_head panic_notifier_list;
> +extern struct tunable_atomic_notifier_head panic_notifier_list;
> static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
> -static struct notifier_block alpha_panic_block = {
> +static struct notifier_block alpha_panic_block_base = {
> alpha_panic_event,
> NULL,
> INT_MAX /* try to do it first */
> };
>
> +static struct tunable_atomic_notifier_block alpha_panic_block = {
> + &alpha_panic_block_base,
Use C99-style initializer. and NULLs aren't needed.
> + NULL,
> + NULL,
> + NULL,
> + NULL
> +};
> +
> #include <asm/uaccess.h>
> #include <asm/pgtable.h>
> #include <asm/system.h>
> diff -uprN linux-2.6.23.orig/arch/arm/mach-omap1/board-voiceblue.c linux-2.6.23/arch/arm/mach-omap1/board-voiceblue.c
> --- linux-2.6.23.orig/arch/arm/mach-omap1/board-voiceblue.c 2007-10-10 05:31:38.000000000 +0900
> +++ linux-2.6.23/arch/arm/mach-omap1/board-voiceblue.c 2007-10-18 09:00:35.900000000 +0900
> @@ -228,14 +228,23 @@ static int panic_event(struct notifier_b
> return NOTIFY_DONE;
> }
>
> -static struct notifier_block panic_block = {
> +static struct notifier_block panic_block_base = {
> .notifier_call = panic_event,
> };
>
> +static struct tunable_atomic_notifier_block panic_block = {
> + .nb = &panic_block_base,
> + .head = NULL,
> + .dir = NULL,
> + .pri_dentry = NULL,
> + .desc_dentry = NULL
Drop the NULLs.
> +};
> +
> static int __init voiceblue_setup(void)
> {
> /* Setup panic notifier */
> - notifier_chain_register(&panic_notifier_list, &panic_block);
> + tunable_atomic_notifier_chain_register(&panic_notifier_list,
> + &panic_block, "VoiceBlue", NULL);
>
> return 0;
> }
> diff -uprN linux-2.6.23.orig/arch/mips/sgi-ip22/ip22-reset.c linux-2.6.23/arch/mips/sgi-ip22/ip22-reset.c
> --- linux-2.6.23.orig/arch/mips/sgi-ip22/ip22-reset.c 2007-10-10 05:31:38.000000000 +0900
> +++ linux-2.6.23/arch/mips/sgi-ip22/ip22-reset.c 2007-10-18 09:01:33.408000000 +0900
> @@ -226,10 +226,18 @@ static int panic_event(struct notifier_b
> return NOTIFY_DONE;
> }
>
> -static struct notifier_block panic_block = {
> +static struct notifier_block panic_block_base = {
> .notifier_call = panic_event,
> };
>
> +static struct tunable_atomic_notifier_block panic_block = {
> + .nb = &panic_block_base,
> + .head = NULL,
> + .dir = NULL,
> + .pri_dentry = NULL,
> + .desc_dentry = NULL
Ditto.
> +};
> +
> static int __init reboot_setup(void)
> {
> _machine_restart = sgi_machine_restart;
> diff -uprN linux-2.6.23.orig/arch/mips/sgi-ip32/ip32-reset.c linux-2.6.23/arch/mips/sgi-ip32/ip32-reset.c
> --- linux-2.6.23.orig/arch/mips/sgi-ip32/ip32-reset.c 2007-10-10 05:31:38.000000000 +0900
> +++ linux-2.6.23/arch/mips/sgi-ip32/ip32-reset.c 2007-10-18 09:02:20.496000000 +0900
> @@ -175,10 +175,18 @@ static int panic_event(struct notifier_b
> return NOTIFY_DONE;
> }
>
> -static struct notifier_block panic_block = {
> +static struct notifier_block panic_block_base = {
> .notifier_call = panic_event,
> };
>
> +static struct tunable_atomic_notifier_block panic_block = {
> + .nb = &panic_block_base,
> + .head = NULL,
> + .dir = NULL,
> + .pri_dentry = NULL,
> + .desc_dentry = NULL
Ditto.
> +};
> +
> static __init int ip32_reboot_setup(void)
> {
> /* turn on the green led only */
> diff -uprN linux-2.6.23.orig/arch/parisc/kernel/pdc_chassis.c linux-2.6.23/arch/parisc/kernel/pdc_chassis.c
> --- linux-2.6.23.orig/arch/parisc/kernel/pdc_chassis.c 2007-10-10 05:31:38.000000000 +0900
> +++ linux-2.6.23/arch/parisc/kernel/pdc_chassis.c 2007-10-18 08:56:54.052000000 +0900
> @@ -101,11 +101,18 @@ static int pdc_chassis_panic_event(struc
> }
>
>
> -static struct notifier_block pdc_chassis_panic_block = {
> +static struct notifier_block pdc_chassis_panic_block_base = {
> .notifier_call = pdc_chassis_panic_event,
> .priority = INT_MAX,
> };
>
> +static struct tunable_atomic_notifier_block pdc_chassis_panic_block = {
> + .nb = &pdc_chassis_panic_block_base,
> + .head = NULL,
> + .dir = NULL,
> + .pri_dentry = NULL,
> + .desc_dentry = NULL
Ditto... (I'll skip mentioning the rest of these.)
> +};
>
> /**
> * parisc_reboot_event() - Called by the reboot handler.
---
~Randy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] add tunable_notifier function ,take2
2007-10-18 8:53 ` [PATCH 1/2] add tunable_notifier function ,take2 Takenori Nagano
@ 2007-10-24 18:16 ` Randy Dunlap
2007-10-25 8:02 ` Takenori Nagano
0 siblings, 1 reply; 8+ messages in thread
From: Randy Dunlap @ 2007-10-24 18:16 UTC (permalink / raw)
To: Takenori Nagano
Cc: linux-kernel, vgoyal, Eric W. Biederman, k-miyoshi, kexec,
Bernhard Walle, Keith Owens, Andrew Morton, kdb
On Thu, 18 Oct 2007 17:53:00 +0900 Takenori Nagano wrote:
> This patch adds new notifier function tunable_notifier_chain. Its base is
> atomic_notifier_chain.
>
> Thanks,
>
> ---
>
> Signed-off-by: Takenori Nagano <t-nagano@ah.jp.nec.com>
>
> ---
> diff -uprN linux-2.6.23.orig/kernel/sys.c linux-2.6.23/kernel/sys.c
> --- linux-2.6.23.orig/kernel/sys.c 2007-10-10 05:31:38.000000000 +0900
> +++ linux-2.6.23/kernel/sys.c 2007-10-18 10:08:52.728000000 +0900
> @@ -38,6 +38,7 @@
> #include <linux/syscalls.h>
> #include <linux/kprobes.h>
> #include <linux/user_namespace.h>
> +#include <linux/debugfs.h>
>
> #include <asm/uaccess.h>
> #include <asm/io.h>
> @@ -393,6 +394,243 @@ int blocking_notifier_call_chain(struct
> EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
> +/**
> + * tunable_atomic_notifier_chain_register
> + * - Add notifier to an tunable notifier chain
Function name & short description must be on one (long?) line. :(
> + * @nh: Pointer to head of the tunable notifier chain
> + * @n: New entry in notifier chain
> + * @name: Pointer to the name of the new notifier entry
> + * @desc: Pointer to the description of new entry
> + *
> + * Adds a notifier to an tunable notifier chain and makes control dir.
> + *
> + * Returns zero on success or %-ENODEV on failure.
> + */
> +
> +int tunable_atomic_notifier_chain_register(
> + struct tunable_atomic_notifier_head *nh,
> + struct tunable_atomic_notifier_block *n, char *name, char *desc)
> +{
> +}
> +
> +EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_register);
> +
> +/**
> + * tunable_atomic_notifier_chain_unregister
> + * - Remove notifier from a tunable notifier chain
Ditto.
> + * @nh: Pointer to head of the tunable notifier chain
> + * @n: Entry to remove from notifier chain
> + *
> + * Removes a notifier from a tunable notifier chain.
> + *
> + * Retunrns zero on success or %-ENOENT on failure.
> + */
> +
> +int tunable_atomic_notifier_chain_unregister(
> + struct tunable_atomic_notifier_head *nh,
> + struct tunable_atomic_notifier_block *n)
> +{
> +}
> +
> +EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_unregister);
> +
> +/**
> + * __tunable_atomic_notifier_call_chain
> + * - Call functions in a tunable notifier chain
Same.
> + * @nh: Pointer to head of the tunable notifier chain
> + * @val: Value passed unmodified to notifier function
> + * @v: Pointer passed unmodified to notifier function
> + * @nt_to_call: See the comment for notifier_call_chain
@nr_to_call: ...
> + * @nr_calls: See the comment for notifier_call_chain
> + *
> + * Calls each function in a notifier chain in turn. The functions
> + * run in an atomic context, so they must not block.
> + * This routine uses RCU to synchronize with changes to the chain.
> + *
> + * If the return value of the notifier can be and'ed
> + * with %NOTIFY_STOP_MASK then tunable_atomic_notifier_call_chain()
> + * will return immediately, with the return value of
> + * the notifier function which halted execution.
> + * Otherwise the return value is the return value
> + * of the last notifier function called.
> + */
> +
> +int __kprobes __tunable_atomic_notifier_call_chain(
> + struct tunable_atomic_notifier_head *nh,
> + unsigned long val, void *v,
> + int nr_to_call, int *nr_calls)
> +{
> + int ret;
> +
> + rcu_read_lock();
> + ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls);
> + rcu_read_unlock();
> + return ret;
> +}
> +
> +EXPORT_SYMBOL_GPL(__tunable_atomic_notifier_call_chain);
Blank line is usually omitted before EXPORT_SYMBOL....
---
~Randy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2
2007-10-24 18:11 ` Randy Dunlap
@ 2007-10-25 7:59 ` Takenori Nagano
0 siblings, 0 replies; 8+ messages in thread
From: Takenori Nagano @ 2007-10-25 7:59 UTC (permalink / raw)
To: Randy Dunlap
Cc: linux-kernel, vgoyal, Eric W. Biederman, k-miyoshi, kexec,
Bernhard Walle, Keith Owens, Andrew Morton, kdb
Randy Dunlap wrote:
> On Thu, 18 Oct 2007 17:53:03 +0900 Takenori Nagano wrote:
>
>> This patch implements new notifier function to panic_notifier_list. We can
>> change the list of order by debugfs.
>
> Should be sysfs IMO. debugfs isn't (should not be) required.
OK. We try to find an appropriate place.
http://lkml.org/lkml/2007/10/24/54
>> Thanks,
>>
>> ---
>>
>> Signed-off-by: Takenori Nagano <t-nagano@ah.jp.nec.com>
>>
>> ---
>> diff -uprN linux-2.6.23.orig/arch/alpha/kernel/setup.c linux-2.6.23/arch/alpha/kernel/setup.c
>> --- linux-2.6.23.orig/arch/alpha/kernel/setup.c 2007-10-10 05:31:38.000000000 +0900
>> +++ linux-2.6.23/arch/alpha/kernel/setup.c 2007-10-18 08:56:53.928000000 +0900
>> @@ -45,14 +45,22 @@
>> #include <asm/io.h>
>> #include <linux/log2.h>
>>
>> -extern struct atomic_notifier_head panic_notifier_list;
>> +extern struct tunable_atomic_notifier_head panic_notifier_list;
>> static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
>> -static struct notifier_block alpha_panic_block = {
>> +static struct notifier_block alpha_panic_block_base = {
>> alpha_panic_event,
>> NULL,
>> INT_MAX /* try to do it first */
>> };
>>
>> +static struct tunable_atomic_notifier_block alpha_panic_block = {
>> + &alpha_panic_block_base,
>
> Use C99-style initializer. and NULLs aren't needed.
OK. I'll fix.
Thanks,
Takenori
>
>> + NULL,
>> + NULL,
>> + NULL,
>> + NULL
>> +};
>> +
>> #include <asm/uaccess.h>
>> #include <asm/pgtable.h>
>> #include <asm/system.h>
>
>> diff -uprN linux-2.6.23.orig/arch/arm/mach-omap1/board-voiceblue.c linux-2.6.23/arch/arm/mach-omap1/board-voiceblue.c
>> --- linux-2.6.23.orig/arch/arm/mach-omap1/board-voiceblue.c 2007-10-10 05:31:38.000000000 +0900
>> +++ linux-2.6.23/arch/arm/mach-omap1/board-voiceblue.c 2007-10-18 09:00:35.900000000 +0900
>> @@ -228,14 +228,23 @@ static int panic_event(struct notifier_b
>> return NOTIFY_DONE;
>> }
>>
>> -static struct notifier_block panic_block = {
>> +static struct notifier_block panic_block_base = {
>> .notifier_call = panic_event,
>> };
>>
>> +static struct tunable_atomic_notifier_block panic_block = {
>> + .nb = &panic_block_base,
>> + .head = NULL,
>> + .dir = NULL,
>> + .pri_dentry = NULL,
>> + .desc_dentry = NULL
>
> Drop the NULLs.
>
>> +};
>> +
>> static int __init voiceblue_setup(void)
>> {
>> /* Setup panic notifier */
>> - notifier_chain_register(&panic_notifier_list, &panic_block);
>> + tunable_atomic_notifier_chain_register(&panic_notifier_list,
>> + &panic_block, "VoiceBlue", NULL);
>>
>> return 0;
>> }
>> diff -uprN linux-2.6.23.orig/arch/mips/sgi-ip22/ip22-reset.c linux-2.6.23/arch/mips/sgi-ip22/ip22-reset.c
>> --- linux-2.6.23.orig/arch/mips/sgi-ip22/ip22-reset.c 2007-10-10 05:31:38.000000000 +0900
>> +++ linux-2.6.23/arch/mips/sgi-ip22/ip22-reset.c 2007-10-18 09:01:33.408000000 +0900
>> @@ -226,10 +226,18 @@ static int panic_event(struct notifier_b
>> return NOTIFY_DONE;
>> }
>>
>> -static struct notifier_block panic_block = {
>> +static struct notifier_block panic_block_base = {
>> .notifier_call = panic_event,
>> };
>>
>> +static struct tunable_atomic_notifier_block panic_block = {
>> + .nb = &panic_block_base,
>> + .head = NULL,
>> + .dir = NULL,
>> + .pri_dentry = NULL,
>> + .desc_dentry = NULL
>
> Ditto.
>
>> +};
>> +
>> static int __init reboot_setup(void)
>> {
>> _machine_restart = sgi_machine_restart;
>
>> diff -uprN linux-2.6.23.orig/arch/mips/sgi-ip32/ip32-reset.c linux-2.6.23/arch/mips/sgi-ip32/ip32-reset.c
>> --- linux-2.6.23.orig/arch/mips/sgi-ip32/ip32-reset.c 2007-10-10 05:31:38.000000000 +0900
>> +++ linux-2.6.23/arch/mips/sgi-ip32/ip32-reset.c 2007-10-18 09:02:20.496000000 +0900
>> @@ -175,10 +175,18 @@ static int panic_event(struct notifier_b
>> return NOTIFY_DONE;
>> }
>>
>> -static struct notifier_block panic_block = {
>> +static struct notifier_block panic_block_base = {
>> .notifier_call = panic_event,
>> };
>>
>> +static struct tunable_atomic_notifier_block panic_block = {
>> + .nb = &panic_block_base,
>> + .head = NULL,
>> + .dir = NULL,
>> + .pri_dentry = NULL,
>> + .desc_dentry = NULL
>
> Ditto.
>
>> +};
>> +
>> static __init int ip32_reboot_setup(void)
>> {
>> /* turn on the green led only */
>
>> diff -uprN linux-2.6.23.orig/arch/parisc/kernel/pdc_chassis.c linux-2.6.23/arch/parisc/kernel/pdc_chassis.c
>> --- linux-2.6.23.orig/arch/parisc/kernel/pdc_chassis.c 2007-10-10 05:31:38.000000000 +0900
>> +++ linux-2.6.23/arch/parisc/kernel/pdc_chassis.c 2007-10-18 08:56:54.052000000 +0900
>> @@ -101,11 +101,18 @@ static int pdc_chassis_panic_event(struc
>> }
>>
>>
>> -static struct notifier_block pdc_chassis_panic_block = {
>> +static struct notifier_block pdc_chassis_panic_block_base = {
>> .notifier_call = pdc_chassis_panic_event,
>> .priority = INT_MAX,
>> };
>>
>> +static struct tunable_atomic_notifier_block pdc_chassis_panic_block = {
>> + .nb = &pdc_chassis_panic_block_base,
>> + .head = NULL,
>> + .dir = NULL,
>> + .pri_dentry = NULL,
>> + .desc_dentry = NULL
>
> Ditto... (I'll skip mentioning the rest of these.)
>
>> +};
>>
>> /**
>> * parisc_reboot_event() - Called by the reboot handler.
>
>
> ---
> ~Randy
>
>
--
+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+
NEC コンピュータソフトウェア事業本部
OSSプラットフォーム開発本部
永野 武則 (Takenori Nagano)
TEL:8-23-57270(MyLine) 042-333-5383(外線)
e-mail:t-nagano@ah.jp.nec.com
+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] add tunable_notifier function ,take2
2007-10-24 18:16 ` Randy Dunlap
@ 2007-10-25 8:02 ` Takenori Nagano
0 siblings, 0 replies; 8+ messages in thread
From: Takenori Nagano @ 2007-10-25 8:02 UTC (permalink / raw)
To: Randy Dunlap
Cc: linux-kernel, vgoyal, Eric W. Biederman, k-miyoshi, kexec,
Bernhard Walle, Keith Owens, Andrew Morton, kdb
Randy Dunlap wrote:
> On Thu, 18 Oct 2007 17:53:00 +0900 Takenori Nagano wrote:
>
>> This patch adds new notifier function tunable_notifier_chain. Its base is
>> atomic_notifier_chain.
>>
>> Thanks,
>>
>> ---
>>
>> Signed-off-by: Takenori Nagano <t-nagano@ah.jp.nec.com>
>>
>> ---
>> diff -uprN linux-2.6.23.orig/kernel/sys.c linux-2.6.23/kernel/sys.c
>> --- linux-2.6.23.orig/kernel/sys.c 2007-10-10 05:31:38.000000000 +0900
>> +++ linux-2.6.23/kernel/sys.c 2007-10-18 10:08:52.728000000 +0900
>> @@ -38,6 +38,7 @@
>> #include <linux/syscalls.h>
>> #include <linux/kprobes.h>
>> #include <linux/user_namespace.h>
>> +#include <linux/debugfs.h>
>>
>> #include <asm/uaccess.h>
>> #include <asm/io.h>
>> @@ -393,6 +394,243 @@ int blocking_notifier_call_chain(struct
>> EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
>
>> +/**
>> + * tunable_atomic_notifier_chain_register
>> + * - Add notifier to an tunable notifier chain
>
> Function name & short description must be on one (long?) line. :(
OK. I'll fix next version.
>> +
>> +int __kprobes __tunable_atomic_notifier_call_chain(
>> + struct tunable_atomic_notifier_head *nh,
>> + unsigned long val, void *v,
>> + int nr_to_call, int *nr_calls)
>> +{
>> + int ret;
>> +
>> + rcu_read_lock();
>> + ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls);
>> + rcu_read_unlock();
>> + return ret;
>> +}
>> +
>> +EXPORT_SYMBOL_GPL(__tunable_atomic_notifier_call_chain);
>
> Blank line is usually omitted before EXPORT_SYMBOL....
OK. I'll fix, too.
Thanks,
Takenori
> ---
> ~Randy
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-10-25 8:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <4716FFDB.7090502@ah.jp.nec.com>
2007-10-18 6:45 ` [PATCH 1/2] add tunable_notifier function ,take2 Takenori Nagano
2007-10-18 6:45 ` [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2 Takenori Nagano
2007-10-18 8:53 ` [PATCH 1/2] add tunable_notifier function ,take2 Takenori Nagano
2007-10-24 18:16 ` Randy Dunlap
2007-10-25 8:02 ` Takenori Nagano
2007-10-18 8:53 ` [PATCH 2/2] implement new notifier function to panic_notifier_list ,take2 Takenori Nagano
2007-10-24 18:11 ` Randy Dunlap
2007-10-25 7:59 ` Takenori Nagano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox