libbpf-tools: update llcstat for libbpf 1.0
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 17 Dec 2021 22:32:29 +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/llcstat.bpf.c
libbpf-tools/llcstat.c

index fbd5b6c439533c1b6efb512f5dcee26517deef96..a36fc2dfbf9f9e69c32bc6c9721ebcda06c5b27d 100644 (file)
@@ -36,13 +36,13 @@ int trace_event(__u64 sample_period, bool miss)
        return 0;
 }
 
-SEC("perf_event/1")
+SEC("perf_event")
 int on_cache_miss(struct bpf_perf_event_data *ctx)
 {
        return trace_event(ctx->sample_period, true);
 }
 
-SEC("perf_event/2")
+SEC("perf_event")
 int on_cache_ref(struct bpf_perf_event_data *ctx)
 {
        return trace_event(ctx->sample_period, false);
index 13e9f0fb593b563d0204e5f0b226fe85569ac907..89b49efeb5435fae3b8ba304d3c477b2dc237f15 100644 (file)
@@ -106,10 +106,8 @@ static int open_and_attach_perf_event(__u64 config, int period,
                        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;
                }
@@ -185,14 +183,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) {
                fprintf(stderr, "failed to get # of possible cpus: '%s'!\n",