Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Oct 2010 15:01:18 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        hackers@freebsd.org, Andriy Gapon <avg@freebsd.org>
Subject:   Re: panic_cpu should be volatile
Message-ID:  <201010081501.18870.jhb@freebsd.org>
In-Reply-To: <4CAE0621.3070809@freebsd.org>
References:  <4CAE0621.3070809@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010081501.18870.jhb>