~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/bpf-utils.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
  2 
  3 #ifndef __PERF_BPF_UTILS_H
  4 #define __PERF_BPF_UTILS_H
  5 
  6 #define ptr_to_u64(ptr)    ((__u64)(unsigned long)(ptr))
  7 
  8 #ifdef HAVE_LIBBPF_SUPPORT
  9 
 10 #include <bpf/libbpf.h>
 11 
 12 /*
 13  * Get bpf_prog_info in continuous memory
 14  *
 15  * struct bpf_prog_info has multiple arrays. The user has option to choose
 16  * arrays to fetch from kernel. The following APIs provide an uniform way to
 17  * fetch these data. All arrays in bpf_prog_info are stored in a single
 18  * continuous memory region. This makes it easy to store the info in a
 19  * file.
 20  *
 21  * Before writing perf_bpil to files, it is necessary to
 22  * translate pointers in bpf_prog_info to offsets. Helper functions
 23  * bpil_addr_to_offs() and bpil_offs_to_addr()
 24  * are introduced to switch between pointers and offsets.
 25  *
 26  * Examples:
 27  *   # To fetch map_ids and prog_tags:
 28  *   __u64 arrays = (1UL << PERF_BPIL_MAP_IDS) |
 29  *           (1UL << PERF_BPIL_PROG_TAGS);
 30  *   struct perf_bpil *info_linear =
 31  *           get_bpf_prog_info_linear(fd, arrays);
 32  *
 33  *   # To save data in file
 34  *   bpil_addr_to_offs(info_linear);
 35  *   write(f, info_linear, sizeof(*info_linear) + info_linear->data_len);
 36  *
 37  *   # To read data from file
 38  *   read(f, info_linear, <proper_size>);
 39  *   bpil_offs_to_addr(info_linear);
 40  */
 41 enum perf_bpil_array_types {
 42         PERF_BPIL_FIRST_ARRAY = 0,
 43         PERF_BPIL_JITED_INSNS = 0,
 44         PERF_BPIL_XLATED_INSNS,
 45         PERF_BPIL_MAP_IDS,
 46         PERF_BPIL_JITED_KSYMS,
 47         PERF_BPIL_JITED_FUNC_LENS,
 48         PERF_BPIL_FUNC_INFO,
 49         PERF_BPIL_LINE_INFO,
 50         PERF_BPIL_JITED_LINE_INFO,
 51         PERF_BPIL_PROG_TAGS,
 52         PERF_BPIL_LAST_ARRAY,
 53 };
 54 
 55 struct perf_bpil {
 56         /* size of struct bpf_prog_info, when the tool is compiled */
 57         __u32                   info_len;
 58         /* total bytes allocated for data, round up to 8 bytes */
 59         __u32                   data_len;
 60         /* which arrays are included in data */
 61         __u64                   arrays;
 62         struct bpf_prog_info    info;
 63         __u8                    data[];
 64 };
 65 
 66 struct perf_bpil *
 67 get_bpf_prog_info_linear(int fd, __u64 arrays);
 68 
 69 void
 70 bpil_addr_to_offs(struct perf_bpil *info_linear);
 71 
 72 void
 73 bpil_offs_to_addr(struct perf_bpil *info_linear);
 74 
 75 #endif /* HAVE_LIBBPF_SUPPORT */
 76 #endif /* __PERF_BPF_UTILS_H */
 77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php