Date: Thu, 07 Oct 2010 20:40:49 +0300 From: Andriy Gapon <avg@freebsd.org> To: hackers@freebsd.org, freebsd-current@freebsd.org Subject: panic_cpu should be volatile Message-ID: <4CAE0621.3070809@freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4CAE0621.3070809>