|WARNING| sched: fix queue stats read for mixed subports

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Wed Nov 25 12:54:09 CET 2026


Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/173144

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-11-25

**Review: sched: fix queue stats read for mixed subports**

**Warning: the test enshrines rejection of a valid queue ID, so the fix is incomplete**

```
	/* Queue ID at or above the total queue count is rejected */
	err = rte_sched_queue_read_stats(port, 144, &queue_stats, &qlen);
	TEST_ASSERT_FAIL(err, "Queue ID 144 accepted, err=%d\n", err);
```

With `n_pipes_per_subport = 8`, each subport has 128 queue slots, so `subport_qmask` is 7. Queue ID 144 therefore decodes to subport 1, qindex 16, which is pipe 1, queue 0.

Subport 1 enables 8 pipes, so that is a real, enabled queue. `rte_sched_port_pkt_write(port, m, 1, 1, 0, ...)` would produce exactly this ID.

Per the commit message, the old check compares against the summed queue count (16 + 128 = 144). That check still rejects IDs 144..255, so stats for pipes 1..7 of subport 1 cannot be read at all.

This contradicts the commit message claim that "Queue IDs produced by rte_sched_port_pkt_write() are valid before and after the change".

The same problem shows up in the comment "First and last queue of the large subport 1 read cleanly" above the 128/143 reads. ID 143 is the last queue of pipe 0, not of subport 1; the last queue of subport 1 is ID 255.

Suggested fix: replace the total-count check with a check that the decoded `subport_id < port->n_subports_per_port`, and keep the new per-subport `subport_qindex` check. Then update the test:
- Expect ID 144 (and 255) to succeed.
- Use an ID that decodes past `n_subports_per_port` as the out-of-range case.

**Warning: resource leaks in the new test**

```
	mp = create_mempool();
	...
	err = rte_sched_port_dequeue(port, mbufs, 1);
	...
	rte_sched_port_free(port);

	return 0;
```

- The mempool `mp` is never freed, even on the success path.
- The dequeued mbuf `mbufs[0]` is never returned with `rte_pktmbuf_free()`.
- Every `TEST_ASSERT_*` failure after `rte_sched_port_config()` returns without calling `rte_sched_port_free(port)`.

Suggested fix: free the dequeued mbuf and call `rte_mempool_free(mp)` before returning. Use a cleanup label, or setup/teardown in a `unit_test_suite`, so failure paths release the port and the mempool.

**Info: consider using the unit test suite framework**

The new test is registered as a separate `REGISTER_FAST_TEST` with a duplicated Windows stub. Adding it as a `TEST_CASE` in a `unit_test_suite` alongside the existing sched test would remove the stub and give shared setup/teardown for cleanup.

Review-Result: WARNING


More information about the test-report mailing list