libbpf-tools: update runqlen for libbpf 1.0
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 20 Dec 2021 21:21:26 +0000 (13:21 -0800)
Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
libbpf-tools/runqlen.c

index 5caa841b95b41259fa9ebc6769dd0551f89edcb9..43c65246249680eb32acc1deb10c91ce3e70a9a7 100644 (file)
@@ -145,10 +145,8 @@ static int open_and_attach_perf_event(int freq, struct bpf_program *prog,
                        return -1;
                }
                links[i] = bpf_program__attach_perf_event(prog, fd);
-               if (libbpf_get_error(links[i])) {
-                       fprintf(stderr, "failed to attach perf event on cpu: "
-                               "%d\n", i);
-                       links[i] = NULL;
+               if (!links[i]) {
+                       fprintf(stderr, "failed to attach perf event on cpu: %d\n", i);
                        close(fd);
                        return -1;
                }
@@ -232,14 +230,9 @@ int main(int argc, char **argv)
        if (err)
                return err;
 
+       libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
        libbpf_set_print(libbpf_print_fn);
 
-       err = bump_memlock_rlimit();
-       if (err) {
-               fprintf(stderr, "failed to increase rlimit: %d\n", err);
-               return 1;
-       }
-
        nr_cpus = libbpf_num_possible_cpus();
        if (nr_cpus < 0) {
                printf("failed to get # of possible cpus: '%s'!\n",