[LTP] [PATCH] syscalls/clock_gettime: Add test to check bug during successive readings

Viresh Kumar viresh.kumar@linaro.org
Tue Jun 9 10:33:54 CEST 2020


On 09-06-20, 14:02, Viresh Kumar wrote:
> On 09-06-20, 09:43, Arnd Bergmann wrote:
> > On Tue, Jun 9, 2020 at 9:05 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > >
> > > On 08-06-20, 16:51, Arnd Bergmann wrote:
> > > > You already have a special case for gettimeofday(), so just round down
> > > > the 'start' value to the previous microsecond when you are in that
> > > > case.
> > >
> > > Since this will also affect the next reading as well (as we will loose
> > > values < 1 us), I tried to do it a bit differently.
> > >
> > > @@ -78,6 +78,13 @@ static void run(unsigned int i)
> > >                         tv->gettime(clks[i], tst_ts_get(&ts));
> > >                         end = tst_ts_to_ns(ts);
> > >
> > > +                       /*
> > > +                        * gettimeofday() doesn't value less than 1 us, copy
> > > +                        * that from start.
> > > +                        */
> > > +                       if (tv->gettime == my_gettimeofday && end < start)
> > > +                               end += start % 1000;
> > 
> > This looks like it should work correctly, but it feels a bit more fragile than
> > 
> >                        if (tv->gettime == my_gettimeofday)
> >                                start -= start % 1000;

And this can be
        start /= 1000;

-- 
viresh


More information about the ltp mailing list