Thread (67 messages) flat view 67 messages, 9 authors, 2021-04-21

Re: [dpdk-dev] [PATCH v2 1/6] eal: add internal API for current time

From: Morten Brørup <hidden>
Date: 2021-03-17 09:50:50

From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Dmitry Kozlyuk
Sent: Tuesday, March 16, 2021 9:08 PM

2021-03-16 11:59 (UTC-0700), Stephen Hemminger:
quoted
On Sun, 14 Feb 2021 05:16:11 +0300
Dmitry Kozlyuk [off-list ref] wrote:
quoted
+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.
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help