linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Sebastian Andrzej Siewior <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: peterz@infradead.org, linux-kernel@vger.kernel.org,
	mingo@kernel.org, akinobu.mita@gmail.com, bigeasy@linutronix.de,
	tglx@linutronix.de, hpa@zytor.com
Subject: [tip:smp/hotplug] fault-injection/cpu: Convert to hotplug state machine
Date: Mon, 19 Sep 2016 12:57:48 -0700	[thread overview]
Message-ID: <tip-8c58898b3ecb213ad7c52aa0c7c9d3201e559be1@git.kernel.org> (raw)
In-Reply-To: <20160906170457.32393-15-bigeasy@linutronix.de>

Commit-ID:  8c58898b3ecb213ad7c52aa0c7c9d3201e559be1
Gitweb:     http://git.kernel.org/tip/8c58898b3ecb213ad7c52aa0c7c9d3201e559be1
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:50 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:31 +0200

fault-injection/cpu: Convert to hotplug state machine

Install the callbacks via the state machine.

This is just a temporary vehicle to keep the interface working for now,
It'll be replaced by the sysfs interface which allows to step through the
hotplug state machine step by step.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-15-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/cpuhotplug.h      |  1 +
 lib/cpu-notifier-error-inject.c | 46 +++++++++++++++++++++++++++++++++++------
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 7706987..bb6231d 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -43,6 +43,7 @@ enum cpuhp_state {
 	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 	CPUHP_SH_SH3X_PREPARE,
 	CPUHP_TIMERS_DEAD,
+	CPUHP_NOTF_ERR_INJ_PREPARE,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
 	CPUHP_AP_OFFLINE,
diff --git a/lib/cpu-notifier-error-inject.c b/lib/cpu-notifier-error-inject.c
index 707ca24..0e2c9a1 100644
--- a/lib/cpu-notifier-error-inject.c
+++ b/lib/cpu-notifier-error-inject.c
@@ -8,16 +8,47 @@ static int priority;
 module_param(priority, int, 0);
 MODULE_PARM_DESC(priority, "specify cpu notifier priority");
 
+#define UP_PREPARE 0
+#define UP_PREPARE_FROZEN 0
+#define DOWN_PREPARE 0
+#define DOWN_PREPARE_FROZEN 0
+
 static struct notifier_err_inject cpu_notifier_err_inject = {
 	.actions = {
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE_FROZEN) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE_FROZEN) },
+		{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE) },
+		{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE_FROZEN) },
+		{ NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE) },
+		{ NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE_FROZEN) },
 		{}
 	}
 };
 
+static int notf_err_handle(struct notifier_err_inject_action *action)
+{
+	int ret;
+
+	ret = action->error;
+	if (ret)
+		pr_info("Injecting error (%d) to %s\n", ret, action->name);
+	return ret;
+}
+
+static int notf_err_inj_up_prepare(unsigned int cpu)
+{
+	if (!cpuhp_tasks_frozen)
+		return notf_err_handle(&cpu_notifier_err_inject.actions[0]);
+	else
+		return notf_err_handle(&cpu_notifier_err_inject.actions[1]);
+}
+
+static int notf_err_inj_dead(unsigned int cpu)
+{
+	if (!cpuhp_tasks_frozen)
+		return notf_err_handle(&cpu_notifier_err_inject.actions[2]);
+	else
+		return notf_err_handle(&cpu_notifier_err_inject.actions[3]);
+}
+
 static struct dentry *dir;
 
 static int err_inject_init(void)
@@ -29,7 +60,10 @@ static int err_inject_init(void)
 	if (IS_ERR(dir))
 		return PTR_ERR(dir);
 
-	err = register_hotcpu_notifier(&cpu_notifier_err_inject.nb);
+	err = cpuhp_setup_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE,
+					"cpu-err-notif:prepare",
+					notf_err_inj_up_prepare,
+					notf_err_inj_dead);
 	if (err)
 		debugfs_remove_recursive(dir);
 
