git: 6ecf086d5a0c - stable/13 - altq: improve pfctl config time for large numbers of queues

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 18 Aug 2022 12:39:38 UTC
The branch stable/13 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6ecf086d5a0cdb2f1a13a6227a11b6548223e488

commit 6ecf086d5a0cdb2f1a13a6227a11b6548223e488
Author:     James Skon <jps@rgnets.com>
AuthorDate: 2022-07-28 19:58:31 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-08-18 07:12:13 +0000

    altq: improve pfctl config time for large numbers of queues
    
    In the current implementation of altq_hfsc.c, whne new queues are being
    added (by pfctl), each queue is added to the tail of the siblings linked
    list under the parent queue.
    
    On a system with many queues (50,000+) this leads to very long load
    times at the insertion process must scan the entire list for every new
    queue,
    
    Since this list is unordered, this changes merely adds the new queue to
    the head of the list rather than the tail.
    
    Reviewed by:    kp
    MFC after:      3 weeks
    Sponsored by:   RG Nets
    Differential Revision:  https://reviews.freebsd.org/D35964
    
    (cherry picked from commit 13890d30f8b215b84800cce3f161ad5148c82c00)
---
 sys/net/altq/altq_hfsc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/net/altq/altq_hfsc.c b/sys/net/altq/altq_hfsc.c
index 2dbf571cdbb9..0d15b903cd64 100644
--- a/sys/net/altq/altq_hfsc.c
+++ b/sys/net/altq/altq_hfsc.c
@@ -514,9 +514,9 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
 		if ((p = parent->cl_children) == NULL)
 			parent->cl_children = cl;
 		else {
-			while (p->cl_siblings != NULL)
-				p = p->cl_siblings;
-			p->cl_siblings = cl;
+			/* Put new class at beginning of list */
+			cl->cl_siblings = parent->cl_children;
+			parent->cl_children = cl;
 		}
 	}
 	IFQ_UNLOCK(hif->hif_ifq);