On systems with many CPUs (e.g. 128 cores x 4 HW breakpoint slots = 512 = MAX_TEST_BREAKPOINTS), test_many_cpus() advances idx to MAX_TEST_BREAKPOINTS after the last fill_bp_slots(). The subsequent register_test_bp() call hits WARN_ON(idx >= MAX_TEST_BREAKPOINTS), returns NULL, and the -ENOSPC expectation fails. Bail out of the loop when idx reaches the limit. Earlier iterations already validate the NOSPC path on other CPUs. To: Peter Zijlstra To: Ingo Molnar To: Arnaldo Carvalho de Melo To: Namhyung Kim To: Mark Rutland To: Alexander Shishkin To: Jiri Olsa To: Ian Rogers To: Adrian Hunter To: James Clark Cc: linux-perf-users@vger.kernel.org Signed-off-by: Jia He --- kernel/events/hw_breakpoint_test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/events/hw_breakpoint_test.c b/kernel/events/hw_breakpoint_test.c index 2cfeeecf8de9..943d040d2224 100644 --- a/kernel/events/hw_breakpoint_test.c +++ b/kernel/events/hw_breakpoint_test.c @@ -137,6 +137,9 @@ static void test_many_cpus(struct kunit *test) for_each_online_cpu(cpu) { bool do_continue = fill_bp_slots(test, &idx, cpu, NULL, 0); + if (idx >= MAX_TEST_BREAKPOINTS) + break; + TEST_EXPECT_NOSPC(register_test_bp(cpu, NULL, idx)); if (!do_continue) break; -- 2.34.1