Andrew Geissler | 062316f | 2020-05-15 14:19:14 -0500 | [diff] [blame^] | 1 | From 366487b86a8c87954fb4ab7bd88ab49a929a32f6 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 13 Apr 2020 11:25:58 -0700 |
| 4 | Subject: [PATCH 2/2] Revert "selftests/bpf: Fix perf_buffer test on systems w/ |
| 5 | offline CPUs" |
| 6 | |
| 7 | This reverts commit 77bb53cb094828a31cd3c5b402899810f63073c1. |
| 8 | --- |
| 9 | .../selftests/bpf/prog_tests/perf_buffer.c | 29 ++++--------------- |
| 10 | 1 file changed, 5 insertions(+), 24 deletions(-) |
| 11 | |
| 12 | diff --git a/tools/testing/selftests/bpf/prog_tests/perf_buffer.c b/tools/testing/selftests/bpf/prog_tests/perf_buffer.c |
| 13 | index cf6c87936c69..3003fddc0613 100644 |
| 14 | --- a/tools/testing/selftests/bpf/prog_tests/perf_buffer.c |
| 15 | +++ b/tools/testing/selftests/bpf/prog_tests/perf_buffer.c |
| 16 | @@ -4,7 +4,6 @@ |
| 17 | #include <sched.h> |
| 18 | #include <sys/socket.h> |
| 19 | #include <test_progs.h> |
| 20 | -#include "libbpf_internal.h" |
| 21 | |
| 22 | static void on_sample(void *ctx, int cpu, void *data, __u32 size) |
| 23 | { |
| 24 | @@ -20,7 +19,7 @@ static void on_sample(void *ctx, int cpu, void *data, __u32 size) |
| 25 | |
| 26 | void test_perf_buffer(void) |
| 27 | { |
| 28 | - int err, prog_fd, on_len, nr_on_cpus = 0, nr_cpus, i, duration = 0; |
| 29 | + int err, prog_fd, nr_cpus, i, duration = 0; |
| 30 | const char *prog_name = "kprobe/sys_nanosleep"; |
| 31 | const char *file = "./test_perf_buffer.o"; |
| 32 | struct perf_buffer_opts pb_opts = {}; |
| 33 | @@ -30,27 +29,15 @@ void test_perf_buffer(void) |
| 34 | struct bpf_object *obj; |
| 35 | struct perf_buffer *pb; |
| 36 | struct bpf_link *link; |
| 37 | - bool *online; |
| 38 | |
| 39 | nr_cpus = libbpf_num_possible_cpus(); |
| 40 | if (CHECK(nr_cpus < 0, "nr_cpus", "err %d\n", nr_cpus)) |
| 41 | return; |
| 42 | |
| 43 | - err = parse_cpu_mask_file("/sys/devices/system/cpu/online", |
| 44 | - &online, &on_len); |
| 45 | - if (CHECK(err, "nr_on_cpus", "err %d\n", err)) |
| 46 | - return; |
| 47 | - |
| 48 | - for (i = 0; i < on_len; i++) |
| 49 | - if (online[i]) |
| 50 | - nr_on_cpus++; |
| 51 | - |
| 52 | /* load program */ |
| 53 | err = bpf_prog_load(file, BPF_PROG_TYPE_KPROBE, &obj, &prog_fd); |
| 54 | - if (CHECK(err, "obj_load", "err %d errno %d\n", err, errno)) { |
| 55 | - obj = NULL; |
| 56 | - goto out_close; |
| 57 | - } |
| 58 | + if (CHECK(err, "obj_load", "err %d errno %d\n", err, errno)) |
| 59 | + return; |
| 60 | |
| 61 | prog = bpf_object__find_program_by_title(obj, prog_name); |
| 62 | if (CHECK(!prog, "find_probe", "prog '%s' not found\n", prog_name)) |
| 63 | @@ -77,11 +64,6 @@ void test_perf_buffer(void) |
| 64 | /* trigger kprobe on every CPU */ |
| 65 | CPU_ZERO(&cpu_seen); |
| 66 | for (i = 0; i < nr_cpus; i++) { |
| 67 | - if (i >= on_len || !online[i]) { |
| 68 | - printf("skipping offline CPU #%d\n", i); |
| 69 | - continue; |
| 70 | - } |
| 71 | - |
| 72 | CPU_ZERO(&cpu_set); |
| 73 | CPU_SET(i, &cpu_set); |
| 74 | |
| 75 | @@ -99,8 +81,8 @@ void test_perf_buffer(void) |
| 76 | if (CHECK(err < 0, "perf_buffer__poll", "err %d\n", err)) |
| 77 | goto out_free_pb; |
| 78 | |
| 79 | - if (CHECK(CPU_COUNT(&cpu_seen) != nr_on_cpus, "seen_cpu_cnt", |
| 80 | - "expect %d, seen %d\n", nr_on_cpus, CPU_COUNT(&cpu_seen))) |
| 81 | + if (CHECK(CPU_COUNT(&cpu_seen) != nr_cpus, "seen_cpu_cnt", |
| 82 | + "expect %d, seen %d\n", nr_cpus, CPU_COUNT(&cpu_seen))) |
| 83 | goto out_free_pb; |
| 84 | |
| 85 | out_free_pb: |
| 86 | @@ -109,5 +91,4 @@ void test_perf_buffer(void) |
| 87 | bpf_link__destroy(link); |
| 88 | out_close: |
| 89 | bpf_object__close(obj); |
| 90 | - free(online); |
| 91 | } |
| 92 | -- |
| 93 | 2.26.0 |
| 94 | |