Download raw body.
use nanoseconds for timekeeping in hfsc
hfsc uses a scaled version of microseconds for time at the moment. it
seems more straightforward to just use nanoseconds.
kjc and cheloa like the idea. it seems to work fine in my own tests.
ok?
Index: hfsc.c
===================================================================
RCS file: /cvs/src/sys/net/hfsc.c,v
diff -u -p -r1.49 hfsc.c
--- hfsc.c 11 Apr 2023 00:45:09 -0000 1.49
+++ hfsc.c 30 Sep 2024 05:24:11 -0000
@@ -248,11 +248,12 @@ void hfsc_rtsc_min(struct hfsc_runtime_
void hfsc_getclstats(struct hfsc_class_stats *, struct hfsc_class *);
struct hfsc_class *hfsc_clh2cph(struct hfsc_if *, u_int32_t);
-#define HFSC_CLK_SHIFT 8
-#define HFSC_FREQ (1000000 << HFSC_CLK_SHIFT)
-#define HFSC_CLK_PER_TICK (HFSC_FREQ / hz)
+#define HFSC_FREQ 1000000000LL
+#define HFSC_CLK_PER_TICK tick_nsec
#define HFSC_HT_INFINITY 0xffffffffffffffffLL /* infinite time value */
+#define hfsc_uptime() nsecuptime()
+
struct pool hfsc_class_pl, hfsc_internal_sc_pl;
/*
@@ -345,16 +346,6 @@ hfsc_class_purge(struct hfsc_class *cl,
return cl->cl_qops->pfq_purge(cl->cl_qdata, ml);
}
-u_int64_t
-hfsc_microuptime(void)
-{
- struct timeval tv;
-
- microuptime(&tv);
- return (((u_int64_t)(tv.tv_sec) * 1000000 + tv.tv_usec) <<
- HFSC_CLK_SHIFT);
-}
-
static inline u_int
hfsc_more_slots(u_int current)
{
@@ -845,7 +836,7 @@ hfsc_deq_begin(struct ifqueue *ifq, void
struct mbuf *m;
u_int64_t cur_time;
- cur_time = hfsc_microuptime();
+ cur_time = hfsc_uptime();
/*
* if there are eligible classes, use real-time criteria.
@@ -1007,7 +998,7 @@ hfsc_init_ed(struct hfsc_if *hif, struct
{
u_int64_t cur_time;
- cur_time = hfsc_microuptime();
+ cur_time = hfsc_uptime();
/* update the deadline curve */
hfsc_rtsc_min(&cl->cl_deadline, cl->cl_rsc, cur_time, cl->cl_cumul);
@@ -1114,7 +1105,7 @@ hfsc_init_vf(struct hfsc_class *cl, int
if (cl->cl_usc != NULL) {
/* class has upper limit curve */
if (cur_time == 0)
- cur_time = hfsc_microuptime();
+ cur_time = hfsc_uptime();
/* update the ulimit curve */
hfsc_rtsc_min(&cl->cl_ulimit, cl->cl_usc, cur_time,
@@ -1701,7 +1692,7 @@ hfsc_getclstats(struct hfsc_class_stats
sp->myfadj = cl->cl_myfadj;
sp->vtadj = cl->cl_vtadj;
- sp->cur_time = hfsc_microuptime();
+ sp->cur_time = hfsc_uptime();
sp->machclk_freq = HFSC_FREQ;
sp->qlength = hfsc_class_qlength(cl);
use nanoseconds for timekeeping in hfsc