You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RFC 2: MT safe fiber context switch on ARM32 (#15582)
We need a store-store barrier between pushing the registers to the
current stack and setting the resumable flag of the current fiber,
otherwise the CPU is allowed to reorder the instructions at runtime and
to store the resumable flag before or while storing the registers
thread 1: enqueues current fiber A
therad 1: swapcontext -> store resumable
thread 1: is preempted
thread 2: steals fiber A
thread 2: resumes fiber A
thread 2: loads registers => reads garbage => segfaults
thread 1: stores registers (too late)
The chosen assembly is compatible with armv6, but might not work on older architectures, and it doesn't take advantage of armv7 supporting the `dmb ish` instruction.
We might want to consider integrating #14524 (comment) into the compiler, so we could add flags based on features, for example `armv7` when any feature matches `/\+v7(ve|r|m|em|s|k|)/`.
This is the ARM32 equivalent of #15581.
0 commit comments