sfer-encoding:content-transfer-encoding; bh=D5X6a8Xvk5wU38bHYqpXPXEo8K6XNg/3cmvJ5KdpYXY=; b=V8FEe0VHgUL6F2ocvJDY8+o5lK5uujVYKGMfRaTXYczQTHIKulftx+v6S3aiJhFWGKs2ie arlJHEr99Q1EK6BB+XPRM3giTcLabigohGau0yuhRLE4EehWmeKGj6hgos6ZjOWTMj2buV obLWBERzFIH+F0AUcAkd5xrW7k3BC0vj4RILmCOCVHcRw4QGLpT9vOPeztoYfgNTHiKrZB g3XEyCzqQGEFaFydS5KpCioiHcI04PfDy25AIcgNbdOIFIGg3SWRKASmj9yPh8jOZMv6h/ G4R2JdbPdIcAnqcajqbl/Ra51XYvmDF6MVtjwdZyXC5hcwQ5qBhwlupOSoAngQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760387162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D5X6a8Xvk5wU38bHYqpXPXEo8K6XNg/3cmvJ5KdpYXY=; b=T79jHPryfzJe7BEbJb/UXrG+1KAIxQt1nzP7Dv4hXxxWGa960ojdk0fRsGbZ6q3/YNdQGP UZGhCRyfMzXPOnOHZblUqJsCcbT9jO17cqa7QdThu1RrREC46d8t307RW9mG8M97qWq/lg AQt20EZf28fIire0Wj+/lg9z6TXoHpOeZ/80VQ1XZtBAeA0KbdHRL7vZ8pT261GcQ/uZ/+ ELtl5EpfpD66y9uOoES/V5axojjluAGzKRLdybRmzOUGXLHMOeEy9ZLxeA2u5w2ZIeDRE/ n/14e5jYH1yWgFwc97QGJv6LH8sM8P6+HF0IHztMdQwTC+qd8rXyWnfKzOPT1w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760387162; a=rsa-sha256; cv=none; b=mFmoHSKG5G7o6nX+MLpVlHDCZQxlCfb2BAqXGrqKgfj0W0rEU1om0aZSLr26Psgc6++JOF G61/24Wvm20xqY0giHn0gGRvw5WX+Wa4iwDE0/SppJBCYNFpj98ChjHvS/DPUb0HzhuXOY +RP3HF3YbUF7+Bu7Y2sneI3YJwxF0boT1VuoSV+Ga8P62j8L6078dX1daQg3kff5lYsg4I Zhd6xvuUbZTIwfvcvF+cpVJKRdrLtl9d/Q7b/Ctca5gZY/RkJEusxKprZ+LJzSsLOHJ8HK EL2YQKz/gune5HkBk6fXNimRZZ1Pq7qzKCum4g21EkRCqNGmNH9nyjVsIxs6GQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4clplG5VMnz5n2; Mon, 13 Oct 2025 20:26:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59DKQ2FZ014239; Mon, 13 Oct 2025 20:26:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59DKQ2Iu014236; Mon, 13 Oct 2025 20:26:02 GMT (envelope-from git) Date: Mon, 13 Oct 2025 20:26:02 GMT Message-Id: <202510132026.59DKQ2Iu014236@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: e79941bcb9d8 - main - tcp: fix KASSERT in HPTS List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e79941bcb9d8758070a97d780582e097bb82396e Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=e79941bcb9d8758070a97d780582e097bb82396e commit e79941bcb9d8758070a97d780582e097bb82396e Author: Nick Banks AuthorDate: 2025-10-13 20:24:52 +0000 Commit: Michael Tuexen CommitDate: 2025-10-13 20:24:52 +0000 tcp: fix KASSERT in HPTS Reviewed by: tuexen Sponsored by: Netflix, Inc. --- sys/netinet/tcp_hpts.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c index b022cfba451d..fbab912b9a1f 100644 --- a/sys/netinet/tcp_hpts.c +++ b/sys/netinet/tcp_hpts.c @@ -1486,24 +1486,32 @@ no_run: */ hpts->p_wheel_complete = 1; /* - * Now did we spend too long running input and need to run more? - * Note that if wrap_loop_cnt < 2 then we should have the conditions - * in the KASSERT's true. But if the wheel is behind i.e. wrap_loop_cnt - * is greater than 2, then the condtion most likely are *not* true. - * Also if we are called not from the callout, we don't run the wheel - * multiple times so the slots may not align either. - */ - KASSERT(((hpts->p_prev_slot == hpts->p_cur_slot) || - (hpts->p_on_queue_cnt == 0) || - (wrap_loop_cnt >= 2) || !from_callout), - ("H:%p p_prev_slot:%u not equal to p_cur_slot:%u", hpts, - hpts->p_prev_slot, hpts->p_cur_slot)); - KASSERT((!tcp_hpts_different_slots(cts, cts_last_run) || - (hpts->p_on_queue_cnt == 0) || - (wrap_loop_cnt >= 2) || !from_callout), - ("H:%p cts_last_run:%u not close enough to cts:%u", hpts, - cts_last_run, cts)); - if (from_callout && ((cts - cts_last_run) >= HPTS_USECS_PER_SLOT)) { + * If enough time has elapsed that we should be processing the next + * slot(s), then we should have kept running and not marked the wheel as + * complete. + * + * But there are several other conditions where we would have stopped + * processing, so the prev/cur slots and cts variables won't match. + * These conditions are: + * + * - Calls not from callouts don't run multiple times + * - The wheel is empty + * - We've processed more than max_pacer_loops times + * - We've wrapped more than 2 times + * + * This assert catches when the logic above has violated this design. + * + */ + KASSERT((!from_callout || (hpts->p_on_queue_cnt == 0) || + (loop_cnt > max_pacer_loops) || (wrap_loop_cnt >= 2) || + ((hpts->p_prev_slot == hpts->p_cur_slot) && + !tcp_hpts_different_slots(cts, cts_last_run))), + ("H:%p Shouldn't be done! prev_slot:%u, cur_slot:%u, " + "cts_last_run:%u, cts:%u, loop_cnt:%d, wrap_loop_cnt:%d", + hpts, hpts->p_prev_slot, hpts->p_cur_slot, + cts_last_run, cts, loop_cnt, wrap_loop_cnt)); + + if (from_callout && tcp_hpts_different_slots(cts, cts_last_run)){ cts_last_run = tcp_pace.cts_last_ran[hpts->p_num]; tcp_pace.cts_last_ran[hpts->p_num] = cts = tcp_get_usecs(&tv); hpts->p_cur_slot = cts_to_wheel(cts);