1 | // SPDX-License-Identifier: GPL-2.0 |
2 | /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ |
3 | |
4 | #include "vmlinux.h" |
5 | #include <bpf/bpf_helpers.h> |
6 | #include <bpf/usdt.bpf.h> |
7 | |
8 | /* this file is linked together with test_usdt.c to validate that usdt.bpf.h |
9 | * can be included in multiple .bpf.c files forming single final BPF object |
10 | * file |
11 | */ |
12 | |
13 | extern int my_pid; |
14 | |
15 | int usdt_100_called; |
16 | int usdt_100_sum; |
17 | |
18 | SEC("usdt//proc/self/exe:test:usdt_100" ) |
19 | int BPF_USDT(usdt_100, int x) |
20 | { |
21 | if (my_pid != (bpf_get_current_pid_tgid() >> 32)) |
22 | return 0; |
23 | |
24 | __sync_fetch_and_add(&usdt_100_called, 1); |
25 | __sync_fetch_and_add(&usdt_100_sum, x); |
26 | |
27 | return 0; |
28 | } |
29 | |
30 | char _license[] SEC("license" ) = "GPL" ; |
31 | |