public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail()
@ 2010-03-18  9:05 Akinobu Mita
  2010-03-18  9:05 ` [PATCH 02/12] cpu-hotplug: return better errno on cpu hotplug failure Akinobu Mita
                   ` (10 more replies)
  0 siblings, 11 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Rusty Russell

No functional change.
These are just wrappers of raw_cpu_notifier_call_chain.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
---
 kernel/cpu.c |   55 ++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index f8cced2..bc9c301 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -133,6 +133,26 @@ int __ref register_cpu_notifier(struct notifier_block *nb)
 	return ret;
 }
 
+static int __cpu_notify(unsigned long val, void *v, int nr_to_call,
+			int *nr_calls)
+{
+	return __raw_notifier_call_chain(&cpu_chain, val, v, nr_to_call,
+					nr_calls);
+}
+
+static int cpu_notify(unsigned long val, void *v)
+{
+	return __cpu_notify(val, v, -1, NULL);
+}
+
+static void cpu_notify_nofail(unsigned long val, void *v)
+{
+	int err;
+
+	err = cpu_notify(val, v);
+	BUG_ON(err == NOTIFY_BAD);
+}
+
 #ifdef CONFIG_HOTPLUG_CPU
 
 EXPORT_SYMBOL(register_cpu_notifier);
@@ -178,8 +198,7 @@ static int __ref take_cpu_down(void *_param)
 	if (err < 0)
 		return err;
 
-	raw_notifier_call_chain(&cpu_chain, CPU_DYING | param->mod,
-				param->hcpu);
+	cpu_notify(CPU_DYING | param->mod, param->hcpu);
 
 	/* Force idle task to run as soon as we yield: it should
 	   immediately notice cpu is offline and die quickly. */
@@ -210,14 +229,12 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
 
 	cpu_hotplug_begin();
 	set_cpu_active(cpu, false);
-	err = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod,
-					hcpu, -1, &nr_calls);
+	err = __cpu_notify(CPU_DOWN_PREPARE | mod, hcpu, -1, &nr_calls);
 	if (err == NOTIFY_BAD) {
 		set_cpu_active(cpu, true);
 
 		nr_calls--;
-		__raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod,
-					  hcpu, nr_calls, NULL);
+		__cpu_notify(CPU_DOWN_FAILED | mod, hcpu, nr_calls, NULL);
 		printk("%s: attempt to take down CPU %u failed\n",
 				__func__, cpu);
 		err = -EINVAL;
@@ -232,9 +249,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
 	if (err) {
 		set_cpu_active(cpu, true);
 		/* CPU didn't die: tell everyone.  Can't complain. */
-		if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod,
-					    hcpu) == NOTIFY_BAD)
-			BUG();
+		cpu_notify_nofail(CPU_DOWN_FAILED | mod, hcpu);
 
 		goto out_allowed;
 	}
@@ -248,9 +263,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
 	__cpu_die(cpu);
 
 	/* CPU is completely dead: tell everyone.  Too late to complain. */
-	if (raw_notifier_call_chain(&cpu_chain, CPU_DEAD | mod,
-				    hcpu) == NOTIFY_BAD)
-		BUG();
+	cpu_notify_nofail(CPU_DEAD | mod, hcpu);
 
 	check_for_tasks(cpu);
 
@@ -258,11 +271,9 @@ out_allowed:
 	set_cpus_allowed_ptr(current, old_allowed);
 out_release:
 	cpu_hotplug_done();
-	if (!err) {
-		if (raw_notifier_call_chain(&cpu_chain, CPU_POST_DEAD | mod,
-					    hcpu) == NOTIFY_BAD)
-			BUG();
-	}
+	if (!err)
+		cpu_notify_nofail(CPU_POST_DEAD | mod, hcpu);
+
 	free_cpumask_var(old_allowed);
 	return err;
 }
@@ -302,8 +313,7 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
 		return -EINVAL;
 
 	cpu_hotplug_begin();
