Jakub Kicinski 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.
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
Signed-off-by: Jakub Kicinski kuba@kernel.org
Reviewed-by: Willem de Bruijn willemb@google.com
Two tiny comments, neither cause for respin.
+@ksft_disruptive +def procfs_downup_hammer(cfg) -> None:
- """
- Reading stats via procfs only holds the RCU lock, drivers often try
- to sleep when reading the stats, or don't protect against races.
- """
- # Max out the queues, we'll flip between max an 1
s/an/and/
- channels = ethnl.channels_get({'header': {'dev-index': cfg.ifindex}})
- if channels['combined-count'] == 0:
rx_type = 'rx'
- else:
rx_type = 'combined'
- cur_queue_cnt = channels[f'{rx_type}-count']
- max_queue_cnt = channels[f'{rx_type}-max']
- cmd(f"ethtool -L {cfg.ifname} {rx_type} {max_queue_cnt}")
- defer(cmd, f"ethtool -L {cfg.ifname} {rx_type} {cur_queue_cnt}")
- # Real test stats
- stats = __run_inf_loop("cat /proc/net/dev")
- defer(stats.kill)
- ipset = f"ip link set dev {cfg.ifname}"
- defer(ip, f"link set dev {cfg.ifname} up")
unimportant: could reference ipset here too, as in below.
- # The "echo -n 1" lets us count iterations below
- updown = f"{ipset} down; sleep 0.05; {ipset} up; sleep 0.05; " + \
f"ethtool -L {cfg.ifname} {rx_type} 1; " + \
f"ethtool -L {cfg.ifname} {rx_type} {max_queue_cnt}; " + \
"echo -n 1"