treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / test_perf_buffer.c
blobebfcc9f50c35bf1aa828330c8cb07d68f7a5d0a9
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
4 #include <linux/ptrace.h>
5 #include <linux/bpf.h>
6 #include <bpf/bpf_helpers.h>
7 #include "bpf_trace_helpers.h"
9 struct {
10 __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
11 __uint(key_size, sizeof(int));
12 __uint(value_size, sizeof(int));
13 } perf_buf_map SEC(".maps");
15 SEC("kprobe/sys_nanosleep")
16 int BPF_KPROBE(handle_sys_nanosleep_entry)
18 int cpu = bpf_get_smp_processor_id();
20 bpf_perf_event_output(ctx, &perf_buf_map, BPF_F_CURRENT_CPU,
21 &cpu, sizeof(cpu));
22 return 0;
25 char _license[] SEC("license") = "GPL";