@@ -38,7 +72,7 @@ static int err_inject_init(void)
 
 static void err_inject_exit(void)
 {
-	unregister_hotcpu_notifier(&cpu_notifier_err_inject.nb);
+	cpuhp_remove_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE);
 	debugfs_remove_recursive(dir);
 }
 

  reply	other threads:[~2016-09-19 19:58 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 01/21] arm64: FP/SIMD: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-09-06 18:14   ` Will Deacon
2016-09-19 19:51   ` [tip:smp/hotplug] arm64/FP/SIMD: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 02/21] ARM: shmobile: " Sebastian Andrzej Siewior
2016-09-06 18:05   ` Geert Uytterhoeven
2016-09-07 13:58     ` Sebastian Andrzej Siewior
2016-09-19 19:52   ` [tip:smp/hotplug] ARM/shmobile: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 03/21] ARM: OMAP: wakeupgen: " Sebastian Andrzej Siewior
2016-09-13 22:24   ` Tony Lindgren
2016-09-19 19:52   ` [tip:smp/hotplug] ARM/OMAP/wakeupgen: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 04/21] ia64: mca: " Sebastian Andrzej Siewior
2016-09-19 19:53   ` [tip:smp/hotplug] ia64/mca: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 05/21] sh: SH-X3 SMP: " Sebastian Andrzej Siewior
2016-09-19 19:53   ` [tip:smp/hotplug] sh/SH-X3 " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 06/21] x86: microcode: " Sebastian Andrzej Siewior
2016-09-07 11:36   ` Borislav Petkov
2016-09-07 14:51     ` Sebastian Andrzej Siewior
2016-09-07 16:02       ` Borislav Petkov
2016-09-07 16:45     ` [PATCH 06/21 v2] " Sebastian Andrzej Siewior
2016-09-19 19:54       ` [tip:smp/hotplug] x86/microcode: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 07/21] lib: irq_poll: " Sebastian Andrzej Siewior
2016-09-19 19:54   ` [tip:smp/hotplug] lib/irq_poll: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 08/21] block: softirq: " Sebastian Andrzej Siewior
2016-09-19 19:55   ` [tip:smp/hotplug] block/softirq: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 09/21] oprofile: timer: " Sebastian Andrzej Siewior
2016-09-19 19:55   ` [tip:smp/hotplug] oprofile/timer: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 10/21] virtio scsi: " Sebastian Andrzej Siewior
2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 11/21] ACPI: processor: " Sebastian Andrzej Siewior
2016-09-06 21:08   ` Rafael J. Wysocki
2016-09-07 14:01     ` Sebastian Andrzej Siewior
2016-09-07 15:59       ` Rafael J. Wysocki
2016-09-19 19:56   ` [tip:smp/hotplug] ACPI/processor: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 12/21] cpufreq: " Sebastian Andrzej Siewior
2016-09-06 21:27   ` Rafael J. Wysocki
2016-09-07 14:18     ` Sebastian Andrzej Siewior
2016-09-07 15:58       ` Rafael J. Wysocki
2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-20 14:56     ` [PATCH] cpufreq: fix up conversion " Sebastian Andrzej Siewior
2016-09-20 15:07       ` [tip:smp/hotplug] cpufreq: Fix " tip-bot for Sebastian Andrzej Siewior
2016-09-20 16:08         ` Borislav Petkov
2016-09-20 16:17       ` [PATCH] cpufreq: fix " Rafael J. Wysocki
2016-09-06 17:04 ` [PATCH 13/21] padata: Convert " Sebastian Andrzej Siewior
2016-09-19 19:57   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 14/21] fault-injection: cpu: " Sebastian Andrzej Siewior
2016-09-19 19:57   ` tip-bot for Sebastian Andrzej Siewior [this message]
2016-09-06 17:04 ` [PATCH 15/21] mips: octeon: smp: " Sebastian Andrzej Siewior
2016-09-07  8:24   ` Matt Redfearn
2016-09-07 14:27     ` Sebastian Andrzej Siewior
2016-09-08  8:34       ` Matt Redfearn
2016-09-19 15:10   ` Ralf Baechle
2016-09-19 19:58   ` [tip:smp/hotplug] mips/octeon/smp: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 16/21] mips: loongson: smp: " Sebastian Andrzej Siewior
2016-09-19 15:10   ` Ralf Baechle
2016-09-19 19:58   ` [tip:smp/hotplug] mips/loongson/smp: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 17/21] s390: mm: pfault: " Sebastian Andrzej Siewior
2016-09-19 19:59   ` [tip:smp/hotplug] s390/mm/pfault: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 18/21] x86: apic: uv: " Sebastian Andrzej Siewior
2016-09-19 19:59   ` [tip:smp/hotplug] x86/apic/uv: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 19/21] blk: mq: reserve hotplug ID states for block Sebastian Andrzej Siewior
2016-09-19 20:03   ` [tip:smp/hotplug] blk/mq: Reserve hotplug ID states for block multiqueue tip-bot for Sebastian Andrzej Siewior
2016-09-19 21:24   ` [tip:smp/hotplug] blk/mq: Reserve hotplug " tip-bot for Sebastian Andrzej Siewior
2016-09-21  7:45   ` tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 20/21] blk: mq: cpu-notif: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 21/21] blk: mq: " Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-8c58898b3ecb213ad7c52aa0c7c9d3201e559be1@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akinobu.mita@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).