Skip to contentSkip to conversation

selftests: drv-net: test drivers sleeping in ndo_get_stats64

PATCH Applied Jakub Kicinski 2 participants 2 messages Jan 7, 2025 – Jan 9, 2025

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH v2 1/1 selftests: drv-net: test drivers sleeping in ndo_get_stats64

Most of our tests use rtnetlink to read device stats, so they don't expose the drivers much to paths in which device stats are read under RCU. Add tests which hammer profcs reads to make sure drivers:
- don't sleep while reporting stats,
- can handle parallel reads,
- can handle device going down while reading.

Set ifname on the env class in NetDrvEnv, we already do that in NetDrvEpEnv.

KTAP version 1
1..7
ok 1 stats.check_pause
ok 2 stats.check_fec
ok 3 stats.pkt_byte_sum
ok 4 stats.qstat_by_ifindex
ok 5 stats.check_down
ok 6 stats.procfs_hammer

  # completed up/down cycles: 6
  ok 7 stats.procfs_downup_hammer
  # Totals: pass:7 fail:0 xfail:0 xpass:0 skip:0 error:0

---
CC: [email protected]
CC: [email protected]

v2:
- fix spelling in a comment
v1: https://lore.kernel.org/[email protected]

---
 .../selftests/drivers/net/lib/py/env.py       |  1 +
 tools/testing/selftests/drivers/net/stats.py  | 94 ++++++++++++++++++-
 tools/testing/selftests/net/lib/py/ksft.py    |  5 +
 3 files changed, 97 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/lib/py/env.py +1 -0
index fea343f209ea..987e452d3a45 100644
@@ -48,6 +48,7 @@ from .remote import Remote
         else:
             self._ns = NetdevSimDev(**kwargs)
             self.dev = self._ns.nsims[0].dev
+        self.ifname = self.dev['ifname']
         self.ifindex = self.dev['ifindex']
 
     def __enter__(self):
tools/testing/selftests/drivers/net/stats.py +91 -3

113 lines not on this page · raw message

tools/testing/selftests/net/lib/py/ksft.py +5 -0
index 477ae76de93d..3efe005436cd 100644
@@ -71,6 +71,11 @@ KSFT_DISRUPTIVE = True
         _fail("Check failed", a, "not in", b, comment)
 
 
+def ksft_is(a, b, comment=""):
+    if a is not b:
+        _fail("Check failed", a, "is not", b, comment)
+
+
 def ksft_ge(a, b, comment=""):
     if a < b:
         _fail("Check failed", a, "<", b, comment)
Signature · 1 line
2.47.1
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Mon, 6 Jan 2025 18:29:32 -0800 you wrote:

Most of our tests use rtnetlink to read device stats, so they don't expose the drivers much to paths in which device stats are read under RCU. Add tests which hammer profcs reads to make sure drivers:
- don't sleep while reporting stats,
- can handle parallel reads,
- can handle device going down while reading.

[...]

Here is the summary with links:
- [net-next,v2] selftests: drv-net: test drivers sleeping in ndo_get_stats64

    https://git.kernel.org/netdev/net-next/c/31eae6d99587

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html