Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
0003 
0004 #include "vmlinux.h"
0005 #include <bpf/bpf_helpers.h>
0006 #include <bpf/usdt.bpf.h>
0007 
0008 /* this file is linked together with test_usdt.c to validate that usdt.bpf.h
0009  * can be included in multiple .bpf.c files forming single final BPF object
0010  * file
0011  */
0012 
0013 extern int my_pid;
0014 
0015 int usdt_100_called;
0016 int usdt_100_sum;
0017 
0018 SEC("usdt//proc/self/exe:test:usdt_100")
0019 int BPF_USDT(usdt_100, int x)
0020 {
0021     long tmp;
0022 
0023     if (my_pid != (bpf_get_current_pid_tgid() >> 32))
0024         return 0;
0025 
0026     __sync_fetch_and_add(&usdt_100_called, 1);
0027     __sync_fetch_and_add(&usdt_100_sum, x);
0028 
0029     return 0;
0030 }
0031 
0032 char _license[] SEC("license") = "GPL";