Index | Thread | Search

From:
David Gwynne <david@gwynne.id.au>
Subject:
use nsecuptime() in fq_codel.c directly
To:
tech@openbsd.org
Date:
Fri, 25 Oct 2024 15:48:31 +1000

Download raw body.

Thread
codel uses nsecs for timestamps already, but uses nanouptime and some
maths to get them. it could just use nsecuptime().

ok?

Index: fq_codel.c
===================================================================
RCS file: /cvs/src/sys/net/fq_codel.c,v
diff -u -p -r1.15 fq_codel.c
--- fq_codel.c	2 Jan 2022 22:36:03 -0000	1.15
+++ fq_codel.c	25 Oct 2024 05:46:50 -0000
@@ -292,15 +292,6 @@ codel_freeparams(struct codel_params *cp
 	cp->intervals = NULL;
 }
 
-static inline void
-codel_gettime(int64_t *now)
-{
-	struct timespec tv;
-
-	nanouptime(&tv);
-	*now = tv.tv_sec * 1000000000LL + tv.tv_nsec;
-}
-
 static inline unsigned int
 codel_backlog(struct codel *cd)
 {
@@ -543,7 +534,7 @@ fqcodel_enq(struct fqcodel *fqc, struct 
 	if (flow == NULL)
 		return (m);
 
-	codel_gettime(&now);
+	now = nsecuptime();
 	codel_enqueue(&flow->cd, now, m);
 	fqc->qlength++;
 
@@ -650,7 +641,7 @@ fqcodel_deq_begin(struct fqcodel *fqc, v
 	if ((fqc->flags & FQCF_FIXED_QUANTUM) == 0)
 		fqc->quantum = fqc->ifp->if_mtu + max_linkhdr;
 
-	codel_gettime(&now);
+	now = nsecuptime();
 
 	for (flow = first_flow(fqc, &fq); flow != NULL;
 	     flow = next_flow(fqc, flow, &fq)) {