Re: [PATCH v10 3/7] x86/time: read_boot_clock64() implementation

From: Andy Shevchenko
Date: Mon Jun 18 2018 - 04:45:15 EST


On Mon, Jun 18, 2018 at 11:42 AM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
>
> On Fri, Jun 15, 2018 at 8:48 PM Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> wrote:
> >
> > read_boot_clock64() returns time of when system was started. Now, that
> > early boot clock is going to be available on x86 it is possible to
> > implement x86 specific version of read_boot_clock64() that takes advantage
> > of this new feature.
>

Oops, sorry for previous empty mail.

> > +void __init read_boot_clock64(struct timespec64 *now, struct timespec64 *ts)
> > +{
> > + u64 ns_boot = sched_clock_cpu(smp_processor_id());
> > + bool valid_clock;
> > + u64 ns_now;
> > +
> > + ns_now = timespec64_to_ns(now);
> > + valid_clock = ns_boot && timespec64_valid_strict(now) &&
> > + (ns_now > ns_boot);
> > +
>


> > + if (!valid_clock)

Are we expecting more often clock to be non-valid?
Perhaps change to positive conditional?

> > + *ts = (struct timespec64){0, 0};

I dunno if additional variable would be better for readability, like

struct timespec64 null_ts = {0,0};
...
*ts = null_ts;

> > + else
> > + *ts = ns_to_timespec64(ns_now - ns_boot);

But I'm fine as long as Thomas is okay with this code.

> > +}


--
With Best Regards,
Andy Shevchenko