linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: vincent.donnefort@arm.com
To: peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org
Cc: valentin.schneider@arm.com,
	Vincent Donnefort <vincent.donnefort@arm.com>
Subject: [PATCH 4/4] cpu/hotplug: Fix CPU down rollback
Date: Mon, 11 Jan 2021 17:10:47 +0000	[thread overview]
Message-ID: <1610385047-92151-5-git-send-email-vincent.donnefort@arm.com> (raw)
In-Reply-To: <1610385047-92151-1-git-send-email-vincent.donnefort@arm.com>

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

After the AP brought itself down to CPUHP_TEARDOWN_CPU, the BP will finish
the job. The steps left are as followed:

   +--------------------+
   | CPUHP_TEARDOWN_CPU |  -> If fails state is CPUHP_TEARDOWN_CPU
   +--------------------+
   |   ATOMIC STATES    |  -> Cannot Fail
   +--------------------+
   |  CPUHP_BRINGUP_CPU |  -> Cannot fail
   +--------------------+
   |        ...         |
   |        ...         |  -> Can fail and rollback
   |   CPUHP_OFFLINE    |
   +--------------------+

There are, in case of failure two possibilities:

  1. Failure in CPUHP_TEARDOWN_CPU, then st->state will still be
     CPUHP_TEARDOWN_CPU

  2. Failure between CPUHP_OFFLINE and CPUHP_BRINGUP_CPU.

For 2. The rollback will always run in the CPUHP_BRINGUP_CPU bringup
callback (bringup_cpu()) which kicks the AP back on. The latter will then
end-up setting st->state to CPUHP_AP_ONLINE_IDLE.

Checking for CPUHP_AP_ONLINE_IDLE allows then to rollback in all cases.

Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
---
 kernel/cpu.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index aebec3a..8b3f84e 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1078,7 +1078,14 @@ 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) {
+	if (ret && (st->state == CPUHP_AP_ONLINE_IDLE ||
+		    st->state == CPUHP_TEARDOWN_CPU) &&
+	    st->state < prev_state) {
+		/*
+		 * After an error the state can be either:
+		 *  - CPUHP_TEARDOWN_CPU if this step failed.
+		 *  - CPUHP_AP_ONLINE_IDLE if any other failed.
+		 */
 		cpuhp_reset_state(st, prev_state);
 		__cpuhp_kick_ap(st);
 	}
-- 
2.7.4


  parent reply	other threads:[~2021-01-11 17:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 17:10 [PATCH 0/4] cpu/hotplug: rollback and "fail" interface fixes vincent.donnefort
2021-01-11 17:10 ` [PATCH 1/4] cpu/hotplug: Allowing to reset fail injection vincent.donnefort
2021-01-11 17:10 ` [PATCH 2/4] cpu/hotplug: CPUHP_BRINGUP_CPU exception in " vincent.donnefort
2021-01-20 12:58   ` Peter Zijlstra
2021-01-20 15:17     ` Vincent Donnefort
2021-01-20 17:30       ` Peter Zijlstra
2021-01-11 17:10 ` [PATCH 3/4] cpu/hotplug: Add cpuhp_invoke_callback_range() vincent.donnefort
2021-01-20 13:11   ` Peter Zijlstra
2021-01-20 17:54     ` Peter Zijlstra
2021-01-20 17:45   ` Peter Zijlstra
2021-01-20 17:53     ` Peter Zijlstra
2021-01-21 10:57       ` Vincent Donnefort
2021-01-21 11:18         ` Peter Zijlstra
2021-01-20 17:49   ` Peter Zijlstra
2021-01-11 17:10 ` vincent.donnefort [this message]
2021-01-21 14:57   ` [PATCH 4/4] cpu/hotplug: Fix CPU down rollback Peter Zijlstra
2021-01-21 15:43     ` 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=1610385047-92151-5-git-send-email-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).