162306a36Sopenharmony_ci.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci================ 462306a36Sopenharmony_cibpftool-prog 562306a36Sopenharmony_ci================ 662306a36Sopenharmony_ci------------------------------------------------------------------------------- 762306a36Sopenharmony_citool for inspection and simple manipulation of eBPF progs 862306a36Sopenharmony_ci------------------------------------------------------------------------------- 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci:Manual section: 8 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci.. include:: substitutions.rst 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciSYNOPSIS 1562306a36Sopenharmony_ci======== 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci **bpftool** [*OPTIONS*] **prog** *COMMAND* 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci *OPTIONS* := { |COMMON_OPTIONS| | 2062306a36Sopenharmony_ci { **-f** | **--bpffs** } | { **-m** | **--mapcompat** } | { **-n** | **--nomount** } | 2162306a36Sopenharmony_ci { **-L** | **--use-loader** } } 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci *COMMANDS* := 2462306a36Sopenharmony_ci { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load** | 2562306a36Sopenharmony_ci **loadall** | **help** } 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciPROG COMMANDS 2862306a36Sopenharmony_ci============= 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci| **bpftool** **prog** { **show** | **list** } [*PROG*] 3162306a36Sopenharmony_ci| **bpftool** **prog dump xlated** *PROG* [{ **file** *FILE* | [**opcodes**] [**linum**] [**visual**] }] 3262306a36Sopenharmony_ci| **bpftool** **prog dump jited** *PROG* [{ **file** *FILE* | [**opcodes**] [**linum**] }] 3362306a36Sopenharmony_ci| **bpftool** **prog pin** *PROG* *FILE* 3462306a36Sopenharmony_ci| **bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** { **idx** *IDX* | **name** *NAME* } *MAP*] [{ **offload_dev** | **xdpmeta_dev** } *NAME*] [**pinmaps** *MAP_DIR*] [**autoattach**] 3562306a36Sopenharmony_ci| **bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*] 3662306a36Sopenharmony_ci| **bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*] 3762306a36Sopenharmony_ci| **bpftool** **prog tracelog** 3862306a36Sopenharmony_ci| **bpftool** **prog run** *PROG* **data_in** *FILE* [**data_out** *FILE* [**data_size_out** *L*]] [**ctx_in** *FILE* [**ctx_out** *FILE* [**ctx_size_out** *M*]]] [**repeat** *N*] 3962306a36Sopenharmony_ci| **bpftool** **prog profile** *PROG* [**duration** *DURATION*] *METRICs* 4062306a36Sopenharmony_ci| **bpftool** **prog help** 4162306a36Sopenharmony_ci| 4262306a36Sopenharmony_ci| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* } 4362306a36Sopenharmony_ci| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* | **name** *PROG_NAME* } 4462306a36Sopenharmony_ci| *TYPE* := { 4562306a36Sopenharmony_ci| **socket** | **kprobe** | **kretprobe** | **classifier** | **action** | 4662306a36Sopenharmony_ci| **tracepoint** | **raw_tracepoint** | **xdp** | **perf_event** | **cgroup/skb** | 4762306a36Sopenharmony_ci| **cgroup/sock** | **cgroup/dev** | **lwt_in** | **lwt_out** | **lwt_xmit** | 4862306a36Sopenharmony_ci| **lwt_seg6local** | **sockops** | **sk_skb** | **sk_msg** | **lirc_mode2** | 4962306a36Sopenharmony_ci| **cgroup/bind4** | **cgroup/bind6** | **cgroup/post_bind4** | **cgroup/post_bind6** | 5062306a36Sopenharmony_ci| **cgroup/connect4** | **cgroup/connect6** | **cgroup/getpeername4** | **cgroup/getpeername6** | 5162306a36Sopenharmony_ci| **cgroup/getsockname4** | **cgroup/getsockname6** | **cgroup/sendmsg4** | **cgroup/sendmsg6** | 5262306a36Sopenharmony_ci| **cgroup/recvmsg4** | **cgroup/recvmsg6** | **cgroup/sysctl** | 5362306a36Sopenharmony_ci| **cgroup/getsockopt** | **cgroup/setsockopt** | **cgroup/sock_release** | 5462306a36Sopenharmony_ci| **struct_ops** | **fentry** | **fexit** | **freplace** | **sk_lookup** 5562306a36Sopenharmony_ci| } 5662306a36Sopenharmony_ci| *ATTACH_TYPE* := { 5762306a36Sopenharmony_ci| **sk_msg_verdict** | **sk_skb_verdict** | **sk_skb_stream_verdict** | 5862306a36Sopenharmony_ci| **sk_skb_stream_parser** | **flow_dissector** 5962306a36Sopenharmony_ci| } 6062306a36Sopenharmony_ci| *METRICs* := { 6162306a36Sopenharmony_ci| **cycles** | **instructions** | **l1d_loads** | **llc_misses** | 6262306a36Sopenharmony_ci| **itlb_misses** | **dtlb_misses** 6362306a36Sopenharmony_ci| } 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ciDESCRIPTION 6762306a36Sopenharmony_ci=========== 6862306a36Sopenharmony_ci **bpftool prog { show | list }** [*PROG*] 6962306a36Sopenharmony_ci Show information about loaded programs. If *PROG* is 7062306a36Sopenharmony_ci specified show information only about given programs, 7162306a36Sopenharmony_ci otherwise list all programs currently loaded on the system. 7262306a36Sopenharmony_ci In case of **tag** or **name**, *PROG* may match several 7362306a36Sopenharmony_ci programs which will all be shown. 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci Output will start with program ID followed by program type and 7662306a36Sopenharmony_ci zero or more named attributes (depending on kernel version). 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci Since Linux 5.1 the kernel can collect statistics on BPF 7962306a36Sopenharmony_ci programs (such as the total time spent running the program, 8062306a36Sopenharmony_ci and the number of times it was run). If available, bpftool 8162306a36Sopenharmony_ci shows such statistics. However, the kernel does not collect 8262306a36Sopenharmony_ci them by defaults, as it slightly impacts performance on each 8362306a36Sopenharmony_ci program run. Activation or deactivation of the feature is 8462306a36Sopenharmony_ci performed via the **kernel.bpf_stats_enabled** sysctl knob. 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci Since Linux 5.8 bpftool is able to discover information about 8762306a36Sopenharmony_ci processes that hold open file descriptors (FDs) against BPF 8862306a36Sopenharmony_ci programs. On such kernels bpftool will automatically emit this 8962306a36Sopenharmony_ci information as well. 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | [**opcodes**] [**linum**] [**visual**] }] 9262306a36Sopenharmony_ci Dump eBPF instructions of the programs from the kernel. By 9362306a36Sopenharmony_ci default, eBPF will be disassembled and printed to standard 9462306a36Sopenharmony_ci output in human-readable format. In this case, **opcodes** 9562306a36Sopenharmony_ci controls if raw opcodes should be printed as well. 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci In case of **tag** or **name**, *PROG* may match several 9862306a36Sopenharmony_ci programs which will all be dumped. However, if **file** or 9962306a36Sopenharmony_ci **visual** is specified, *PROG* must match a single program. 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci If **file** is specified, the binary image will instead be 10262306a36Sopenharmony_ci written to *FILE*. 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci If **visual** is specified, control flow graph (CFG) will be 10562306a36Sopenharmony_ci built instead, and eBPF instructions will be presented with 10662306a36Sopenharmony_ci CFG in DOT format, on standard output. 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci If the programs have line_info available, the source line will 10962306a36Sopenharmony_ci be displayed. If **linum** is specified, the filename, line 11062306a36Sopenharmony_ci number and line column will also be displayed. 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci **bpftool prog dump jited** *PROG* [{ **file** *FILE* | [**opcodes**] [**linum**] }] 11362306a36Sopenharmony_ci Dump jited image (host machine code) of the program. 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci If *FILE* is specified image will be written to a file, 11662306a36Sopenharmony_ci otherwise it will be disassembled and printed to stdout. 11762306a36Sopenharmony_ci *PROG* must match a single program when **file** is specified. 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci **opcodes** controls if raw opcodes will be printed. 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci If the prog has line_info available, the source line will 12262306a36Sopenharmony_ci be displayed. If **linum** is specified, the filename, line 12362306a36Sopenharmony_ci number and line column will also be displayed. 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci **bpftool prog pin** *PROG* *FILE* 12662306a36Sopenharmony_ci Pin program *PROG* as *FILE*. 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci Note: *FILE* must be located in *bpffs* mount. It must not 12962306a36Sopenharmony_ci contain a dot character ('.'), which is reserved for future 13062306a36Sopenharmony_ci extensions of *bpffs*. 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci **bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** { **idx** *IDX* | **name** *NAME* } *MAP*] [{ **offload_dev** | **xdpmeta_dev** } *NAME*] [**pinmaps** *MAP_DIR*] [**autoattach**] 13362306a36Sopenharmony_ci Load bpf program(s) from binary *OBJ* and pin as *PATH*. 13462306a36Sopenharmony_ci **bpftool prog load** pins only the first program from the 13562306a36Sopenharmony_ci *OBJ* as *PATH*. **bpftool prog loadall** pins all programs 13662306a36Sopenharmony_ci from the *OBJ* under *PATH* directory. 13762306a36Sopenharmony_ci **type** is optional, if not specified program type will be 13862306a36Sopenharmony_ci inferred from section names. 13962306a36Sopenharmony_ci By default bpftool will create new maps as declared in the ELF 14062306a36Sopenharmony_ci object being loaded. **map** parameter allows for the reuse 14162306a36Sopenharmony_ci of existing maps. It can be specified multiple times, each 14262306a36Sopenharmony_ci time for a different map. *IDX* refers to index of the map 14362306a36Sopenharmony_ci to be replaced in the ELF file counting from 0, while *NAME* 14462306a36Sopenharmony_ci allows to replace a map by name. *MAP* specifies the map to 14562306a36Sopenharmony_ci use, referring to it by **id** or through a **pinned** file. 14662306a36Sopenharmony_ci If **offload_dev** *NAME* is specified program will be loaded 14762306a36Sopenharmony_ci onto given networking device (offload). 14862306a36Sopenharmony_ci If **xdpmeta_dev** *NAME* is specified program will become 14962306a36Sopenharmony_ci device-bound without offloading, this facilitates access 15062306a36Sopenharmony_ci to XDP metadata. 15162306a36Sopenharmony_ci Optional **pinmaps** argument can be provided to pin all 15262306a36Sopenharmony_ci maps under *MAP_DIR* directory. 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci If **autoattach** is specified program will be attached 15562306a36Sopenharmony_ci before pin. In that case, only the link (representing the 15662306a36Sopenharmony_ci program attached to its hook) is pinned, not the program as 15762306a36Sopenharmony_ci such, so the path won't show in **bpftool prog show -f**, 15862306a36Sopenharmony_ci only show in **bpftool link show -f**. Also, this only works 15962306a36Sopenharmony_ci when bpftool (libbpf) is able to infer all necessary 16062306a36Sopenharmony_ci information from the object file, in particular, it's not 16162306a36Sopenharmony_ci supported for all program types. If a program does not 16262306a36Sopenharmony_ci support autoattach, bpftool falls back to regular pinning 16362306a36Sopenharmony_ci for that program instead. 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci Note: *PATH* must be located in *bpffs* mount. It must not 16662306a36Sopenharmony_ci contain a dot character ('.'), which is reserved for future 16762306a36Sopenharmony_ci extensions of *bpffs*. 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci **bpftool prog attach** *PROG* *ATTACH_TYPE* [*MAP*] 17062306a36Sopenharmony_ci Attach bpf program *PROG* (with type specified by 17162306a36Sopenharmony_ci *ATTACH_TYPE*). Most *ATTACH_TYPEs* require a *MAP* 17262306a36Sopenharmony_ci parameter, with the exception of *flow_dissector* which is 17362306a36Sopenharmony_ci attached to current networking name space. 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci **bpftool prog detach** *PROG* *ATTACH_TYPE* [*MAP*] 17662306a36Sopenharmony_ci Detach bpf program *PROG* (with type specified by 17762306a36Sopenharmony_ci *ATTACH_TYPE*). Most *ATTACH_TYPEs* require a *MAP* 17862306a36Sopenharmony_ci parameter, with the exception of *flow_dissector* which is 17962306a36Sopenharmony_ci detached from the current networking name space. 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci **bpftool prog tracelog** 18262306a36Sopenharmony_ci Dump the trace pipe of the system to the console (stdout). 18362306a36Sopenharmony_ci Hit <Ctrl+C> to stop printing. BPF programs can write to this 18462306a36Sopenharmony_ci trace pipe at runtime with the **bpf_trace_printk**\ () helper. 18562306a36Sopenharmony_ci This should be used only for debugging purposes. For 18662306a36Sopenharmony_ci streaming data from BPF programs to user space, one can use 18762306a36Sopenharmony_ci perf events (see also **bpftool-map**\ (8)). 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci **bpftool prog run** *PROG* **data_in** *FILE* [**data_out** *FILE* [**data_size_out** *L*]] [**ctx_in** *FILE* [**ctx_out** *FILE* [**ctx_size_out** *M*]]] [**repeat** *N*] 19062306a36Sopenharmony_ci Run BPF program *PROG* in the kernel testing infrastructure 19162306a36Sopenharmony_ci for BPF, meaning that the program works on the data and 19262306a36Sopenharmony_ci context provided by the user, and not on actual packets or 19362306a36Sopenharmony_ci monitored functions etc. Return value and duration for the 19462306a36Sopenharmony_ci test run are printed out to the console. 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci Input data is read from the *FILE* passed with **data_in**. 19762306a36Sopenharmony_ci If this *FILE* is "**-**", input data is read from standard 19862306a36Sopenharmony_ci input. Input context, if any, is read from *FILE* passed with 19962306a36Sopenharmony_ci **ctx_in**. Again, "**-**" can be used to read from standard 20062306a36Sopenharmony_ci input, but only if standard input is not already in use for 20162306a36Sopenharmony_ci input data. If a *FILE* is passed with **data_out**, output 20262306a36Sopenharmony_ci data is written to that file. Similarly, output context is 20362306a36Sopenharmony_ci written to the *FILE* passed with **ctx_out**. For both 20462306a36Sopenharmony_ci output flows, "**-**" can be used to print to the standard 20562306a36Sopenharmony_ci output (as plain text, or JSON if relevant option was 20662306a36Sopenharmony_ci passed). If output keywords are omitted, output data and 20762306a36Sopenharmony_ci context are discarded. Keywords **data_size_out** and 20862306a36Sopenharmony_ci **ctx_size_out** are used to pass the size (in bytes) for the 20962306a36Sopenharmony_ci output buffers to the kernel, although the default of 32 kB 21062306a36Sopenharmony_ci should be more than enough for most cases. 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ci Keyword **repeat** is used to indicate the number of 21362306a36Sopenharmony_ci consecutive runs to perform. Note that output data and 21462306a36Sopenharmony_ci context printed to files correspond to the last of those 21562306a36Sopenharmony_ci runs. The duration printed out at the end of the runs is an 21662306a36Sopenharmony_ci average over all runs performed by the command. 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_ci Not all program types support test run. Among those which do, 21962306a36Sopenharmony_ci not all of them can take the **ctx_in**/**ctx_out** 22062306a36Sopenharmony_ci arguments. bpftool does not perform checks on program types. 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci **bpftool prog profile** *PROG* [**duration** *DURATION*] *METRICs* 22362306a36Sopenharmony_ci Profile *METRICs* for bpf program *PROG* for *DURATION* 22462306a36Sopenharmony_ci seconds or until user hits <Ctrl+C>. *DURATION* is optional. 22562306a36Sopenharmony_ci If *DURATION* is not specified, the profiling will run up to 22662306a36Sopenharmony_ci **UINT_MAX** seconds. 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci **bpftool prog help** 22962306a36Sopenharmony_ci Print short help message. 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ciOPTIONS 23262306a36Sopenharmony_ci======= 23362306a36Sopenharmony_ci .. include:: common_options.rst 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci -f, --bpffs 23662306a36Sopenharmony_ci When showing BPF programs, show file names of pinned 23762306a36Sopenharmony_ci programs. 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ci -m, --mapcompat 24062306a36Sopenharmony_ci Allow loading maps with unknown map definitions. 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci -n, --nomount 24362306a36Sopenharmony_ci Do not automatically attempt to mount any virtual file system 24462306a36Sopenharmony_ci (such as tracefs or BPF virtual file system) when necessary. 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_ci -L, --use-loader 24762306a36Sopenharmony_ci Load program as a "loader" program. This is useful to debug 24862306a36Sopenharmony_ci the generation of such programs. When this option is in 24962306a36Sopenharmony_ci use, bpftool attempts to load the programs from the object 25062306a36Sopenharmony_ci file into the kernel, but does not pin them (therefore, the 25162306a36Sopenharmony_ci *PATH* must not be provided). 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci When combined with the **-d**\ \|\ **--debug** option, 25462306a36Sopenharmony_ci additional debug messages are generated, and the execution 25562306a36Sopenharmony_ci of the loader program will use the **bpf_trace_printk**\ () 25662306a36Sopenharmony_ci helper to log each step of loading BTF, creating the maps, 25762306a36Sopenharmony_ci and loading the programs (see **bpftool prog tracelog** as 25862306a36Sopenharmony_ci a way to dump those messages). 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ciEXAMPLES 26162306a36Sopenharmony_ci======== 26262306a36Sopenharmony_ci**# bpftool prog show** 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_ci:: 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci 10: xdp name some_prog tag 005a3d2123620c8b gpl run_time_ns 81632 run_cnt 10 26762306a36Sopenharmony_ci loaded_at 2017-09-29T20:11:00+0000 uid 0 26862306a36Sopenharmony_ci xlated 528B jited 370B memlock 4096B map_ids 10 26962306a36Sopenharmony_ci pids systemd(1) 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ci**# bpftool --json --pretty prog show** 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci:: 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci [{ 27662306a36Sopenharmony_ci "id": 10, 27762306a36Sopenharmony_ci "type": "xdp", 27862306a36Sopenharmony_ci "tag": "005a3d2123620c8b", 27962306a36Sopenharmony_ci "gpl_compatible": true, 28062306a36Sopenharmony_ci "run_time_ns": 81632, 28162306a36Sopenharmony_ci "run_cnt": 10, 28262306a36Sopenharmony_ci "loaded_at": 1506715860, 28362306a36Sopenharmony_ci "uid": 0, 28462306a36Sopenharmony_ci "bytes_xlated": 528, 28562306a36Sopenharmony_ci "jited": true, 28662306a36Sopenharmony_ci "bytes_jited": 370, 28762306a36Sopenharmony_ci "bytes_memlock": 4096, 28862306a36Sopenharmony_ci "map_ids": [10 28962306a36Sopenharmony_ci ], 29062306a36Sopenharmony_ci "pids": [{ 29162306a36Sopenharmony_ci "pid": 1, 29262306a36Sopenharmony_ci "comm": "systemd" 29362306a36Sopenharmony_ci } 29462306a36Sopenharmony_ci ] 29562306a36Sopenharmony_ci } 29662306a36Sopenharmony_ci ] 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci| 29962306a36Sopenharmony_ci| **# bpftool prog dump xlated id 10 file /tmp/t** 30062306a36Sopenharmony_ci| **$ ls -l /tmp/t** 30162306a36Sopenharmony_ci 30262306a36Sopenharmony_ci:: 30362306a36Sopenharmony_ci 30462306a36Sopenharmony_ci -rw------- 1 root root 560 Jul 22 01:42 /tmp/t 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci**# bpftool prog dump jited tag 005a3d2123620c8b** 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci:: 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci 0: push %rbp 31162306a36Sopenharmony_ci 1: mov %rsp,%rbp 31262306a36Sopenharmony_ci 2: sub $0x228,%rsp 31362306a36Sopenharmony_ci 3: sub $0x28,%rbp 31462306a36Sopenharmony_ci 4: mov %rbx,0x0(%rbp) 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci| 31762306a36Sopenharmony_ci| **# mount -t bpf none /sys/fs/bpf/** 31862306a36Sopenharmony_ci| **# bpftool prog pin id 10 /sys/fs/bpf/prog** 31962306a36Sopenharmony_ci| **# bpftool prog load ./my_prog.o /sys/fs/bpf/prog2** 32062306a36Sopenharmony_ci| **# ls -l /sys/fs/bpf/** 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_ci:: 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_ci -rw------- 1 root root 0 Jul 22 01:43 prog 32562306a36Sopenharmony_ci -rw------- 1 root root 0 Jul 22 01:44 prog2 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci**# bpftool prog dump jited pinned /sys/fs/bpf/prog opcodes** 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_ci:: 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci 0: push %rbp 33262306a36Sopenharmony_ci 55 33362306a36Sopenharmony_ci 1: mov %rsp,%rbp 33462306a36Sopenharmony_ci 48 89 e5 33562306a36Sopenharmony_ci 4: sub $0x228,%rsp 33662306a36Sopenharmony_ci 48 81 ec 28 02 00 00 33762306a36Sopenharmony_ci b: sub $0x28,%rbp 33862306a36Sopenharmony_ci 48 83 ed 28 33962306a36Sopenharmony_ci f: mov %rbx,0x0(%rbp) 34062306a36Sopenharmony_ci 48 89 5d 00 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ci| 34362306a36Sopenharmony_ci| **# bpftool prog load xdp1_kern.o /sys/fs/bpf/xdp1 type xdp map name rxcnt id 7** 34462306a36Sopenharmony_ci| **# bpftool prog show pinned /sys/fs/bpf/xdp1** 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci:: 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_ci 9: xdp name xdp_prog1 tag 539ec6ce11b52f98 gpl 34962306a36Sopenharmony_ci loaded_at 2018-06-25T16:17:31-0700 uid 0 35062306a36Sopenharmony_ci xlated 488B jited 336B memlock 4096B map_ids 7 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_ci**# rm /sys/fs/bpf/xdp1** 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci| 35562306a36Sopenharmony_ci| **# bpftool prog profile id 337 duration 10 cycles instructions llc_misses** 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci:: 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ci 51397 run_cnt 36062306a36Sopenharmony_ci 40176203 cycles (83.05%) 36162306a36Sopenharmony_ci 42518139 instructions # 1.06 insns per cycle (83.39%) 36262306a36Sopenharmony_ci 123 llc_misses # 2.89 LLC misses per million insns (83.15%) 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci| 36562306a36Sopenharmony_ci| Output below is for the trace logs. 36662306a36Sopenharmony_ci| Run in separate terminals: 36762306a36Sopenharmony_ci| **# bpftool prog tracelog** 36862306a36Sopenharmony_ci| **# bpftool prog load -L -d file.o** 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci:: 37162306a36Sopenharmony_ci 37262306a36Sopenharmony_ci bpftool-620059 [004] d... 2634685.517903: bpf_trace_printk: btf_load size 665 r=5 37362306a36Sopenharmony_ci bpftool-620059 [004] d... 2634685.517912: bpf_trace_printk: map_create sample_map idx 0 type 2 value_size 4 value_btf_id 0 r=6 37462306a36Sopenharmony_ci bpftool-620059 [004] d... 2634685.517997: bpf_trace_printk: prog_load sample insn_cnt 13 r=7 37562306a36Sopenharmony_ci bpftool-620059 [004] d... 2634685.517999: bpf_trace_printk: close(5) = 0 376