Reducing limit or memory_limit in dualpi2_change() removes packets with qdisc_dequeue_internal(), bypassing the timestamp refresh performed by dequeue_packet(). The cached c_head_ts and l_head_ts can therefore refer to a packet that has already been removed. A drained queue keeps a nonzero timestamp and reports an increasing delay; a partially trimmed queue reports the delay of its old head. These stale delays are also used by the PI2 controller. Refresh both cached timestamps from the internal queue heads after the trim loop, while still holding the qdisc tree lock. head_enqueue_time() returns zero when the corresponding queue is empty. I identified the issue and reviewed the fix. OpenAI Codex assisted with root-cause analysis, the fix and changelog, and automated validation. Local regression checks on arm64 net-tree kernels in QEMU pass three controls and fail eight trimming checks before the fix; all 11 pass with the fix. The tests use real AF_PACKET traffic in an isolated network namespace with HFSC shaping, without fault injection. Fixes: 8f9516daedd6 ("sched: Add enqueue/dequeue of dualpi2 qdisc") Cc: stable@vger.kernel.org Signed-off-by: Zhiqi Zhang --- Changes in v2: - Drop the 659-line selftest patch following review; retain the regression checks for local validation. The qdisc fix is unchanged. - Add Chia-Yu Chang to CC and use Koen De Schepper's current primary IETF address; the Nokia Bell Labs address used in v1 bounced. - Check the patch with --strict --max-line-length=80. The local before/after tests cover C/L dequeue, complete and partial trimming, mixed queues, and a configuration change without trimming. The baseline passes three controls and fails eight trimming checks; the fixed kernel passes all 11. These tests are not part of v2. The two-line fix and its arm64 W=1 object-build results are unchanged from v1. This revision does not claim a new full kernel build. AI assistance: I used OpenAI Codex for root-cause analysis, drafting the fix, initial tests and changelog, and automated validation. The revision prompt asked to address the review of the DualPI2 patch. V1: https://lore.kernel.org/netdev/20261118143500.dualpi2.1.543a9a1be910-zhiqizhangg@gmail.com/ Review: https://lore.kernel.org/netdev/willemb.4158a0ba73d8@google.com/ net/sched/sch_dualpi2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sched/sch_dualpi2.c b/net/sched/sch_dualpi2.c index 4947def7c4..79eba7209e 100644 --- a/net/sched/sch_dualpi2.c +++ b/net/sched/sch_dualpi2.c @@ -938,6 +938,8 @@ static int dualpi2_change(struct Qdisc *sch, struct nlattr *opt, break; } } + WRITE_ONCE(q->c_head_ts, head_enqueue_time(sch)); + WRITE_ONCE(q->l_head_ts, head_enqueue_time(q->l_queue)); qdisc_tree_reduce_backlog(sch, old_qlen - qdisc_qlen(sch), old_backlog - sch->qstats.backlog);