lkml.org 
[lkml]   [2018]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/3] x86/vdso: Rearrange do_hres() to improve code generation
From
Date


> On Oct 4, 2018, at 11:00 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
>
>> On Thu, 4 Oct 2018, Andy Lutomirski wrote:
>> index 18c8a78d1ec9..419de7552c2f 100644
>> --- a/arch/x86/entry/vdso/vclock_gettime.c
>> +++ b/arch/x86/entry/vdso/vclock_gettime.c
>> @@ -147,10 +147,9 @@ notrace static int do_hres(clockid_t clk, struct timespec *ts)
>>
>> do {
>> seq = gtod_read_begin(gtod);
>> - ts->tv_sec = base->sec;
>> + cycles = vgetcyc(gtod->vclock_mode);
>> ns = base->nsec;
>> last = gtod->cycle_last;
>> - cycles = vgetcyc(gtod->vclock_mode);
>> if (unlikely((s64)cycles < 0))
>> return vdso_fallback_gettime(clk, ts);
>> if (cycles > last)
>> @@ -158,7 +157,7 @@ notrace static int do_hres(clockid_t clk, struct timespec *ts)
>> ns >>= gtod->shift;
>> } while (unlikely(gtod_read_retry(gtod, seq)));
>>
>> - ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
>> + ts->tv_sec = base->sec + __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
>
> You cannot access base->sec outside of the seqcount protected region. It
> might have been incremented by now and you'll get a time jump by a full
> second.

Duh. Let me try this again.

>
> Thanks,
>
> tglx
>
>

\
 
 \ /
  Last update: 2018-10-05 15:06    [W:0.092 / U:1.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site