The branch main has been updated by tuexen:

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

commit e0838f8a2e61e73e37c1ae08eab9473daacaacb8
Author:     Peter Lei <peter...@netflix.com>
AuthorDate: 2025-07-21 07:56:03 +0000
Commit:     Michael Tuexen <tue...@freebsd.org>
CommitDate: 2025-07-21 07:56:03 +0000

    tcp rack: fix sendmap app limited count tracking
    
    rc_app_limited_cnt is an internal counter on the rack structure
    that tracks the number of sendmap entries that have the
    RACK_APP_LIMITED flag set. These entries gate goodput measurements.
    The counter is reported in a number of blackbox logging events.
    When a sendmap entry which has the RACK_APP_LIMITED flag set is
    cloned, the counter was not being maintained properly.
    While here, cleanup the counter check when a sendmap entry with
    the flag set is freed which previously hid this issue.
    
    Reviewed by:    tuexen
    MFC after:      1 week
    Sponsored by:   Netflix, Inc.
---
 sys/netinet/tcp_stacks/rack.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c
index f52e6fbddfef..b0342b4e3165 100644
--- a/sys/netinet/tcp_stacks/rack.c
+++ b/sys/netinet/tcp_stacks/rack.c
@@ -3480,9 +3480,9 @@ static void
 rack_free(struct tcp_rack *rack, struct rack_sendmap *rsm)
 {
        if (rsm->r_flags & RACK_APP_LIMITED) {
-               if (rack->r_ctl.rc_app_limited_cnt > 0) {
-                       rack->r_ctl.rc_app_limited_cnt--;
-               }
+               KASSERT((rack->r_ctl.rc_app_limited_cnt > 0),
+                   ("app_cnt %u, rsm %p", rack->r_ctl.rc_app_limited_cnt, 
rsm));
+               rack->r_ctl.rc_app_limited_cnt--;
        }
        if (rsm->r_limit_type) {
                /* currently there is only one limit type */
@@ -7044,6 +7044,9 @@ rack_clone_rsm(struct tcp_rack *rack, struct rack_sendmap 
*nrsm,
        /* Push bit must go to the right edge as well */
        if (rsm->r_flags & RACK_HAD_PUSH)
                rsm->r_flags &= ~RACK_HAD_PUSH;
+       /* Update the count if app limited */
+       if (nrsm->r_flags & RACK_APP_LIMITED)
+               rack->r_ctl.rc_app_limited_cnt++;
        /* Clone over the state of the hw_tls flag */
        nrsm->r_hw_tls = rsm->r_hw_tls;
        /*

Reply via email to