-	ret = __raw_notifier_call_chain(&cpu_chain, CPU_UP_PREPARE | mod, hcpu,
-							-1, &nr_calls);
+	ret = __cpu_notify(CPU_UP_PREPARE | mod, hcpu, -1, &nr_calls);
 	if (ret == NOTIFY_BAD) {
 		nr_calls--;
 		printk("%s: attempt to bring up CPU %u failed\n",
@@ -321,12 +331,11 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
 	set_cpu_active(cpu, true);
 
 	/* Now call notifier in preparation. */
-	raw_notifier_call_chain(&cpu_chain, CPU_ONLINE | mod, hcpu);
+	cpu_notify(CPU_ONLINE | mod, hcpu);
 
 out_notify:
 	if (ret != 0)
-		__raw_notifier_call_chain(&cpu_chain,
-				CPU_UP_CANCELED | mod, hcpu, nr_calls, NULL);
+		__cpu_notify(CPU_UP_CANCELED | mod, hcpu, nr_calls, NULL);
 	cpu_hotplug_done();
 
 	return ret;
@@ -466,7 +475,7 @@ void __cpuinit notify_cpu_starting(unsigned int cpu)
 	if (frozen_cpus != NULL && cpumask_test_cpu(cpu, frozen_cpus))
 		val = CPU_STARTING_FROZEN;
 #endif /* CONFIG_PM_SLEEP_SMP */
-	raw_notifier_call_chain(&cpu_chain, val, (void *)(long)cpu);
+	cpu_notify(val, (void *)(long)cpu);
 }
 
 #endif /* CONFIG_SMP */
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/12] cpu-hotplug: return better errno on cpu hotplug failure
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18  9:05 ` [PATCH 03/12] notifier: change notifier_from_errno(0) to return NOTIFY_OK Akinobu Mita
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Rusty Russell

Currently, onlining or offlining a CPU failure by one of the cpu
notifiers error always cause -EINVAL error.
(i.e. writing 0 or 1 to /sys/devices/system/cpu/cpuX/online gets EINVAL)

To get better error reporting rather than always getting -EINVAL,
This changes cpu_notify() to return -errno value with notifier_to_errno() and
fix the callers. Now that cpu notifiers can return encapsulate errno value.

Currently, all cpu hotplug notifiers return NOTIFY_OK, NOTIFY_BAD,
or NOTIFY_DONE. So cpu_notify() can returns 0 or -EPERM with this change
for now.
(notifier_to_errno(NOTIFY_OK) == 0, notifier_to_errno(NOTIFY_DONE) == 0,
notifier_to_errno(NOTIFY_BAD) == -EPERM)

Forthcoming patches convert several cpu notifiers to return encapsulate
errno value with notifier_from_errno().

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
---
 kernel/cpu.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index bc9c301..d3f335e 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -136,8 +136,12 @@ int __ref register_cpu_notifier(struct notifier_block *nb)
 static int __cpu_notify(unsigned long val, void *v, int nr_to_call,
 			int *nr_calls)
 {
-	return __raw_notifier_call_chain(&cpu_chain, val, v, nr_to_call,
+	int ret;
+
+	ret = __raw_notifier_call_chain(&cpu_chain, val, v, nr_to_call,
 					nr_calls);
+
+	return notifier_to_errno(ret);
 }
 
 static int cpu_notify(unsigned long val, void *v)
@@ -150,7 +154,7 @@ static void cpu_notify_nofail(unsigned long val, void *v)
 	int err;
 
 	err = cpu_notify(val, v);
-	BUG_ON(err == NOTIFY_BAD);
+	BUG_ON(err);
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -230,14 +234,13 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
 	cpu_hotplug_begin();
 	set_cpu_active(cpu, false);
 	err = __cpu_notify(CPU_DOWN_PREPARE | mod, hcpu, -1, &nr_calls);
-	if (err == NOTIFY_BAD) {
+	if (err) {
 		set_cpu_active(cpu, true);
 
 		nr_calls--;
 		__cpu_notify(CPU_DOWN_FAILED | mod, hcpu, nr_calls, NULL);
 		printk("%s: attempt to take down CPU %u failed\n",
 				__func__, cpu);
-		err = -EINVAL;
 		goto out_release;
 	}
 
@@ -314,11 +317,10 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
 
 	cpu_hotplug_begin();
 	ret = __cpu_notify(CPU_UP_PREPARE | mod, hcpu, -1, &nr_calls);
-	if (ret == NOTIFY_BAD) {
+	if (ret) {
 		nr_calls--;
 		printk("%s: attempt to bring up CPU %u failed\n",
 				__func__, cpu);
-		ret = -EINVAL;
 		goto out_notify;
 	}
 
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/12] notifier: change notifier_from_errno(0) to return NOTIFY_OK
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
  2010-03-18  9:05 ` [PATCH 02/12] cpu-hotplug: return better errno on cpu hotplug failure Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18  9:05 ` [PATCH 04/12] x86: convert cpu notifier to return encapsulate errno value Akinobu Mita
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita

This changes notifier_from_errno(0) to be NOTIFY_OK instead of
NOTIFY_STOP_MASK | NOTIFY_OK.

Currently, the notifiers which return encapsulated errno value have to
do something like this:

	err = do_something(); // returns -errno
	if (err)
		return notifier_from_errno(err);
	else
		return NOTIFY_OK;

This change makes the above code simple:

	err = do_something(); // returns -errno

	return return notifier_from_errno(err);

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 include/linux/notifier.h |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index fee6c2f..9e4831d 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -164,7 +164,10 @@ extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
 /* Encapsulate (negative) errno value (in particular, NOTIFY_BAD <=> EPERM). */
 static inline int notifier_from_errno(int err)
 {
-	return NOTIFY_STOP_MASK | (NOTIFY_OK - err);
+	if (err)
+		return NOTIFY_STOP_MASK | (NOTIFY_OK - err);
+
+	return NOTIFY_OK;
 }
 
 /* Restore (negative) errno value from notify return value. */
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/12] x86: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
  2010-03-18  9:05 ` [PATCH 02/12] cpu-hotplug: return better errno on cpu hotplug failure Akinobu Mita
  2010-03-18  9:05 ` [PATCH 03/12] notifier: change notifier_from_errno(0) to return NOTIFY_OK Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18  9:05 ` [PATCH 05/12] topology: " Akinobu Mita
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86

