]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - samples/bpf/trace_event_user.c
samples/bpf: Make samples more libbpf-centric
[mirror_ubuntu-zesty-kernel.git] / samples / bpf / trace_event_user.c
index 9a130d31ecf258b601d20e52367443a18f02c11c..704fe9fa77b2b2bc2b45b48903e3dd6b9c188e27 100644 (file)
@@ -61,14 +61,14 @@ static void print_stack(struct key_t *key, __u64 count)
        int i;
 
        printf("%3lld %s;", count, key->comm);
-       if (bpf_lookup_elem(map_fd[1], &key->kernstack, ip) != 0) {
+       if (bpf_map_lookup_elem(map_fd[1], &key->kernstack, ip) != 0) {
                printf("---;");
        } else {
                for (i = PERF_MAX_STACK_DEPTH - 1; i >= 0; i--)
                        print_ksym(ip[i]);
        }
        printf("-;");
-       if (bpf_lookup_elem(map_fd[1], &key->userstack, ip) != 0) {
+       if (bpf_map_lookup_elem(map_fd[1], &key->userstack, ip) != 0) {
                printf("---;");
        } else {
                for (i = PERF_MAX_STACK_DEPTH - 1; i >= 0; i--)
@@ -98,10 +98,10 @@ static void print_stacks(void)
        int fd = map_fd[0], stack_map = map_fd[1];
 
        sys_read_seen = sys_write_seen = false;
-       while (bpf_get_next_key(fd, &key, &next_key) == 0) {
-               bpf_lookup_elem(fd, &next_key, &value);
+       while (bpf_map_get_next_key(fd, &key, &next_key) == 0) {
+               bpf_map_lookup_elem(fd, &next_key, &value);
                print_stack(&next_key, value);
-               bpf_delete_elem(fd, &next_key);
+               bpf_map_delete_elem(fd, &next_key);
                key = next_key;
        }
 
@@ -111,8 +111,8 @@ static void print_stacks(void)
        }
 
        /* clear stack map */
-       while (bpf_get_next_key(stack_map, &stackid, &next_id) == 0) {
-               bpf_delete_elem(stack_map, &next_id);
+       while (bpf_map_get_next_key(stack_map, &stackid, &next_id) == 0) {
+               bpf_map_delete_elem(stack_map, &next_id);
                stackid = next_id;
        }
 }