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

Nicholas Piggin npiggin at gmail.com
Sat Nov 25 01:08:16 AEDT 2017


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

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");
 
-- 
2.15.0



More information about the Skiboot mailing list