By the previous modification, the cpu notifier can return encapsulate
errno value. This converts the cpu notifiers for msr, cpuid, and
therm_throt.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/kernel/cpu/mcheck/therm_throt.c |    2 +-
 arch/x86/kernel/cpuid.c                  |    2 +-
 arch/x86/kernel/msr.c                    |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index 81c499e..e1a0a3b 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -190,7 +190,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
 		mutex_unlock(&therm_cpu_lock);
 		break;
 	}
-	return err ? NOTIFY_BAD : NOTIFY_OK;
+	return notifier_from_errno(err);
 }
 
 static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 83e5e62..caf11b5 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -169,7 +169,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
 		cpuid_device_destroy(cpu);
 		break;
 	}
-	return err ? NOTIFY_BAD : NOTIFY_OK;
+	return notifier_from_errno(err);
 }
 
 static struct notifier_block __refdata cpuid_class_cpu_notifier =
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 206735a..823081b 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -229,7 +229,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
 		msr_device_destroy(cpu);
 		break;
 	}
-	return err ? NOTIFY_BAD : NOTIFY_OK;
+	return notifier_from_errno(err);
 }
 
 static struct notifier_block __refdata msr_class_cpu_notifier = {
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/12] topology: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
                   ` (2 preceding siblings ...)
  2010-03-18  9:05 ` [PATCH 04/12] x86: convert cpu notifier to return encapsulate errno value Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18  9:05 ` [PATCH 06/12] kernel/: " Akinobu Mita
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Greg Kroah-Hartman

By the previous modification, the cpu notifier can return encapsulate
errno value. This converts the cpu notifiers for topology.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/topology.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index bf6b132..9fc630c 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -162,7 +162,7 @@ static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
 		topology_remove_dev(cpu);
 		break;
 	}
-	return rc ? NOTIFY_BAD : NOTIFY_OK;
+	return notifier_from_errno(rc);
 }
 
 static int __cpuinit topology_sysfs_init(void)
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/12] kernel/: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
                   ` (3 preceding siblings ...)
  2010-03-18  9:05 ` [PATCH 05/12] topology: " Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18  9:05 ` [PATCH 07/12] slab: " Akinobu Mita
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Ingo Molnar, Peter Zijlstra

By the previous modification, the cpu notifier can return encapsulate
errno value. This converts the cpu notifiers for kernel/*.c

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 kernel/padata.c     |    4 ++--
 kernel/profile.c    |    4 ++--
 kernel/relay.c      |    2 +-
 kernel/sched.c      |    2 +-
 kernel/smp.c        |    2 +-
 kernel/softirq.c    |    2 +-
 kernel/softlockup.c |    2 +-
 kernel/timer.c      |    7 +++++--
 kernel/workqueue.c  |    9 +++++----
 9 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/kernel/padata.c b/kernel/padata.c
index 93caf65..c610d12 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -587,7 +587,7 @@ static int __cpuinit padata_cpu_callback(struct notifier_block *nfb,
 		err = __padata_add_cpu(pinst, cpu);
 		mutex_unlock(&pinst->lock);
 		if (err)
-			return NOTIFY_BAD;
+			return notifier_from_errno(err);
 		break;
 
 	case CPU_DOWN_PREPARE:
@@ -598,7 +598,7 @@ static int __cpuinit padata_cpu_callback(struct notifier_block *nfb,
 		err = __padata_remove_cpu(pinst, cpu);
 		mutex_unlock(&pinst->lock);
 		if (err)
-			return NOTIFY_BAD;
+			return notifier_from_errno(err);
 		break;
 
 	case CPU_UP_CANCELED:
diff --git a/kernel/profile.c b/kernel/profile.c
index a55d3a3..cbf2677 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -370,7 +370,7 @@ static int __cpuinit profile_cpu_callback(struct notifier_block *info,
 					GFP_KERNEL | __GFP_ZERO,
 					0);
 			if (!page)
-				return NOTIFY_BAD;
+				return notifier_from_errno(-ENOMEM);
 			per_cpu(cpu_profile_hits, cpu)[1] = page_address(page);
 		}
 		if (!per_cpu(cpu_profile_hits, cpu)[0]) {
@@ -386,7 +386,7 @@ out_free:
 		page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
 		per_cpu(cpu_profile_hits, cpu)[1] = NULL;
 		__free_page(page);
-		return NOTIFY_BAD;
+		return notifier_from_errno(-ENOMEM);
 	case CPU_ONLINE:
 	case CPU_ONLINE_FROZEN:
 		if (prof_cpu_mask != NULL)
diff --git a/kernel/relay.c b/kernel/relay.c
index 3d97f28..29714bf 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -539,7 +539,7 @@ static int __cpuinit relay_hotcpu_callback(struct notifier_block *nb,
 					"relay_hotcpu_callback: cpu %d buffer "
 					"creation failed\n", hotcpu);
 				mutex_unlock(&relay_channels_mutex);
-				return NOTIFY_BAD;
+				return notifier_from_errno(-ENOMEM);
 			}
 		}
 		mutex_unlock(&relay_channels_mutex);
diff --git a/kernel/sched.c b/kernel/sched.c
index c61e58a..873b9d1 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5887,7 +5887,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
 	case CPU_UP_PREPARE_FROZEN:
 		p = kthread_create(migration_thread, hcpu, "migration/%d", cpu);
 		if (IS_ERR(p))
-			return NOTIFY_BAD;
+			return notifier_from_errno(PTR_ERR(p));
 		kthread_bind(p, cpu);
 		/* Must be high prio: stop_machine expects to yield to it. */
 		rq = task_rq_lock(p, &flags);
