Module Name: src
Committed By: martin
Date: Wed Jul 3 19:15:08 UTC 2024
Modified Files:
src/sys/altq [netbsd-10]: altq_rmclass.c
Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #736):
sys/altq/altq_rmclass.c: revision 1.31
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 >=3D 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.29 -r1.29.10.1 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.29 src/sys/altq/altq_rmclass.c:1.29.10.1
--- src/sys/altq/altq_rmclass.c:1.29 Wed Jul 21 07:34:44 2021
+++ src/sys/altq/altq_rmclass.c Wed Jul 3 19:15:07 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: altq_rmclass.c,v 1.29 2021/07/21 07:34:44 ozaki-r Exp $ */
+/* $NetBSD: altq_rmclass.c,v 1.29.10.1 2024/07/03 19:15:07 martin 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.29 2021/07/21 07:34:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.29.10.1 2024/07/03 19:15:07 martin 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;