selftests: drv-net: pp_alloc_fail: restore ring size after timeout
Subsystems (3)
PATCH 1/1 selftests: drv-net: pp_alloc_fail: restore ring size after timeout
The test restores the original RX ring size only if the command to change it returns successfully. The cmd() helper raises TimeoutExpired after 20 seconds but does not terminate the ethtool subprocess or wait for it to finish. The subprocess may therefore continue running and leave the new ring size applied despite the timeout, while the test skips restoration.
This was observed in a NIPA run. The first attempt reported:
subprocess.TimeoutExpired: Command '['ethtool', '-G', 'ens25f1np1',
'rx', '2048']' timed out after 20 secondsThe subsequent retry attempt then reported:
subprocess.TimeoutExpired: Command '['ethtool', '-G', 'ens25f1np1',
'rx', '4096']' timed out after 20 secondsThe retry attempted to increase the ring from 2048 to 4096, showing that the first command had applied the change despite the timeout.
Register the restoration with defer() before running the command so it is attempted if cmd() times out. If the restoration also times out, its ethtool subprocess is likewise left running and may eventually restore the original ring size, avoiding a persistent configuration leak.
---
Would it be preferable for cmd() to terminate and wait for timed-out subprocesses?
--- .../testing/selftests/drivers/net/hw/pp_alloc_fail.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tools/testing/selftests/drivers/net/hw/pp_alloc_fail.py +4 -6
@@ -13,7 +13,7 @@ from lib.py import ksft_run, ksft_exit, ksft_pr from lib.py import KsftSkipEx, KsftFailEx from lib.py import NetdevFamily, NlError from lib.py import NetDrvEpEnv -from lib.py import cmd, tool, GenerateTraffic +from lib.py import cmd, defer, ethtool, tool, GenerateTraffic def _write_fail_config(config):
@@ -77,7 +77,6 @@ def test_pp_alloc(cfg, netdevnl): if 'rx-alloc-fail' not in stats: raise KsftSkipEx("Driver does not report 'rx-alloc-fail' via qstats") - set_g = False traffic = None try: traffic = GenerateTraffic(cfg)
@@ -112,10 +111,11 @@ def test_pp_alloc(cfg, netdevnl): new_g = None if new_g: - set_g = cmd(f"ethtool -G {cfg.ifname} rx {new_g}", fail=False).ret == 0 - if set_g: + restore_g = defer(ethtool, f"-G {cfg.ifname} rx {g['rx']}") + if cmd(f"ethtool -G {cfg.ifname} rx {new_g}", fail=False).ret == 0: ksft_pr("ethtool -G change retval: success") else: + restore_g.cancel() ksft_pr("ethtool -G change retval: did not succeed", new_g) else: ksft_pr("ethtool -G change retval: did not try")
@@ -127,8 +127,6 @@ def test_pp_alloc(cfg, netdevnl): if traffic: traffic.stop() time.sleep(0.1) - if set_g: - cmd(f"ethtool -G {cfg.ifname} rx {g['rx']}") def main() -> None:
Signature · 1 line
2.45.0
Jakub Kicinski
maintainerQuoted 2 lines · On Tue, 25 Aug 2026 12:07:58 +0300 Nimrod Oren wrote:
Would it be preferable for
cmd()to terminate and wait for timed-out subprocesses?
Meaning send a kill signal and then wait? Does it help anything?
Regarding the patch - I'm not sure we should be complicating tests for this. How about we make NIPA reboot the machine if it sees subprocess.TimeoutExpired ? Adding defer()s before seems like a bit of a whack-a-mole.
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines · On Tue, 25 Aug 2026 12:07:58 +0300 Nimrod Oren wrote:
Would it be preferable for
cmd()to terminate and wait for timed-out subprocesses?Meaning send a kill signal and then wait? Does it help anything?
It can help isolate tests so unwanted behavior does not carry over, like the timed-out ethtool command continuing to hold the RTNL lock. Rebooting would address this too.
Quoted 4 lines
Regarding the patch - I'm not sure we should be complicating tests for this. How about we make NIPA reboot the machine if it sees subprocess.TimeoutExpired ? Adding defer()s before seems like a bit of a whack-a-mole.
Sounds good to me. Rebooting will be cleaner.
Jakub Kicinski
maintainerQuoted 6 lines · On Sun, 30 Aug 2026 11:05:52 +0300 Nimrod Oren wrote:
Quoted 4 lines
Regarding the patch - I'm not sure we should be complicating tests for this. How about we make NIPA reboot the machine if it sees subprocess.TimeoutExpired ? Adding defer()s before seems like a bit of a whack-a-mole.
Sounds good to me. Rebooting will be cleaner.
Done, currently pending runs should see the new code so we'll know if it gets handled right soon.