diff --git a/kernel/smp.c b/kernel/smp.c
index 9867b6b..cb2a6c6 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -51,7 +51,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
 	case CPU_UP_PREPARE_FROZEN:
 		if (!zalloc_cpumask_var_node(&cfd->cpumask, GFP_KERNEL,
 				cpu_to_node(cpu)))
-			return NOTIFY_BAD;
+			return notifier_from_errno(-ENOMEM);
 		break;
 
 #ifdef CONFIG_HOTPLUG_CPU
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 7c1a67e..2ca2323 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -808,7 +808,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
 		p = kthread_create(run_ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
 		if (IS_ERR(p)) {
 			printk("ksoftirqd for %i failed\n", hotcpu);
-			return NOTIFY_BAD;
+			return notifier_from_errno(PTR_ERR(p));
 		}
 		kthread_bind(p, hotcpu);
   		per_cpu(ksoftirqd, hotcpu) = p;
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index 0d4c789..46af4c5 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -228,7 +228,7 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 		p = kthread_create(watchdog, hcpu, "watchdog/%d", hotcpu);
 		if (IS_ERR(p)) {
 			printk(KERN_ERR "watchdog for %i failed\n", hotcpu);
-			return NOTIFY_BAD;
+			return notifier_from_errno(PTR_ERR(p));
 		}
 		per_cpu(softlockup_touch_ts, hotcpu) = 0;
 		per_cpu(softlockup_watchdog, hotcpu) = p;
diff --git a/kernel/timer.c b/kernel/timer.c
index c61a794..bc7e930 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1618,11 +1618,14 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
 				unsigned long action, void *hcpu)
 {
 	long cpu = (long)hcpu;
+	int err;
+
 	switch(action) {
 	case CPU_UP_PREPARE:
 	case CPU_UP_PREPARE_FROZEN:
-		if (init_timers_cpu(cpu) < 0)
-			return NOTIFY_BAD;
+		err = init_timers_cpu(cpu);
+		if (err < 0)
+			return notifier_from_errno(err);
 		break;
 #ifdef CONFIG_HOTPLUG_CPU
 	case CPU_DEAD:
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index dee4865..5aa45a0 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1076,7 +1076,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
 	unsigned int cpu = (unsigned long)hcpu;
 	struct cpu_workqueue_struct *cwq;
 	struct workqueue_struct *wq;
-	int ret = NOTIFY_OK;
+	int err = 0;
 
 	action &= ~CPU_TASKS_FROZEN;
 
@@ -1090,12 +1090,13 @@ undo:
 
 		switch (action) {
 		case CPU_UP_PREPARE:
-			if (!create_workqueue_thread(cwq, cpu))
+			err = create_workqueue_thread(cwq, cpu);
+			if (!err)
 				break;
 			printk(KERN_ERR "workqueue [%s] for %i failed\n",
 				wq->name, cpu);
 			action = CPU_UP_CANCELED;
-			ret = NOTIFY_BAD;
+			err = -ENOMEM;
 			goto undo;
 
 		case CPU_ONLINE:
@@ -1116,7 +1117,7 @@ undo:
 		cpumask_clear_cpu(cpu, cpu_populated_map);
 	}
 
-	return ret;
+	return notifier_from_errno(err);
 }
 
 #ifdef CONFIG_SMP
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/12] slab: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
                   ` (4 preceding siblings ...)
  2010-03-18  9:05 ` [PATCH 06/12] kernel/: " Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18 17:21   ` Pekka Enberg
  2010-03-18  9:05 ` [PATCH 08/12] iucv: " Akinobu Mita
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, Christoph Lameter, Pekka Enberg, Matt Mackall,
	linux-mm

By the previous modification, the cpu notifier can return encapsulate
errno value. This converts the cpu notifiers for slab.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Matt Mackall <mpm@selenic.com>
Cc: linux-mm@kvack.org
---
 mm/slab.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index a9f325b..d57309e 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1324,7 +1324,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
 		mutex_unlock(&cache_chain_mutex);
 		break;
 	}
-	return err ? NOTIFY_BAD : NOTIFY_OK;
+	return notifier_from_errno(err);
 }
 
 static struct notifier_block __cpuinitdata cpucache_notifier = {
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/12] iucv: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
                   ` (5 preceding siblings ...)
  2010-03-18  9:05 ` [PATCH 07/12] slab: " Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18  9:05 ` [PATCH 09/12] ehca: " Akinobu Mita
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Ursula Braun, linux390, linux-s390

