From 0a21ab2c4bf42405de6b11549ad80937b19d677f Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 7 Sep 2015 14:01:18 +0000 Subject: [PATCH] Use load-acquire semantics while waiting for td_lock to be released. The store should have release semantics and will have due to the dsb above it so add a comment to explain this. [1] While here update the code to not reload the current thread, it's already in a register, we just need to not trash it. Suggested by: kib [1] Sponsored by: ABT Systems Ltd --- sys/arm64/arm64/swtch.S | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S index fbffaed437a..bc2e5210341 100644 --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -160,17 +160,18 @@ ENTRY(cpu_switch) dsb sy isb - /* Release the old thread */ + /* + * Release the old thread. This doesn't need to be a store-release + * as the above dsb instruction will provide release semantics. + */ str x2, [x0, #TD_LOCK] #if defined(SCHED_ULE) && defined(SMP) /* Read the value in blocked_lock */ ldr x0, =_C_LABEL(blocked_lock) - ldr x1, [x0] - /* Load curthread */ - ldr x2, [x18, #PC_CURTHREAD] + ldr x2, [x0] 1: - ldr x3, [x2, #TD_LOCK] - cmp x3, x1 + ldar x3, [x1, #TD_LOCK] + cmp x3, x2 b.eq 1b #endif