BZ# 16418: Fix powerpc get_clockfreq raciness
Adhemerval Zanella
azanella@linux.vnet.ibm.com
Wed Jan 21 15:55:00 GMT 2015
On 21-01-2015 12:12, Carlos O'Donell wrote:
> On 11/24/2014 04:44 PM, Adhemerval Zanella wrote:
>> This patch fixes powerpc __get_clockfreq racy and cancel-safe issues by
>> dropping internal static cache and by using nocancel file operations.
>> The vDSO failure check is also removed, since kernel code does not
>> return an error (it cleans cr0.so bit on function return) and the static
>> code (to read value /proc) now uses non-cancellable calls.
>>
>> Since currently I don't see this code patch to be performance sensitive
>> (usually the clock frequency is obtained once to transform timebase
>> values), I don't see a problem to drop its internal cache. Also, if
>> latency came up as being important for this one, correct approach would
>> be use IFUNC to call vDSO symbols directly (which I do not aim to
>> implement now).
>>
>> Tested on powerpc64 and powerpc32.
> This looks good to me.
>
> You've removed the cache which removes the MT-unsafe multiple-writers
> of the cache. You could make this performant by using atomic loads and
> stores with acq/rel semantics to ensure happens before. However, that
> would be a future enhancement if you wanted to do it that way.
>
> You've removed the potential cancellation points and that makes you
> conformant with POSIX in that you no longer create cancellation points
> for clock_* functions.
>
> e.g.
> An implementation shall not introduce cancellation points into any
> other functions specified in this volume of IEEE Std 1003.1-2001.
>
Pushed upstream. I will think if it is really worth to optimize this
function for static case. Thanks for the review.
More information about the Libc-alpha
mailing list