By the previous modification, the cpu notifier can return encapsulate
errno value. This converts the cpu notifiers for iucv.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Ursula Braun <ursula.braun@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
 net/iucv/iucv.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index fd8b283..f28ad2c 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -632,13 +632,14 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
 		iucv_irq_data[cpu] = kmalloc_node(sizeof(struct iucv_irq_data),
 					GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
 		if (!iucv_irq_data[cpu])
-			return NOTIFY_BAD;
+			return notifier_from_errno(-ENOMEM);
+
 		iucv_param[cpu] = kmalloc_node(sizeof(union iucv_param),
 				     GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
 		if (!iucv_param[cpu]) {
 			kfree(iucv_irq_data[cpu]);
 			iucv_irq_data[cpu] = NULL;
-			return NOTIFY_BAD;
+			return notifier_from_errno(-ENOMEM);
 		}
 		iucv_param_irq[cpu] = kmalloc_node(sizeof(union iucv_param),
 					GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
@@ -647,7 +648,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
 			iucv_param[cpu] = NULL;
 			kfree(iucv_irq_data[cpu]);
 			iucv_irq_data[cpu] = NULL;
-			return NOTIFY_BAD;
+			return notifier_from_errno(-ENOMEM);
 		}
 		break;
 	case CPU_UP_CANCELED:
@@ -677,7 +678,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
 		cpu_clear(cpu, cpumask);
 		if (cpus_empty(cpumask))
 			/* Can't offline last IUCV enabled cpu. */
-			return NOTIFY_BAD;
+			return notifier_from_errno(-EINVAL);
 		smp_call_function_single(cpu, iucv_retrieve_cpu, NULL, 1);
 		if (cpus_empty(iucv_irq_cpumask))
 			smp_call_function_single(first_cpu(iucv_buffer_cpumask),
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/12] ehca: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
                   ` (6 preceding siblings ...)
  2010-03-18  9:05 ` [PATCH 08/12] iucv: " Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-29  8:47   ` Alexander Schmidt
  2010-03-18  9:05 ` [PATCH 10/12] s390: " Akinobu Mita
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, Hoang-Nam Nguyen, Christoph Raisch, linux-rdma

By the previous modification, the cpu notifier can return encapsulate
errno value. This converts the cpu notifiers for ehca.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Hoang-Nam Nguyen <hnguyen@de.ibm.com>
Cc: Christoph Raisch <raisch@de.ibm.com>
Cc: linux-rdma@vger.kernel.org
---
 drivers/infiniband/hw/ehca/ehca_irq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index b2b6fea..31f3ee1 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -845,7 +845,7 @@ static int __cpuinit comp_pool_callback(struct notifier_block *nfb,
 		ehca_gen_dbg("CPU: %x (CPU_PREPARE)", cpu);
 		if (!create_comp_task(pool, cpu)) {
 			ehca_gen_err("Can't create comp_task for cpu: %x", cpu);
-			return NOTIFY_BAD;
+			return notifier_from_errno(-ENOMEM);
 		}
 		break;
 	case CPU_UP_CANCELED:
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/12] s390: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
                   ` (7 preceding siblings ...)
  2010-03-18  9:05 ` [PATCH 09/12] ehca: " Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18  9:05 ` [PATCH 11/12] md: " Akinobu Mita
  2010-03-18  9:05 ` [PATCH 12/12] add CPU notifier error injection module Akinobu Mita
  10 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, Martin Schwidefsky, Heiko Carstens, linux390,
	linux-s390

By the previous modification, the cpu notifier can return encapsulate
errno value. This converts the cpu notifiers for s390.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
 arch/s390/kernel/smp.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 29f65bc..5c5ba7b 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -943,21 +943,21 @@ static int __cpuinit smp_cpu_notify(struct notifier_block *self,
 	struct cpu *c = &per_cpu(cpu_devices, cpu);
 	struct sys_device *s = &c->sysdev;
 	struct s390_idle_data *idle;
+	int err = 0;
 
 	switch (action) {
 	case CPU_ONLINE:
 	case CPU_ONLINE_FROZEN:
 		idle = &per_cpu(s390_idle, cpu);
 		memset(idle, 0, sizeof(struct s390_idle_data));
-		if (sysfs_create_group(&s->kobj, &cpu_online_attr_group))
-			return NOTIFY_BAD;
+		err = sysfs_create_group(&s->kobj, &cpu_online_attr_group);
 		break;
 	case CPU_DEAD:
 	case CPU_DEAD_FROZEN:
 		sysfs_remove_group(&s->kobj, &cpu_online_attr_group);
 		break;
 	}
-	return NOTIFY_OK;
+	return notifier_from_errno(err);
 }
 
 static struct notifier_block __cpuinitdata smp_cpu_nb = {
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 11/12] md: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
                   ` (8 preceding siblings ...)
  2010-03-18  9:05 ` [PATCH 10/12] s390: " Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-18  9:05 ` [PATCH 12/12] add CPU notifier error injection module Akinobu Mita
  10 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Neil Brown, linux-raid

By the previous modification, the cpu notifier can return encapsulate
errno value. This converts the cpu notifiers for raid5.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Neil Brown <neilb@suse.de>
Cc: linux-raid@vger.kernel.org
---
 drivers/md/raid5.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 70ffbd0..a711ba3 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4659,7 +4659,7 @@ static int raid456_cpu_notify(struct notifier_block *nfb, unsigned long action,
 			kfree(percpu->scribble);
 			pr_err("%s: failed memory allocation for cpu%ld\n",
 			       __func__, cpu);
-			return NOTIFY_BAD;
+			return notifier_from_errno(-ENOMEM);
 		}
 		break;
 	case CPU_DEAD:
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 12/12] add CPU notifier error injection module
  2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
                   ` (9 preceding siblings ...)
  2010-03-18  9:05 ` [PATCH 11/12] md: " Akinobu Mita
@ 2010-03-18  9:05 ` Akinobu Mita
  2010-03-22 21:48   ` Andrew Morton
  10 siblings, 1 reply; 16+ messages in thread
From: Akinobu Mita @ 2010-03-18  9:05 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita

I used this module to test the series of modification to the
cpu notifiers code.

Example1: inject CPU offline error (-1 == -EPERM)

	# modprobe cpu-notifier-error-inject cpu_down_prepare_error=-1
	# echo 0 > /sys/devices/system/cpu/cpu1/online0
	bash: echo: write error: Operation not permitted

Example2: inject CPU online error (-2 == -ENOENT)

	# modprobe cpu-notifier-error-inject cpu_up_prepare_error=-2
	# echo 1 > /sys/devices/system/cpu/cpu1/online0
	bash: echo: write error: No such file or directory

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 lib/Kconfig.debug               |   12 +++++++
 lib/Makefile                    |    1 +
 lib/cpu-notifier-error-inject.c |   63 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+), 0 deletions(-)
 create mode 100644 lib/cpu-notifier-error-inject.c

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 8e5ec5e..ae467ed 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -885,6 +885,18 @@ config LKDTM
 	Documentation on how to use the module can be found in
 	Documentation/fault-injection/provoke-crashes.txt
 
