Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 May 2009 14:29:11 -1000 (HST)
From:      Jeff Roberson <jroberson@jroberson.net>
To:        =?ISO-8859-15?Q?Dag-Erling_Sm=F8rgrav?= <des@des.no>
Cc:        arch@freebsd.org
Subject:   Re: lockless file descriptor lookup
Message-ID:  <alpine.BSF.2.00.0905121411070.981@desktop>
In-Reply-To: <86bppy60ti.fsf@ds4.des.no>
References:  <alpine.BSF.2.00.0905111720280.981@desktop> <86bppy60ti.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 12 May 2009, Dag-Erling Sm?rgrav wrote:

> Jeff Roberson <jroberson@jroberson.net> writes:
>> I'd also appreciate it if someone could look at my volatile cast and
>> make sure I'm actually forcing the compiler to refresh the fd_ofiles
>> array here:
>>
>> +		if (fp == ((struct file *volatile*)fdp->fd_ofiles)[fd])
>
> The problem is that since it is not declared as volatile, some other
> piece of code may have modified it but not yet flushed it to RAM.

That is an acceptable race due to other guarantees.  If it hasn't been 
committed to memory yet, the old table still contains valid data.  I only 
need to be certain that the compiler doesn't cache the original ofiles 
value.  It can't anyway because atomics use inline assembly on all 
platforms but I'd like it to be explicit anyway.

Thanks,
Jeff

>
> DES
> -- 
> Dag-Erling Sm?rgrav - des@des.no
>



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