git: 990e592daeb3 - stable/13 - ip_reass: do less work in ipreass_slowtimo if possible

Mateusz Guzik mjg at FreeBSD.org
Wed Aug 18 09:47:07 UTC 2021


The branch stable/13 has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=990e592daeb3aa7aad1881d999a6b95c15320df7

commit 990e592daeb3aa7aad1881d999a6b95c15320df7
Author:     Mateusz Guzik <mjg at FreeBSD.org>
AuthorDate: 2021-08-13 09:32:16 +0000
Commit:     Mateusz Guzik <mjg at FreeBSD.org>
CommitDate: 2021-08-18 09:44:44 +0000

    ip_reass: do less work in ipreass_slowtimo if possible
    
    ipreass_slowtimo avoidably uses CPU on otherwise idle boxes
    
    Reviewed by:    kp
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D31526
    
    (cherry picked from commit 3be3cbe06d6107486d67d8eb80480d34d084c39c)
---
 sys/netinet/ip_reass.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/ip_reass.c b/sys/netinet/ip_reass.c
index 8a071345677a..db32e6a312f2 100644
--- a/sys/netinet/ip_reass.c
+++ b/sys/netinet/ip_reass.c
@@ -593,11 +593,16 @@ ipreass_slowtimo(void)
 {
 	struct ipq *fp, *tmp;
 
+	if (atomic_load_int(&nfrags) == 0)
+		return;
+
 	for (int i = 0; i < IPREASS_NHASH; i++) {
+		if (TAILQ_EMPTY(&V_ipq[i].head))
+			continue;
 		IPQ_LOCK(i);
 		TAILQ_FOREACH_SAFE(fp, &V_ipq[i].head, ipq_list, tmp)
 		if (--fp->ipq_ttl == 0)
-				ipq_timeout(&V_ipq[i], fp);
+			ipq_timeout(&V_ipq[i], fp);
 		IPQ_UNLOCK(i);
 	}
 }


More information about the dev-commits-src-all mailing list