Thread (32 messages) 32 messages, 2 authors, 2021-12-23

Re: [PATCH v1 01/25] drivers/net: introduce a new PMD driver

From: Yanling Song <hidden>
Date: 2021-12-22 00:54:13

On Sun, 19 Dec 2021 11:40:31 -0800
Stephen Hemminger [off-list ref] wrote:
On Sat, 18 Dec 2021 10:51:28 +0800
Yanling Song [off-list ref] wrote:
quoted
+#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */
+#define CLOCK_TYPE CLOCK_MONOTONIC_RAW
+#else
+#define CLOCK_TYPE CLOCK_MONOTONIC
+#endif  
CLOCK_MONOTONIC_RAW was defined in Linux.2.6.28
DPDK does not support any kernels that old, so the #ifdef is not
needed.
OK. #ifdef will be removed in the next version.
+
+static inline unsigned long clock_gettime_ms(void)
+{
+	struct timespec tv;
+
+	(void)clock_gettime(CLOCK_TYPE, &tv);
+
+	return (unsigned long)tv.tv_sec * SPNIC_S_TO_MS_UNIT +
+	       (unsigned long)tv.tv_nsec / SPNIC_S_TO_NS_UNIT;
+}

If all you want is jiffie accuracy,  you could use
CLOCK_MONOTONIC_COARSE.
I did not get your point: CLOCK_MONOTONIC is more accurate than
CLOCK_MONOTONIC_COARSE, right?
+#define jiffies	clock_gettime_ms()
+#define msecs_to_jiffies(ms)	(ms)

+#define time_before(now, end)	((now) < (end))

Does that simple version of the macro work right if jiffies wraps
around? Less of an issue on 64 bit platforms...

The kernel version is effectively.
#define time_before(now, end) ((long)((now) - (end)) < 0)
OK. Will be changed in the next version.

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help