Skip to content

Commit

Permalink
selftests/bpf: Fix perf_buffer test on system with offline cpus
Browse files Browse the repository at this point in the history
The perf_buffer fails on system with offline cpus:

  # test_progs -t perf_buffer
  test_perf_buffer:PASS:nr_cpus 0 nsec
  test_perf_buffer:PASS:nr_on_cpus 0 nsec
  test_perf_buffer:PASS:skel_load 0 nsec
  test_perf_buffer:PASS:attach_kprobe 0 nsec
  test_perf_buffer:PASS:perf_buf__new 0 nsec
  test_perf_buffer:PASS:epoll_fd 0 nsec
  skipping offline CPU #24
  skipping offline CPU #25
  skipping offline CPU #26
  skipping offline CPU #27
  skipping offline CPU #28
  skipping offline CPU #29
  skipping offline CPU #30
  skipping offline CPU #31
  test_perf_buffer:PASS:perf_buffer__poll 0 nsec
  test_perf_buffer:PASS:seen_cpu_cnt 0 nsec
  test_perf_buffer:FAIL:buf_cnt got 24, expected 32
  Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED

Changing the test to check online cpus instead of possible.

Signed-off-by: Jiri Olsa <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Acked-by: John Fastabend <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
Jiri Olsa authored and anakryiko committed Oct 21, 2021
1 parent 8082b85 commit d412137
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/perf_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ void serial_test_perf_buffer(void)
"expect %d, seen %d\n", nr_on_cpus, CPU_COUNT(&cpu_seen)))
goto out_free_pb;

if (CHECK(perf_buffer__buffer_cnt(pb) != nr_cpus, "buf_cnt",
"got %zu, expected %d\n", perf_buffer__buffer_cnt(pb), nr_cpus))
if (CHECK(perf_buffer__buffer_cnt(pb) != nr_on_cpus, "buf_cnt",
"got %zu, expected %d\n", perf_buffer__buffer_cnt(pb), nr_on_cpus))
goto out_close;

for (i = 0; i < nr_cpus; i++) {
Expand Down

0 comments on commit d412137

Please sign in to comment.