Breno Leitao wrote:
Add a basic selftest for the netpoll polling mechanism, specifically targeting the netpoll poll() side.
The test creates a scenario where network transmission is running at maximum speed, and netpoll needs to poll the NIC. This is achieved by:
- Configuring a single RX/TX queue to create contention
- Generating background traffic to saturate the interface
- Sending netconsole messages to trigger netpoll polling
- Using dynamic netconsole targets via configfs
- Delete and create new netconsole targets after some messages
- Start a bpftrace in parallel to make sure netpoll_poll_dev() is called
- If bpftrace exists and netpoll_poll_dev() was called, stop.
The test validates a critical netpoll code path by monitoring traffic flow and ensuring netpoll_poll_dev() is called when the normal TX path is blocked.
This addresses a gap in netpoll test coverage for a path that is tricky for the network stack.
Signed-off-by: Breno Leitao leitao@debian.org
+def bpftrace_call() -> None:
- """Call bpftrace to find how many times netpoll_poll_dev() is called.
- Output is saved in the global variable `maps`"""
- # This is going to update the global variable, that will be seen by the
- # main function
- global MAPS # pylint: disable=W0603
- # This will be passed to bpftrace as in bpftrace -e "expr"
- expr = "BEGIN{ @hits = 0;} kprobe:netpoll_poll_dev { @hits += 1; }"
Is that BEGIN statement needed? I generally just use count().
- MAPS = bpftrace(expr, timeout=BPFTRACE_TIMEOUT, json=True)
- logging.debug("BPFtrace output: %s", MAPS)
+def bpftrace_start():
- """Start a thread to call `call_bpf` in parallel for 2 seconds."""
Stale comment? BPFTRACE_TIMEOUT is set to 15.
- global BPF_THREAD # pylint: disable=W0603
- BPF_THREAD = threading.Thread(target=bpftrace_call)
- BPF_THREAD.start()
- if not BPF_THREAD.is_alive():
raise KsftSkipEx("BPFtrace thread is not alive. Skipping test")