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
13extern int my_pid;
14
15int usdt_100_called;
16int usdt_100_sum;
17
18SEC("usdt//proc/self/exe:test:usdt_100")
19int 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
30char _license[] SEC("license") = "GPL";
31

source code of linux/tools/testing/selftests/bpf/progs/test_usdt_multispec.c