+config CPU_NOTIFIER_ERROR_INJECT
+	tristate "CPU notifier error injection module"
+	depends on HOTPLUG_CPU && DEBUG_KERNEL
+	help
+	  This option provides a kernel module that can be used to test
+	  the error handling of the cpu notifiers
+
+	  To compile this code as a module, choose M here: the module will
+	  be called cpu-notify-inject.
+
+	  If unsure, say N.
+
 config FAULT_INJECTION
 	bool "Fault-injection framework"
 	depends on DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index 2e152ae..9e34be2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -82,6 +82,7 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o
 obj-$(CONFIG_SWIOTLB) += swiotlb.o
 obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o
 obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
+obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o
 
 lib-$(CONFIG_GENERIC_BUG) += bug.o
 
diff --git a/lib/cpu-notifier-error-inject.c b/lib/cpu-notifier-error-inject.c
new file mode 100644
index 0000000..4dc2032
--- /dev/null
+++ b/lib/cpu-notifier-error-inject.c
@@ -0,0 +1,63 @@
+#include <linux/kernel.h>
+#include <linux/cpu.h>
+#include <linux/module.h>
+#include <linux/notifier.h>
+
+static int priority;
+static int cpu_up_prepare_error;
+static int cpu_down_prepare_error;
+
+module_param(priority, int, 0);
+MODULE_PARM_DESC(priority, "specify cpu notifier priority");
+
+module_param(cpu_up_prepare_error, int, 0644);
+MODULE_PARM_DESC(cpu_up_prepare_error,
+		"specify error code to inject CPU_UP_PREPARE action");
+
+module_param(cpu_down_prepare_error, int, 0644);
+MODULE_PARM_DESC(cpu_down_prepare_error,
+		"specify error code to inject CPU_DOWN_PREPARE action");
+
+static int err_inject_cpu_callback(struct notifier_block *nfb,
+				unsigned long action, void *hcpu)
+{
+	int err = 0;
+
+	switch (action) {
+	case CPU_UP_PREPARE:
+	case CPU_UP_PREPARE_FROZEN:
+		err = cpu_up_prepare_error;
+		break;
+	case CPU_DOWN_PREPARE:
+	case CPU_DOWN_PREPARE_FROZEN:
+		err = cpu_down_prepare_error;
+		break;
+	}
+	if (err)
+		printk(KERN_INFO "Injecting error (%d) at cpu notifier\n", err);
+
+	return notifier_from_errno(err);
+}
+
+static struct notifier_block err_inject_cpu_notifier = {
+	.notifier_call = err_inject_cpu_callback,
+};
+
+static int err_inject_init(void)
+{
+	err_inject_cpu_notifier.priority = priority;
+
+	return register_hotcpu_notifier(&err_inject_cpu_notifier);
+}
+
+static void err_inject_exit(void)
+{
+	unregister_hotcpu_notifier(&err_inject_cpu_notifier);
+}
+
+module_init(err_inject_init);
+module_exit(err_inject_exit);
+
+MODULE_DESCRIPTION("CPU notifier error injection module");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 07/12] slab: convert cpu notifier to return encapsulate  errno value
  2010-03-18  9:05 ` [PATCH 07/12] slab: " Akinobu Mita
@ 2010-03-18 17:21   ` Pekka Enberg
  0 siblings, 0 replies; 16+ messages in thread
From: Pekka Enberg @ 2010-03-18 17:21 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-kernel, akpm, Christoph Lameter, Matt Mackall, linux-mm

On Thu, Mar 18, 2010 at 11:05 AM, Akinobu Mita <akinobu.mita@gmail.com> wrote:
> By the previous modification, the cpu notifier can return encapsulate
> errno value. This converts the cpu notifiers for slab.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Christoph Lameter <cl@linux-foundation.org>

Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

> Cc: Matt Mackall <mpm@selenic.com>
> Cc: linux-mm@kvack.org
> ---
>  mm/slab.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/slab.c b/mm/slab.c
> index a9f325b..d57309e 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1324,7 +1324,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
>                mutex_unlock(&cache_chain_mutex);
>                break;
>        }
> -       return err ? NOTIFY_BAD : NOTIFY_OK;
> +       return notifier_from_errno(err);
>  }
>
>  static struct notifier_block __cpuinitdata cpucache_notifier = {
> --
> 1.6.0.6
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 12/12] add CPU notifier error injection module
  2010-03-18  9:05 ` [PATCH 12/12] add CPU notifier error injection module Akinobu Mita
@ 2010-03-22 21:48   ` Andrew Morton
  2010-03-23 13:00     ` Akinobu Mita
  0 siblings, 1 reply; 16+ messages in thread
From: Andrew Morton @ 2010-03-22 21:48 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: linux-kernel

On Thu, 18 Mar 2010 18:05:24 +0900
Akinobu Mita <akinobu.mita@gmail.com> wrote:

> I used this module to test the series of modification to the
> cpu notifiers code.
> 
> Example1: inject CPU offline error (-1 == -EPERM)
> 
> 	# modprobe cpu-notifier-error-inject cpu_down_prepare_error=-1
> 	# echo 0 > /sys/devices/system/cpu/cpu1/online0
> 	bash: echo: write error: Operation not permitted
> 
> Example2: inject CPU online error (-2 == -ENOENT)
> 
> 	# modprobe cpu-notifier-error-inject cpu_up_prepare_error=-2
> 	# echo 1 > /sys/devices/system/cpu/cpu1/online0
> 	bash: echo: write error: No such file or directory
> 
> ...
>
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -885,6 +885,18 @@ config LKDTM
>  	Documentation on how to use the module can be found in
>  	Documentation/fault-injection/provoke-crashes.txt
>  
> +config CPU_NOTIFIER_ERROR_INJECT
> +	tristate "CPU notifier error injection module"
> +	depends on HOTPLUG_CPU && DEBUG_KERNEL
> +	help
> +	  This option provides a kernel module that can be used to test
> +	  the error handling of the cpu notifiers
> +
> +	  To compile this code as a module, choose M here: the module will
> +	  be called cpu-notify-inject.

Should be "cpu-notifier-error-inject", yes?

> +	  If unsure, say N.
> +
>  config FAULT_INJECTION
>  	bool "Fault-injection framework"
>  	depends on DEBUG_KERNEL


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 12/12] add CPU notifier error injection module
  2010-03-22 21:48   ` Andrew Morton
@ 2010-03-23 13:00     ` Akinobu Mita
  0 siblings, 0 replies; 16+ messages in thread
From: Akinobu Mita @ 2010-03-23 13:00 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

2010/3/23 Andrew Morton <akpm@linux-foundation.org>:
> On Thu, 18 Mar 2010 18:05:24 +0900
> Akinobu Mita <akinobu.mita@gmail.com> wrote:
>
>> I used this module to test the series of modification to the
>> cpu notifiers code.
>>
>> Example1: inject CPU offline error (-1 == -EPERM)
>>
>>       # modprobe cpu-notifier-error-inject cpu_down_prepare_error=-1
>>       # echo 0 > /sys/devices/system/cpu/cpu1/online0
>>       bash: echo: write error: Operation not permitted
>>
>> Example2: inject CPU online error (-2 == -ENOENT)
>>
>>       # modprobe cpu-notifier-error-inject cpu_up_prepare_error=-2
>>       # echo 1 > /sys/devices/system/cpu/cpu1/online0
>>       bash: echo: write error: No such file or directory
>>
>> ...
>>
>> --- a/lib/Kconfig.debug
>> +++ b/lib/Kconfig.debug
>> @@ -885,6 +885,18 @@ config LKDTM
>>       Documentation on how to use the module can be found in
>>       Documentation/fault-injection/provoke-crashes.txt
>>
>> +config CPU_NOTIFIER_ERROR_INJECT
>> +     tristate "CPU notifier error injection module"
>> +     depends on HOTPLUG_CPU && DEBUG_KERNEL
>> +     help
>> +       This option provides a kernel module that can be used to test
>> +       the error handling of the cpu notifiers
>> +
>> +       To compile this code as a module, choose M here: the module will
>> +       be called cpu-notify-inject.
>
> Should be "cpu-notifier-error-inject", yes?

Yes. Thanks for spotting and fixing.
And I had another typos in the above patch description:

>> Example1: inject CPU offline error (-1 == -EPERM)
>>
>>       # modprobe cpu-notifier-error-inject cpu_down_prepare_error=-1
>>       # echo 0 > /sys/devices/system/cpu/cpu1/online0

# echo 0 > /sys/devices/system/cpu/cpu1/online

(s/online0/online/)

>>       bash: echo: write error: Operation not permitted
>>
>> Example2: inject CPU online error (-2 == -ENOENT)
>>
>>       # modprobe cpu-notifier-error-inject cpu_up_prepare_error=-2
>>       # echo 1 > /sys/devices/system/cpu/cpu1/online0

Ditto.

>>       bash: echo: write error: No such file or directory

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 09/12] ehca: convert cpu notifier to return encapsulate errno value
  2010-03-18  9:05 ` [PATCH 09/12] ehca: " Akinobu Mita
@ 2010-03-29  8:47   ` Alexander Schmidt
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Schmidt @ 2010-03-29  8:47 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-kernel, akpm, Akinobu Mita, Hoang-Nam Nguyen,
	Christoph Raisch, linux-rdma

On Thu, 18 Mar 2010 18:05:21 +0900
Akinobu Mita <akinobu.mita@gmail.com> wrote:

> By the previous modification, the cpu notifier can return encapsulate
> errno value. This converts the cpu notifiers for ehca.
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Hoang-Nam Nguyen <hnguyen@de.ibm.com>
> Cc: Christoph Raisch <raisch@de.ibm.com>
> Cc: linux-rdma@vger.kernel.org

Acked-by: Alexander Schmidt <alexs@linux.vnet.ibm.com>

> ---
>  drivers/infiniband/hw/ehca/ehca_irq.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
> index b2b6fea..31f3ee1 100644
> --- a/drivers/infiniband/hw/ehca/ehca_irq.c
> +++ b/drivers/infiniband/hw/ehca/ehca_irq.c
> @@ -845,7 +845,7 @@ static int __cpuinit comp_pool_callback(struct notifier_block *nfb,
>  		ehca_gen_dbg("CPU: %x (CPU_PREPARE)", cpu);
>  		if (!create_comp_task(pool, cpu)) {
>  			ehca_gen_err("Can't create comp_task for cpu: %x", cpu);
> -			return NOTIFY_BAD;
> +			return notifier_from_errno(-ENOMEM);
>  		}
>  		break;
>  	case CPU_UP_CANCELED:

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-03-29  8:47 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-18  9:05 [PATCH 01/12] cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail() Akinobu Mita
2010-03-18  9:05 ` [PATCH 02/12] cpu-hotplug: return better errno on cpu hotplug failure Akinobu Mita
2010-03-18  9:05 ` [PATCH 03/12] notifier: change notifier_from_errno(0) to return NOTIFY_OK Akinobu Mita
2010-03-18  9:05 ` [PATCH 04/12] x86: convert cpu notifier to return encapsulate errno value Akinobu Mita
2010-03-18  9:05 ` [PATCH 05/12] topology: " Akinobu Mita
2010-03-18  9:05 ` [PATCH 06/12] kernel/: " Akinobu Mita
2010-03-18  9:05 ` [PATCH 07/12] slab: " Akinobu Mita
2010-03-18 17:21   ` Pekka Enberg
2010-03-18  9:05 ` [PATCH 08/12] iucv: " Akinobu Mita
2010-03-18  9:05 ` [PATCH 09/12] ehca: " Akinobu Mita
2010-03-29  8:47   ` Alexander Schmidt
2010-03-18  9:05 ` [PATCH 10/12] s390: " Akinobu Mita
2010-03-18  9:05 ` [PATCH 11/12] md: " Akinobu Mita
2010-03-18  9:05 ` [PATCH 12/12] add CPU notifier error injection module Akinobu Mita
2010-03-22 21:48   ` Andrew Morton
2010-03-23 13:00     ` Akinobu Mita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox