[Skiboot] [PATCH 08/18] fast-reboot: make spin loops consistent and SMT friendly

Nicholas Piggin npiggin at gmail.com
Sun Nov 19 20:14:58 AEDT 2017


Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 core/fast-reboot.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/core/fast-reboot.c b/core/fast-reboot.c
index 3e8a4eb5..d156e536 100644
--- a/core/fast-reboot.c
+++ b/core/fast-reboot.c
@@ -531,11 +531,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();
 	}
@@ -550,11 +553,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");
@@ -569,13 +573,16 @@ 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();
 	}
 
+	sync();
+
 	prlog(PR_INFO, "RESET: All done, cleaning up...\n");
 
 	/* Clear release flag for next time */
-- 
2.15.0



More information about the Skiboot mailing list