diff mbox series

[v2,07/25] fast-reboot: make spin loops consistent and SMT friendly

Message ID 20171124140834.7099-8-npiggin@gmail.com
State Superseded
Headers show
Series move direct controls out of fast-reboot, generalize them, add quiescing | expand

Commit Message

Nicholas Piggin Nov. 24, 2017, 2:08 p.m. UTC
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 core/fast-reboot.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/core/fast-reboot.c b/core/fast-reboot.c
index 6203ff203..c6ecd1cc6 100644
--- a/core/fast-reboot.c
+++ b/core/fast-reboot.c
@@ -518,11 +518,14 @@  void __noreturn fast_reboot_entry(void)
 	 */
 	if (this_cpu() != boot_cpu) {
 		this_cpu()->state = cpu_state_present;
-		while (!fast_boot_release) {
+		sync();
+		if (!fast_boot_release) {
 			smt_lowest();
-			sync();
+			while (!fast_boot_release)
+				barrier();
+			smt_medium();
 		}
-		smt_medium();
+		sync();
 		cleanup_cpu_state();
 		__secondary_cpu_entry();
 	}
@@ -537,11 +540,12 @@  void __noreturn fast_reboot_entry(void)
 			continue;
 
 		/* XXX Add a callin timeout ? */
-		while (cpu->state != cpu_state_present) {
+		if (cpu->state != cpu_state_present) {
 			smt_lowest();
-			sync();
+			while (cpu->state != cpu_state_present)
+				barrier();
+			smt_medium();
 		}
-		smt_medium();
 	}
 
 	prlog(PR_INFO, "RESET: Releasing secondaries...\n");
@@ -556,16 +560,18 @@  void __noreturn fast_reboot_entry(void)
 			continue;
 
 		/* XXX Add a callin timeout ? */
-		while (cpu->state == cpu_state_present) {
+		if (cpu->state == cpu_state_present) {
 			smt_lowest();
-			sync();
+			while (cpu->state == cpu_state_present)
+				barrier();
+			smt_medium();
 		}
-		smt_medium();
 	}
 
 	prlog(PR_DEBUG, "RESET: Releasing special wakeups...\n");
 
 	sreset_all_finish();
+	sync();
 
 	prlog(PR_INFO, "RESET: All done, cleaning up...\n");