realtek: dsa: let the FDB dump walk reschedule

rtldsa_port_fdb_dump() calls cond_resched() every 64 rows, but at the
end of the loop, after the "continue" that skips each row that is not
a valid unicast entry. So it only reschedules when such a 64th row
happens to hold a valid unicast entry.

DSA calls the function once per port. On the 52-port HPE 1920-48G
(RTL8393) a full "bridge fdb show" walks the 16384 rows 52 times:
96 ms per port, 5.0 s in all. With PREEMPT_NONE no other task runs
on that CPU meanwhile. When the kernel's watchdog worker, which
toggles the board's external PT7A7514, waits on that CPU, it misses
its pings and the board resets during the dump, without any console
output.

Move cond_resched() to the top of the loop, as the L3 debugfs dumps
already do, so it runs every 64 rows whatever the row holds.

Tested on the HPE 1920-48G under ping load, with full dumps. Without
this change and the dump pinned to CPU0, 20 of 20 dumps completed
with the watchdog worker on CPU1; moved to CPU0 in the same boot, the
board reset on the first dump. With this change, 20 of 20 completed
with both on CPU0, 20 of 20 with CPU1 kept busy and 20 of 20 with
nothing pinned. Across those 60 dumps no two toggles of the watchdog
GPIO were more than 0.51 s apart. Not tested on other families.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25787
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
This commit is contained in:
Gennaro Cimmino authored and Markus Stockhausen committed 2026-10-10 18:57:18 +02:00
1 parent 7c8ca38c76
commit eb51d41b12
1 file changed
+3 -3
@@ -1049,6 +1049,9 @@ static int rtldsa_port_fdb_dump(struct dsa_switch *ds, int port,
for (int i = 0; i < uc_rows; i++) {
struct rtl838x_l2_entry e = {};
if (!((i + 1) % 64))
cond_resched();
priv->r->read_l2_entry_using_hash(i >> 2, i & 0x3, &e);
if (!e.valid || e.type != L2_UNICAST || e.is_trunk)
@@ -1056,9 +1059,6 @@ static int rtldsa_port_fdb_dump(struct dsa_switch *ds, int port,
if (e.port == port || e.port == RTL930X_PORT_IGNORE)
cb(e.mac, e.rvid, e.is_static, data);
if (!((i + 1) % 64))
cond_resched();
}
for (int i = 0; i < cam_rows; i++) {