]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/bpf: Add timer stress test in NMI context
authorMykyta Yatsenko <yatsenko@meta.com>
Sun, 1 Feb 2026 02:54:01 +0000 (18:54 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 4 Feb 2026 00:58:47 +0000 (16:58 -0800)
commit083c5a4babad4af89dd07e2cc5f7004343d4c1f0
treed989124767e6edadee9ad8d4ccf06459eeaee622
parentfe9d205cec8ccdd13171a056257101374306e802
selftests/bpf: Add timer stress test in NMI context

Add stress tests for BPF timers that run in NMI context using perf_event
programs attached to PERF_COUNT_HW_CPU_CYCLES.

The tests cover three scenarios:
- nmi_race: Tests concurrent timer start and async cancel operations
- nmi_update: Tests updating a map element (effectively deleting and
  inserting new for array map) from within a timer callback
- nmi_cancel: Tests timer self-cancellation attempt.

A common test_common() helper is used to share timer setup logic across
all test modes.

The tests spawn multiple threads in a child process to generate
perf events, which trigger the BPF programs in NMI context. Hit counters
verify that the NMI code paths were actually exercised.

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260201025403.66625-8-alexei.starovoitov@gmail.com
tools/testing/selftests/bpf/prog_tests/timer.c
tools/testing/selftests/bpf/progs/timer.c