* Re: [PATCH net 1/2] net/sched: dualpi2: refresh head timestamps after trimming
2026-11-18 6:39 ` [PATCH net 1/2] net/sched: dualpi2: refresh head timestamps after trimming Zhiqi Zhang
@ 2026-11-25 0:31 ` willemb
2026-11-25 2:27 ` [PATCH net v2] " Zhiqi Zhang
1 sibling, 0 replies; 4+ messages in thread
From: willemb @ 2026-11-25 0:31 UTC (permalink / raw)
To: Zhiqi Zhang, netdev
Cc: jhs, jiri, davem, edumazet, kuba, pabeni, horms, shuah,
koen.de_schepper, linux-kernel, linux-kselftest, stable
Zhiqi Zhang wrote:
> 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. If a queue is drained, its
> timestamp remains nonzero.
> get_queue_delays() continues reporting an increasing delay for the empty
> queue, and calculate_probability() uses that delay as input to the PI2
> controller. Partially trimmed queues also report the delay of the old
> head instead of the retained head.
> 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 this issue and reviewed the fix. I used OpenAI Codex for
> root-cause analysis, drafting the fix and this changelog, and assistance
> with regression-test development. Codex also performed automated
> validation; the archived results are described below.
> I reproduced the issue using Codex-assisted automated tests on an
> unmodified arm64 net-tree kernel in QEMU, with real AF_PACKET traffic
> in an isolated network namespace and HFSC ls/ul shaping to retain
> packets. No source changes or fault injection were
> used to trigger the bug. The companion kernel selftest covers C/L
> dequeue, full and partial trimming, mixed queues and no-trim changes:
> the baseline passes three controls and fails eight trimming checks;
> the fixed kernel passes all 11. Runtime coverage is this DualPI2 selftest
> on arm64. I also used Codex to build arm64 Images and compile the modified
> object with W=1; additional build coverage is in the cover letter.
> Fixes: 8f9516daedd6 ("sched: Add enqueue/dequeue of dualpi2 qdisc")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
The selftest flagged checkpatch issues. It is also many LoC if only
testing a single small issue. LLMs are good at generating tests, we
cannot include all.
Let's also include the original author.
pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH net v2] net/sched: dualpi2: refresh head timestamps after trimming
2026-11-18 6:39 ` [PATCH net 1/2] net/sched: dualpi2: refresh head timestamps after trimming Zhiqi Zhang
2026-11-25 0:31 ` willemb
@ 2026-11-25 2:27 ` Zhiqi Zhang
2026-12-02 4:20 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Zhiqi Zhang @ 2026-11-25 2:27 UTC (permalink / raw)
To: netdev
Cc: willemb, jhs, jiri, davem, edumazet, kuba, pabeni, horms,
koen0607, chia-yu.chang, linux-kernel, stable
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 <zhiqizhangg@gmail.com>
---
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);
^ permalink raw reply related [flat|nested] 4+ messages in thread