[dpdk-dev] [PATCH v2 1/6] eal: add internal API for current time
Morten Brørup
mb at smartsharesystems.com
Wed Mar 17 10:50:20 CET 2021
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Dmitry Kozlyuk
> Sent: Tuesday, March 16, 2021 9:08 PM
>
> 2021-03-16 11:59 (UTC-0700), Stephen Hemminger:
> > On Sun, 14 Feb 2021 05:16:11 +0300
> > Dmitry Kozlyuk <dmitry.kozliuk at gmail.com> wrote:
> >
> > > +rte_time_get_us(struct rte_time_us *now)
> > > +{
> > > + struct timeval sys;
> > > +
> > > + gettimeofday(&sys, NULL);
> > > + now->sec = sys.tv_sec;
> > > + now->usec = sys.tv_usec;
> > > +}
> >
> > Why would drivers want the default (wall clock) time instead
> > of using monotonic clock. The wall clock gets changed by NTP
> > and that is rarely what you want except for the case of log messages.
>
> * gettimeofday() is mostly used to measure time (tests, hns3 PMD), so
> you're
> right, monotonic clock is what that code really needs.
If using monotonic time here, we don't need a struct. A single 64 bit integer counting microseconds can hold thousands of years.
>
> * ena PMD uses gettimeofday() with pthread_cond_timedwait() without
> calling
> pthread_cond_setclock(), which is a bug, I believe.
>
> * hns3 PMD actually uses gettimeofday() for logs.
>
> For wall clock time there is C11 timespec_get(), so I agree this API
> should
> be changed to monotonic, thanks.
More information about the dev
mailing list