143448428SQuentin Monnet.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 243448428SQuentin Monnet 3ff69c21aSJakub Kicinski================ 4ff69c21aSJakub Kicinskibpftool-prog 5ff69c21aSJakub Kicinski================ 6ff69c21aSJakub Kicinski------------------------------------------------------------------------------- 7ff69c21aSJakub Kicinskitool for inspection and simple manipulation of eBPF progs 8ff69c21aSJakub Kicinski------------------------------------------------------------------------------- 9ff69c21aSJakub Kicinski 10ff69c21aSJakub Kicinski:Manual section: 8 11ff69c21aSJakub Kicinski 12b6231815SQuentin Monnet.. include:: substitutions.rst 13b6231815SQuentin Monnet 14ff69c21aSJakub KicinskiSYNOPSIS 15ff69c21aSJakub Kicinski======== 16ff69c21aSJakub Kicinski 170641c3c8SQuentin Monnet **bpftool** [*OPTIONS*] **prog** *COMMAND* 180641c3c8SQuentin Monnet 19b6231815SQuentin Monnet *OPTIONS* := { |COMMON_OPTIONS| | 208cc8c635SQuentin Monnet { **-f** | **--bpffs** } | { **-m** | **--mapcompat** } | { **-n** | **--nomount** } | 218cc8c635SQuentin Monnet { **-L** | **--use-loader** } } 220641c3c8SQuentin Monnet 230641c3c8SQuentin Monnet *COMMANDS* := 24986dec18SQuentin Monnet { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load** | 25986dec18SQuentin Monnet **loadall** | **help** } 260641c3c8SQuentin Monnet 27a5f2d082SPrashant BholePROG COMMANDS 280641c3c8SQuentin Monnet============= 290641c3c8SQuentin Monnet 30c8caa0bbSQuentin Monnet| **bpftool** **prog** { **show** | **list** } [*PROG*] 31*9b79f027SQuentin Monnet| **bpftool** **prog dump xlated** *PROG* [{ **file** *FILE* | [**opcodes**] [**linum**] [**visual**] }] 32*9b79f027SQuentin Monnet| **bpftool** **prog dump jited** *PROG* [{ **file** *FILE* | [**opcodes**] [**linum**] }] 3347ff7ac6SQuentin Monnet| **bpftool** **prog pin** *PROG* *FILE* 34ff0e9a57SWang Yufen| **bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** { **idx** *IDX* | **name** *NAME* } *MAP*] [{ **offload_dev** | **xdpmeta_dev** } *NAME*] [**pinmaps** *MAP_DIR*] [**autoattach**] 35092f0892SStanislav Fomichev| **bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*] 36092f0892SStanislav Fomichev| **bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*] 3730da46b5SQuentin Monnet| **bpftool** **prog tracelog** 38ba95c745SQuentin Monnet| **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*] 39319c7c1fSSong Liu| **bpftool** **prog profile** *PROG* [**duration** *DURATION*] *METRICs* 4047ff7ac6SQuentin Monnet| **bpftool** **prog help** 41ff69c21aSJakub Kicinski| 423ff5a4dcSJakub Kicinski| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* } 43a7d22ca2SPaul Chaignon| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* | **name** *PROG_NAME* } 4449f2cba3SJakub Kicinski| *TYPE* := { 4549f2cba3SJakub Kicinski| **socket** | **kprobe** | **kretprobe** | **classifier** | **action** | 4649f2cba3SJakub Kicinski| **tracepoint** | **raw_tracepoint** | **xdp** | **perf_event** | **cgroup/skb** | 4749f2cba3SJakub Kicinski| **cgroup/sock** | **cgroup/dev** | **lwt_in** | **lwt_out** | **lwt_xmit** | 4849f2cba3SJakub Kicinski| **lwt_seg6local** | **sockops** | **sk_skb** | **sk_msg** | **lirc_mode2** | 4949f2cba3SJakub Kicinski| **cgroup/bind4** | **cgroup/bind6** | **cgroup/post_bind4** | **cgroup/post_bind6** | 5005ee19c1SDaniel Borkmann| **cgroup/connect4** | **cgroup/connect6** | **cgroup/getpeername4** | **cgroup/getpeername6** | 5105ee19c1SDaniel Borkmann| **cgroup/getsockname4** | **cgroup/getsockname6** | **cgroup/sendmsg4** | **cgroup/sendmsg6** | 52f6d08d9dSStanislav Fomichev| **cgroup/recvmsg4** | **cgroup/recvmsg6** | **cgroup/sysctl** | 53a8deba85SLiu Jian| **cgroup/getsockopt** | **cgroup/setsockopt** | **cgroup/sock_release** | 5493a3545dSJakub Sitnicki| **struct_ops** | **fentry** | **fexit** | **freplace** | **sk_lookup** 5549f2cba3SJakub Kicinski| } 56092f0892SStanislav Fomichev| *ATTACH_TYPE* := { 571ba5ad36SDaniel Müller| **sk_msg_verdict** | **sk_skb_verdict** | **sk_skb_stream_verdict** | 581ba5ad36SDaniel Müller| **sk_skb_stream_parser** | **flow_dissector** 59092f0892SStanislav Fomichev| } 60c8caa0bbSQuentin Monnet| *METRICs* := { 61475a23c2SQuentin Monnet| **cycles** | **instructions** | **l1d_loads** | **llc_misses** | 62475a23c2SQuentin Monnet| **itlb_misses** | **dtlb_misses** 63319c7c1fSSong Liu| } 6449f2cba3SJakub Kicinski 65ff69c21aSJakub Kicinski 66ff69c21aSJakub KicinskiDESCRIPTION 67ff69c21aSJakub Kicinski=========== 686ebe6dbdSJakub Kicinski **bpftool prog { show | list }** [*PROG*] 69ff69c21aSJakub Kicinski Show information about loaded programs. If *PROG* is 70ec202509SPaul Chaignon specified show information only about given programs, 71ec202509SPaul Chaignon otherwise list all programs currently loaded on the system. 72a7d22ca2SPaul Chaignon In case of **tag** or **name**, *PROG* may match several 73a7d22ca2SPaul Chaignon programs which will all be shown. 74ff69c21aSJakub Kicinski 75ff69c21aSJakub Kicinski Output will start with program ID followed by program type and 76ff69c21aSJakub Kicinski zero or more named attributes (depending on kernel version). 77ff69c21aSJakub Kicinski 7825df480dSQuentin Monnet Since Linux 5.1 the kernel can collect statistics on BPF 7925df480dSQuentin Monnet programs (such as the total time spent running the program, 8025df480dSQuentin Monnet and the number of times it was run). If available, bpftool 8125df480dSQuentin Monnet shows such statistics. However, the kernel does not collect 8225df480dSQuentin Monnet them by defaults, as it slightly impacts performance on each 8325df480dSQuentin Monnet program run. Activation or deactivation of the feature is 8425df480dSQuentin Monnet performed via the **kernel.bpf_stats_enabled** sysctl knob. 8525df480dSQuentin Monnet 86075c7766SAndrii Nakryiko Since Linux 5.8 bpftool is able to discover information about 87075c7766SAndrii Nakryiko processes that hold open file descriptors (FDs) against BPF 88075c7766SAndrii Nakryiko programs. On such kernels bpftool will automatically emit this 89075c7766SAndrii Nakryiko information as well. 90075c7766SAndrii Nakryiko 91*9b79f027SQuentin Monnet **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | [**opcodes**] [**linum**] [**visual**] }] 92ec202509SPaul Chaignon Dump eBPF instructions of the programs from the kernel. By 93b6c1cedbSJiong Wang default, eBPF will be disassembled and printed to standard 94b6c1cedbSJiong Wang output in human-readable format. In this case, **opcodes** 95b6c1cedbSJiong Wang controls if raw opcodes should be printed as well. 96c9c35995SJakub Kicinski 97a7d22ca2SPaul Chaignon In case of **tag** or **name**, *PROG* may match several 98a7d22ca2SPaul Chaignon programs which will all be dumped. However, if **file** or 99a7d22ca2SPaul Chaignon **visual** is specified, *PROG* must match a single program. 100ec202509SPaul Chaignon 101b6c1cedbSJiong Wang If **file** is specified, the binary image will instead be 102b6c1cedbSJiong Wang written to *FILE*. 103b6c1cedbSJiong Wang 104b6c1cedbSJiong Wang If **visual** is specified, control flow graph (CFG) will be 105b6c1cedbSJiong Wang built instead, and eBPF instructions will be presented with 106b6c1cedbSJiong Wang CFG in DOT format, on standard output. 107ff69c21aSJakub Kicinski 108ec202509SPaul Chaignon If the programs have line_info available, the source line will 109e27f0f16SQuentin Monnet be displayed. If **linum** is specified, the filename, line 110e27f0f16SQuentin Monnet number and line column will also be displayed. 11110a5ce98SMartin KaFai Lau 112*9b79f027SQuentin Monnet **bpftool prog dump jited** *PROG* [{ **file** *FILE* | [**opcodes**] [**linum**] }] 113ff69c21aSJakub Kicinski Dump jited image (host machine code) of the program. 114ec202509SPaul Chaignon 115ff69c21aSJakub Kicinski If *FILE* is specified image will be written to a file, 116ff69c21aSJakub Kicinski otherwise it will be disassembled and printed to stdout. 117ec202509SPaul Chaignon *PROG* must match a single program when **file** is specified. 118ff69c21aSJakub Kicinski 119ff69c21aSJakub Kicinski **opcodes** controls if raw opcodes will be printed. 120ff69c21aSJakub Kicinski 121b053b439SMartin KaFai Lau If the prog has line_info available, the source line will 122e27f0f16SQuentin Monnet be displayed. If **linum** is specified, the filename, line 123e27f0f16SQuentin Monnet number and line column will also be displayed. 12410a5ce98SMartin KaFai Lau 125ff69c21aSJakub Kicinski **bpftool prog pin** *PROG* *FILE* 126ff69c21aSJakub Kicinski Pin program *PROG* as *FILE*. 127ff69c21aSJakub Kicinski 128882731e0SQuentin Monnet Note: *FILE* must be located in *bpffs* mount. It must not 129882731e0SQuentin Monnet contain a dot character ('.'), which is reserved for future 130882731e0SQuentin Monnet extensions of *bpffs*. 131ff69c21aSJakub Kicinski 132ff0e9a57SWang Yufen **bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** { **idx** *IDX* | **name** *NAME* } *MAP*] [{ **offload_dev** | **xdpmeta_dev** } *NAME*] [**pinmaps** *MAP_DIR*] [**autoattach**] 13377380998SStanislav Fomichev Load bpf program(s) from binary *OBJ* and pin as *PATH*. 13477380998SStanislav Fomichev **bpftool prog load** pins only the first program from the 13577380998SStanislav Fomichev *OBJ* as *PATH*. **bpftool prog loadall** pins all programs 13677380998SStanislav Fomichev from the *OBJ* under *PATH* directory. 13749f2cba3SJakub Kicinski **type** is optional, if not specified program type will be 13849f2cba3SJakub Kicinski inferred from section names. 1393ff5a4dcSJakub Kicinski By default bpftool will create new maps as declared in the ELF 1403ff5a4dcSJakub Kicinski object being loaded. **map** parameter allows for the reuse 1413ff5a4dcSJakub Kicinski of existing maps. It can be specified multiple times, each 1423ff5a4dcSJakub Kicinski time for a different map. *IDX* refers to index of the map 1433ff5a4dcSJakub Kicinski to be replaced in the ELF file counting from 0, while *NAME* 1443ff5a4dcSJakub Kicinski allows to replace a map by name. *MAP* specifies the map to 1453ff5a4dcSJakub Kicinski use, referring to it by **id** or through a **pinned** file. 146ba6dd679SJakub Kicinski If **offload_dev** *NAME* is specified program will be loaded 147ba6dd679SJakub Kicinski onto given networking device (offload). 1483767a94bSStanislav Fomichev If **xdpmeta_dev** *NAME* is specified program will become 1493767a94bSStanislav Fomichev device-bound without offloading, this facilitates access 15049a086c2SRoman Gushchin to XDP metadata. 151ff0e9a57SWang Yufen Optional **pinmaps** argument can be provided to pin all 152ff0e9a57SWang Yufen maps under *MAP_DIR* directory. 153ff0e9a57SWang Yufen 154ff0e9a57SWang Yufen If **autoattach** is specified program will be attached 155ff0e9a57SWang Yufen before pin. In that case, only the link (representing the 156ff0e9a57SWang Yufen program attached to its hook) is pinned, not the program as 157ff0e9a57SWang Yufen such, so the path won't show in **bpftool prog show -f**, 158ff0e9a57SWang Yufen only show in **bpftool link show -f**. Also, this only works 159ff0e9a57SWang Yufen when bpftool (libbpf) is able to infer all necessary 160ff0e9a57SWang Yufen information from the object file, in particular, it's not 161ff0e9a57SWang Yufen supported for all program types. If a program does not 16277380998SStanislav Fomichev support autoattach, bpftool falls back to regular pinning 163882731e0SQuentin Monnet for that program instead. 164882731e0SQuentin Monnet 16549a086c2SRoman Gushchin Note: *PATH* must be located in *bpffs* mount. It must not 166092f0892SStanislav Fomichev contain a dot character ('.'), which is reserved for future 167092f0892SStanislav Fomichev extensions of *bpffs*. 168092f0892SStanislav Fomichev 169092f0892SStanislav Fomichev **bpftool prog attach** *PROG* *ATTACH_TYPE* [*MAP*] 170092f0892SStanislav Fomichev Attach bpf program *PROG* (with type specified by 171b7d3826cSJohn Fastabend *ATTACH_TYPE*). Most *ATTACH_TYPEs* require a *MAP* 172092f0892SStanislav Fomichev parameter, with the exception of *flow_dissector* which is 173092f0892SStanislav Fomichev attached to current networking name space. 174092f0892SStanislav Fomichev 175092f0892SStanislav Fomichev **bpftool prog detach** *PROG* *ATTACH_TYPE* [*MAP*] 176092f0892SStanislav Fomichev Detach bpf program *PROG* (with type specified by 177b7d3826cSJohn Fastabend *ATTACH_TYPE*). Most *ATTACH_TYPEs* require a *MAP* 17830da46b5SQuentin Monnet parameter, with the exception of *flow_dissector* which is 17930da46b5SQuentin Monnet detached from the current networking name space. 18030da46b5SQuentin Monnet 181c8caa0bbSQuentin Monnet **bpftool prog tracelog** 18230da46b5SQuentin Monnet Dump the trace pipe of the system to the console (stdout). 18330da46b5SQuentin Monnet Hit <Ctrl+C> to stop printing. BPF programs can write to this 18430da46b5SQuentin Monnet trace pipe at runtime with the **bpf_trace_printk**\ () helper. 18530da46b5SQuentin Monnet This should be used only for debugging purposes. For 186ba95c745SQuentin Monnet streaming data from BPF programs to user space, one can use 187ba95c745SQuentin Monnet perf events (see also **bpftool-map**\ (8)). 188ba95c745SQuentin Monnet 189ba95c745SQuentin Monnet **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*] 190ba95c745SQuentin Monnet Run BPF program *PROG* in the kernel testing infrastructure 191ba95c745SQuentin Monnet for BPF, meaning that the program works on the data and 192ba95c745SQuentin Monnet context provided by the user, and not on actual packets or 193ba95c745SQuentin Monnet monitored functions etc. Return value and duration for the 194ba95c745SQuentin Monnet test run are printed out to the console. 195ba95c745SQuentin Monnet 196ba95c745SQuentin Monnet Input data is read from the *FILE* passed with **data_in**. 197ba95c745SQuentin Monnet If this *FILE* is "**-**", input data is read from standard 198ba95c745SQuentin Monnet input. Input context, if any, is read from *FILE* passed with 199ba95c745SQuentin Monnet **ctx_in**. Again, "**-**" can be used to read from standard 200ba95c745SQuentin Monnet input, but only if standard input is not already in use for 201ba95c745SQuentin Monnet input data. If a *FILE* is passed with **data_out**, output 202ba95c745SQuentin Monnet data is written to that file. Similarly, output context is 203ba95c745SQuentin Monnet written to the *FILE* passed with **ctx_out**. For both 204ba95c745SQuentin Monnet output flows, "**-**" can be used to print to the standard 205ba95c745SQuentin Monnet output (as plain text, or JSON if relevant option was 206ba95c745SQuentin Monnet passed). If output keywords are omitted, output data and 207ba95c745SQuentin Monnet context are discarded. Keywords **data_size_out** and 208ba95c745SQuentin Monnet **ctx_size_out** are used to pass the size (in bytes) for the 209ba95c745SQuentin Monnet output buffers to the kernel, although the default of 32 kB 210ba95c745SQuentin Monnet should be more than enough for most cases. 211ba95c745SQuentin Monnet 212ba95c745SQuentin Monnet Keyword **repeat** is used to indicate the number of 213ba95c745SQuentin Monnet consecutive runs to perform. Note that output data and 214ba95c745SQuentin Monnet context printed to files correspond to the last of those 215ba95c745SQuentin Monnet runs. The duration printed out at the end of the runs is an 216ba95c745SQuentin Monnet average over all runs performed by the command. 217ba95c745SQuentin Monnet 218ba95c745SQuentin Monnet Not all program types support test run. Among those which do, 219319c7c1fSSong Liu not all of them can take the **ctx_in**/**ctx_out** 220319c7c1fSSong Liu arguments. bpftool does not perform checks on program types. 221c8caa0bbSQuentin Monnet 222319c7c1fSSong Liu **bpftool prog profile** *PROG* [**duration** *DURATION*] *METRICs* 223c8caa0bbSQuentin Monnet Profile *METRICs* for bpf program *PROG* for *DURATION* 224319c7c1fSSong Liu seconds or until user hits <Ctrl+C>. *DURATION* is optional. 225ff69c21aSJakub Kicinski If *DURATION* is not specified, the profiling will run up to 226ff69c21aSJakub Kicinski **UINT_MAX** seconds. 227ff69c21aSJakub Kicinski 228a2bc2e5cSQuentin Monnet **bpftool prog help** 229a2bc2e5cSQuentin Monnet Print short help message. 230f28ef96dSQuentin Monnet 2310641c3c8SQuentin MonnetOPTIONS 232c541b734SPrashant Bhole======= 233a8bfd2bcSQuentin Monnet .. include:: common_options.rst 234a8bfd2bcSQuentin Monnet 235c541b734SPrashant Bhole -f, --bpffs 236bc6cd664SQuentin Monnet When showing BPF programs, show file names of pinned 237bc6cd664SQuentin Monnet programs. 238bc6cd664SQuentin Monnet 23933221307SQuentin Monnet -m, --mapcompat 24033221307SQuentin Monnet Allow loading maps with unknown map definitions. 24133221307SQuentin Monnet 24233221307SQuentin Monnet -n, --nomount 2438cc8c635SQuentin Monnet Do not automatically attempt to mount any virtual file system 2448cc8c635SQuentin Monnet (such as tracefs or BPF virtual file system) when necessary. 2458cc8c635SQuentin Monnet 2468cc8c635SQuentin Monnet -L, --use-loader 2478cc8c635SQuentin Monnet Load program as a "loader" program. This is useful to debug 2488cc8c635SQuentin Monnet the generation of such programs. When this option is in 2498cc8c635SQuentin Monnet use, bpftool attempts to load the programs from the object 2508cc8c635SQuentin Monnet file into the kernel, but does not pin them (therefore, the 2518cc8c635SQuentin Monnet *PATH* must not be provided). 2528cc8c635SQuentin Monnet 2538cc8c635SQuentin Monnet When combined with the **-d**\ \|\ **--debug** option, 2548cc8c635SQuentin Monnet additional debug messages are generated, and the execution 2558cc8c635SQuentin Monnet of the loader program will use the **bpf_trace_printk**\ () 2568cc8c635SQuentin Monnet helper to log each step of loading BTF, creating the maps, 257ff69c21aSJakub Kicinski and loading the programs (see **bpftool prog tracelog** as 258ff69c21aSJakub Kicinski a way to dump those messages). 259ff69c21aSJakub Kicinski 26032870ba4SQuentin MonnetEXAMPLES 261ff69c21aSJakub Kicinski======== 262ff69c21aSJakub Kicinski**# bpftool prog show** 26388ad472bSAlexei Starovoitov 26432870ba4SQuentin Monnet:: 265ff69c21aSJakub Kicinski 266075c7766SAndrii Nakryiko 10: xdp name some_prog tag 005a3d2123620c8b gpl run_time_ns 81632 run_cnt 10 267ff69c21aSJakub Kicinski loaded_at 2017-09-29T20:11:00+0000 uid 0 2680641c3c8SQuentin Monnet xlated 528B jited 370B memlock 4096B map_ids 10 2690641c3c8SQuentin Monnet pids systemd(1) 2700641c3c8SQuentin Monnet 2710641c3c8SQuentin Monnet**# bpftool --json --pretty prog show** 27232870ba4SQuentin Monnet 2730641c3c8SQuentin Monnet:: 2740641c3c8SQuentin Monnet 2750641c3c8SQuentin Monnet [{ 2769b984a20SJiri Olsa "id": 10, 27788ad472bSAlexei Starovoitov "type": "xdp", 27888ad472bSAlexei Starovoitov "tag": "005a3d2123620c8b", 27932870ba4SQuentin Monnet "gpl_compatible": true, 2800641c3c8SQuentin Monnet "run_time_ns": 81632, 2810641c3c8SQuentin Monnet "run_cnt": 10, 2820641c3c8SQuentin Monnet "loaded_at": 1506715860, 2830641c3c8SQuentin Monnet "uid": 0, 2840641c3c8SQuentin Monnet "bytes_xlated": 528, 2850641c3c8SQuentin Monnet "jited": true, 286075c7766SAndrii Nakryiko "bytes_jited": 370, 287075c7766SAndrii Nakryiko "bytes_memlock": 4096, 288075c7766SAndrii Nakryiko "map_ids": [10 289075c7766SAndrii Nakryiko ], 290075c7766SAndrii Nakryiko "pids": [{ 2910641c3c8SQuentin Monnet "pid": 1, 2920641c3c8SQuentin Monnet "comm": "systemd" 2930641c3c8SQuentin Monnet } 2940641c3c8SQuentin Monnet ] 295ff69c21aSJakub Kicinski } 296ff69c21aSJakub Kicinski ] 297c8caa0bbSQuentin Monnet 298ff69c21aSJakub Kicinski| 299ff69c21aSJakub Kicinski| **# bpftool prog dump xlated id 10 file /tmp/t** 300ff69c21aSJakub Kicinski| **$ ls -l /tmp/t** 30132870ba4SQuentin Monnet 30232870ba4SQuentin Monnet:: 30332870ba4SQuentin Monnet 30432870ba4SQuentin Monnet -rw------- 1 root root 560 Jul 22 01:42 /tmp/t 30532870ba4SQuentin Monnet 30632870ba4SQuentin Monnet**# bpftool prog dump jited tag 005a3d2123620c8b** 30732870ba4SQuentin Monnet 30832870ba4SQuentin Monnet:: 30932870ba4SQuentin Monnet 31032870ba4SQuentin Monnet 0: push %rbp 31132870ba4SQuentin Monnet 1: mov %rsp,%rbp 312ff69c21aSJakub Kicinski 2: sub $0x228,%rsp 3130641c3c8SQuentin Monnet 3: sub $0x28,%rbp 3140641c3c8SQuentin Monnet 4: mov %rbx,0x0(%rbp) 3150641c3c8SQuentin Monnet 31649a086c2SRoman Gushchin| 3170641c3c8SQuentin Monnet| **# mount -t bpf none /sys/fs/bpf/** 3180641c3c8SQuentin Monnet| **# bpftool prog pin id 10 /sys/fs/bpf/prog** 3190641c3c8SQuentin Monnet| **# bpftool prog load ./my_prog.o /sys/fs/bpf/prog2** 3200641c3c8SQuentin Monnet| **# ls -l /sys/fs/bpf/** 32132870ba4SQuentin Monnet 32232870ba4SQuentin Monnet:: 32332870ba4SQuentin Monnet 32432870ba4SQuentin Monnet -rw------- 1 root root 0 Jul 22 01:43 prog 32532870ba4SQuentin Monnet -rw------- 1 root root 0 Jul 22 01:44 prog2 32632870ba4SQuentin Monnet 32732870ba4SQuentin Monnet**# bpftool prog dump jited pinned /sys/fs/bpf/prog opcodes** 32832870ba4SQuentin Monnet 3290641c3c8SQuentin Monnet:: 33032870ba4SQuentin Monnet 3310641c3c8SQuentin Monnet 0: push %rbp 33232870ba4SQuentin Monnet 55 3330641c3c8SQuentin Monnet 1: mov %rsp,%rbp 33432870ba4SQuentin Monnet 48 89 e5 3350641c3c8SQuentin Monnet 4: sub $0x228,%rsp 33632870ba4SQuentin Monnet 48 81 ec 28 02 00 00 3370641c3c8SQuentin Monnet b: sub $0x28,%rbp 338ff69c21aSJakub Kicinski 48 83 ed 28 3393ff5a4dcSJakub Kicinski f: mov %rbx,0x0(%rbp) 3403ff5a4dcSJakub Kicinski 48 89 5d 00 3413ff5a4dcSJakub Kicinski 34232870ba4SQuentin Monnet| 34332870ba4SQuentin Monnet| **# bpftool prog load xdp1_kern.o /sys/fs/bpf/xdp1 type xdp map name rxcnt id 7** 34432870ba4SQuentin Monnet| **# bpftool prog show pinned /sys/fs/bpf/xdp1** 34532870ba4SQuentin Monnet 34632870ba4SQuentin Monnet:: 34732870ba4SQuentin Monnet 34832870ba4SQuentin Monnet 9: xdp name xdp_prog1 tag 539ec6ce11b52f98 gpl 34932870ba4SQuentin Monnet loaded_at 2018-06-25T16:17:31-0700 uid 0 350ff69c21aSJakub Kicinski xlated 488B jited 336B memlock 4096B map_ids 7 351319c7c1fSSong Liu 352319c7c1fSSong Liu**# rm /sys/fs/bpf/xdp1** 353319c7c1fSSong Liu 354319c7c1fSSong Liu| 355c8caa0bbSQuentin Monnet| **# bpftool prog profile id 337 duration 10 cycles instructions llc_misses** 356319c7c1fSSong Liu 357319c7c1fSSong Liu:: 358319c7c1fSSong Liu 359319c7c1fSSong Liu 51397 run_cnt 3608cc8c635SQuentin Monnet 40176203 cycles (83.05%) 3618cc8c635SQuentin Monnet 42518139 instructions # 1.06 insns per cycle (83.39%) 3628cc8c635SQuentin Monnet 123 llc_misses # 2.89 LLC misses per million insns (83.15%) 3638cc8c635SQuentin Monnet 3648cc8c635SQuentin Monnet| 3658cc8c635SQuentin Monnet| Output below is for the trace logs. 3668cc8c635SQuentin Monnet| Run in separate terminals: 3678cc8c635SQuentin Monnet| **# bpftool prog tracelog** 3688cc8c635SQuentin Monnet| **# bpftool prog load -L -d file.o** 3698cc8c635SQuentin Monnet 3708cc8c635SQuentin Monnet:: 3718cc8c635SQuentin Monnet 3728cc8c635SQuentin Monnet bpftool-620059 [004] d... 2634685.517903: bpf_trace_printk: btf_load size 665 r=5 373 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 374 bpftool-620059 [004] d... 2634685.517997: bpf_trace_printk: prog_load sample insn_cnt 13 r=7 375 bpftool-620059 [004] d... 2634685.517999: bpf_trace_printk: close(5) = 0 376