Commit b0c7663d authored by Andrii Nakryiko's avatar Andrii Nakryiko

Merge branch 'selftests/bpf: Fixes for perf_buffer test'

Jiri Olsa says:

====================

hi,
sending fixes for perf_buffer test on systems
with offline cpus.

v2:
  - resend due to delivery issues, no changes

thanks,
jirka
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
====================
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents 8082b856 99d09975
......@@ -45,7 +45,7 @@ int trigger_on_cpu(int cpu)
void serial_test_perf_buffer(void)
{
int err, on_len, nr_on_cpus = 0, nr_cpus, i;
int err, on_len, nr_on_cpus = 0, nr_cpus, i, j;
struct perf_buffer_opts pb_opts = {};
struct test_perf_buffer *skel;
cpu_set_t cpu_seen;
......@@ -107,19 +107,19 @@ 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++) {
for (i = 0, j = 0; i < nr_cpus; i++) {
if (i >= on_len || !online[i])
continue;
fd = perf_buffer__buffer_fd(pb, i);
fd = perf_buffer__buffer_fd(pb, j);
CHECK(fd < 0 || last_fd == fd, "fd_check", "last fd %d == fd %d\n", last_fd, fd);
last_fd = fd;
err = perf_buffer__consume_buffer(pb, i);
err = perf_buffer__consume_buffer(pb, j);
if (CHECK(err, "drain_buf", "cpu %d, err %d\n", i, err))
goto out_close;
......@@ -127,12 +127,13 @@ void serial_test_perf_buffer(void)
if (trigger_on_cpu(i))
goto out_close;
err = perf_buffer__consume_buffer(pb, i);
if (CHECK(err, "consume_buf", "cpu %d, err %d\n", i, err))
err = perf_buffer__consume_buffer(pb, j);
if (CHECK(err, "consume_buf", "cpu %d, err %d\n", j, err))
goto out_close;
if (CHECK(!CPU_ISSET(i, &cpu_seen), "cpu_seen", "cpu %d not seen\n", i))
goto out_close;
j++;
}
out_free_pb:
......
......@@ -12,7 +12,7 @@ struct {
__type(value, int);
} perf_buf_map SEC(".maps");
SEC("tp/raw_syscalls/sys_enter")
SEC("tp/syscalls/sys_enter_nanosleep")
int handle_sys_enter(void *ctx)
{
int cpu = bpf_get_smp_processor_id();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment