Re: panic_cpu should be volatile

From: John Baldwin <jhb_at_freebsd.org>
Date: Fri, 8 Oct 2010 15:01:18 -0400
On Thursday, October 07, 2010 1:40:49 pm Andriy Gapon wrote:
> 
> 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.

Looks fine to me.

-- 
John Baldwin
Received on Fri Oct 08 2010 - 17:08:45 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:08 UTC