linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: vincent.donnefort@arm.com
To: peterz@infradead.org, tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, valentin.schneider@arm.com,
	Vincent Donnefort <vincent.donnefort@arm.com>
Subject: [PATCH v2 2/3] cpu/hotplug: CPUHP_BRINGUP_CPU failure exception
Date: Tue, 16 Feb 2021 10:35:05 +0000	[thread overview]
Message-ID: <20210216103506.416286-3-vincent.donnefort@arm.com> (raw)
In-Reply-To: <20210216103506.416286-1-vincent.donnefort@arm.com>

From: Vincent Donnefort <vincent.donnefort@arm.com>

The atomic states (between CPUHP_AP_IDLE_DEAD and CPUHP_AP_ONLINE) are
triggered by the CPUHP_BRINGUP_CPU step. If the latter fails, no atomic
state can be rolled back.

DEAD callbacks too can't fail and disallow recovery. As a consequence,
during hotunplug, the fail injection interface should prohibit all states
from CPUHP_BRINGUP_CPU to CPUHP_ONLINE.

Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 093f96fb0824..d44877095b8c 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1038,9 +1038,13 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
 	 * to do the further cleanups.
 	 */
 	ret = cpuhp_down_callbacks(cpu, st, target);
-	if (ret && st->state == CPUHP_TEARDOWN_CPU && st->state < prev_state) {
-		cpuhp_reset_state(st, prev_state);
-		__cpuhp_kick_ap(st);
+	if (ret && st->state < prev_state) {
+		if (st->state == CPUHP_TEARDOWN_CPU) {
+			cpuhp_reset_state(st, prev_state);
+			__cpuhp_kick_ap(st);
+		} else {
+			WARN(1, "DEAD callback error for CPU%d", cpu);
+		}
 	}
 
 out:
@@ -2214,6 +2218,15 @@ static ssize_t write_cpuhp_fail(struct device *dev,
 	if (cpuhp_is_atomic_state(fail))
 		return -EINVAL;
 
+	/*
+	 * DEAD callbacks cannot fail...
+	 * ... neither can CPUHP_BRINGUP_CPU during hotunplug. The latter
+	 * triggering STARTING callbacks, a failure in this state would
+	 * hinder rollback.
+	 */
+	if (fail <= CPUHP_BRINGUP_CPU && st->state > CPUHP_BRINGUP_CPU)
+		return -EINVAL;
+
 	/*
 	 * Cannot fail anything that doesn't have callbacks.
 	 */
-- 
2.25.1


  parent reply	other threads:[~2021-02-16 10:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16 10:35 [PATCH v2 0/3] cpu/hotplug: rollback and "fail" interface fixes vincent.donnefort
2021-02-16 10:35 ` [PATCH v2 1/3] cpu/hotplug: Allowing to reset fail injection vincent.donnefort
2021-03-02  9:01   ` [tip: sched/core] " tip-bot2 for Vincent Donnefort
2021-03-03  9:49   ` tip-bot2 for Vincent Donnefort
2021-03-06 11:42   ` tip-bot2 for Vincent Donnefort
2021-02-16 10:35 ` vincent.donnefort [this message]
2021-03-02  9:01   ` [tip: sched/core] cpu/hotplug: CPUHP_BRINGUP_CPU failure exception tip-bot2 for Vincent Donnefort
2021-03-03  9:49   ` tip-bot2 for Vincent Donnefort
2021-03-06 11:42   ` tip-bot2 for Vincent Donnefort
2021-02-16 10:35 ` [PATCH v2 3/3] cpu/hotplug: Add cpuhp_invoke_callback_range() vincent.donnefort
2021-03-02  9:01   ` [tip: sched/core] " tip-bot2 for Vincent Donnefort
2021-03-03  9:49   ` tip-bot2 for Vincent Donnefort
2021-03-06 11:42   ` tip-bot2 for Vincent Donnefort

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=20210216103506.416286-3-vincent.donnefort@arm.com \
    --to=vincent.donnefort@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=valentin.schneider@arm.com \
    /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).