Module Name: src
Committed By: ozaki-r
Date: Mon Jul 1 02:18:44 UTC 2024
Modified Files:
src/sys/altq: altq_rmclass.c
Log Message:
altq, cbq: take care of borrowed classes on sleeping
rmc_under_limit() determines if we can send a packet by checking
that a target class (or borrowing classes) is ready to send a
packet. cl->undertime_ indicates a time that the class can send
packets after the time. So if cl->undertime_ has passed
(i.e., now >= cl->undertime_), we can send packets through the class.
The treatment is important when a required delay period is shorten
than the minimum delay on the system (a tick), because in that case
the delay handler is too late to wake up to send a packet in time.
If there are traffic, rmc_under_limit() can save such a case.
Unfortunately, the old code didn't take care of bandwidth borrowing
on sleeping. So bandwidth borrowing didn't work well with high
bandwidths that require short delay actions.
To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/altq/altq_rmclass.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/altq/altq_rmclass.c
diff -u src/sys/altq/altq_rmclass.c:1.30 src/sys/altq/altq_rmclass.c:1.31
--- src/sys/altq/altq_rmclass.c:1.30 Fri Feb 9 22:08:31 2024
+++ src/sys/altq/altq_rmclass.c Mon Jul 1 02:18:44 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: altq_rmclass.c,v 1.30 2024/02/09 22:08:31 andvar Exp $ */
+/* $NetBSD: altq_rmclass.c,v 1.31 2024/07/01 02:18:44 ozaki-r Exp $ */
/* $KAME: altq_rmclass.c,v 1.19 2005/04/13 03:44:25 suz Exp $ */
/*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.30 2024/02/09 22:08:31 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.31 2024/07/01 02:18:44 ozaki-r Exp $");
/* #ident "@(#)rm_class.c 1.48 97/12/05 SMI" */
@@ -879,6 +879,7 @@ rmc_under_limit(struct rm_class *cl, str
rm_class_t *p = cl;
rm_class_t *top;
struct rm_ifdat *ifd = cl->ifdat_;
+ int sleeping = cl->sleeping_;
ifd->borrowed_[ifd->qi_] = NULL;
/*
@@ -888,20 +889,23 @@ rmc_under_limit(struct rm_class *cl, str
if (cl->parent_ == NULL)
return (1);
- if (cl->sleeping_) {
- if (TS_LT(now, &cl->undertime_))
- return (0);
-
- CALLOUT_STOP(&cl->callout_);
- cl->sleeping_ = 0;
- cl->undertime_.tv_sec = 0;
+ if (!TS_LT(now, &cl->undertime_)) {
+ /* Fast path: the given class is allowed to send packets */
+ if (sleeping) {
+ CALLOUT_STOP(&cl->callout_);
+ cl->sleeping_ = 0;
+ cl->undertime_.tv_sec = 0;
+ }
return (1);
}
top = NULL;
- while (cl->undertime_.tv_sec && TS_LT(now, &cl->undertime_)) {
+ do {
if (((cl = cl->borrow_) == NULL) ||
(cl->depth_ > ifd->cutoff_)) {
+ /* No need to call the delay action */
+ if (sleeping)
+ return (0);
#ifdef ADJUST_CUTOFF
if (cl != NULL)
/* cutoff is taking effect, just
@@ -931,7 +935,7 @@ rmc_under_limit(struct rm_class *cl, str
return (0);
}
top = cl;
- }
+ } while (cl->undertime_.tv_sec && TS_LT(now, &cl->undertime_));
if (cl != p)
ifd->borrowed_[ifd->qi_] = cl;