panic_cpu variable in kern_shutdown.c should be volatile otherwise it's cached
in
a register in the innermost while-loop in this code (observed on amd64 with base
gcc and -O2):
if (panic_cpu != PCPU_GET(cpuid))
while (atomic_cmpset_int(&panic_cpu, NOCPU,
PCPU_GET(cpuid)) == 0)
while (panic_cpu != NOCPU)
; /* nothing */
The patch is here:
http://people.freebsd.org/~avg/panic_cpu.diff
I also took a liberty to move the variable into the scope of panic() functions
as
it doesn't seem to be useful outside of it. But this is not necessary, of
course.
Big thanks to mdf@ for the hint and to kib@ and kan@ for memory model expertise.
P.S.
The assembly:
.loc 1 544 0
movl panic_cpu(%rip), %eax
.LVL134:
.p2align 4,,7
.L210:
cmpl $255, %eax
jne .L210
jmp .L225
--
Andriy Gapon
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[email protected]"