Skip to content

Commit 075c776

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
tools/bpftool: Add documentation and sample output for process info
Add statements about bpftool being able to discover process info, holding reference to BPF map, prog, link, or BTF. Show example output as well. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/bpf/20200619231703.738941-10-andriin@fb.com
1 parent d53dee3 commit 075c776

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎tools/bpf/bpftool/Documentation/bpftool-btf.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ DESCRIPTION
3636
otherwise list all BTF objects currently loaded on the
3737
system.
3838

39+
Since Linux 5.8 bpftool is able to discover information about
40+
processes that hold open file descriptors (FDs) against BTF
41+
objects. On such kernels bpftool will automatically emit this
42+
information as well.
43+
3944
**bpftool btf dump** *BTF_SRC*
4045
Dump BTF entries from a given *BTF_SRC*.
4146

‎tools/bpf/bpftool/Documentation/bpftool-link.rst‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ DESCRIPTION
3737
zero or more named attributes, some of which depend on type
3838
of link.
3939

40+
Since Linux 5.8 bpftool is able to discover information about
41+
processes that hold open file descriptors (FDs) against BPF
42+
links. On such kernels bpftool will automatically emit this
43+
information as well.
44+
4045
**bpftool link pin** *LINK* *FILE*
4146
Pin link *LINK* as *FILE*.
4247

@@ -82,6 +87,7 @@ EXAMPLES
8287

8388
10: cgroup prog 25
8489
cgroup_id 614 attach_type egress
90+
pids test_progs(223)
8591

8692
**# bpftool --json --pretty link show**
8793

@@ -91,7 +97,12 @@ EXAMPLES
9197
"type": "cgroup",
9298
"prog_id": 25,
9399
"cgroup_id": 614,
94-
"attach_type": "egress"
100+
"attach_type": "egress",
101+
"pids": [{
102+
"pid": 223,
103+
"comm": "test_progs"
104+
}
105+
]
95106
}
96107
]
97108

‎tools/bpf/bpftool/Documentation/bpftool-map.rst‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ DESCRIPTION
6262
Output will start with map ID followed by map type and
6363
zero or more named attributes (depending on kernel version).
6464

65+
Since Linux 5.8 bpftool is able to discover information about
66+
processes that hold open file descriptors (FDs) against BPF
67+
maps. On such kernels bpftool will automatically emit this
68+
information as well.
69+
6570
**bpftool map create** *FILE* **type** *TYPE* **key** *KEY_SIZE* **value** *VALUE_SIZE* **entries** *MAX_ENTRIES* **name** *NAME* [**flags** *FLAGS*] [**dev** *NAME*]
6671
Create a new map with given parameters and pin it to *bpffs*
6772
as *FILE*.
@@ -180,7 +185,8 @@ EXAMPLES
180185
::
181186

182187
10: hash name some_map flags 0x0
183-
key 4B value 8B max_entries 2048 memlock 167936B
188+
key 4B value 8B max_entries 2048 memlock 167936B
189+
pids systemd(1)
184190

185191
The following three commands are equivalent:
186192

‎tools/bpf/bpftool/Documentation/bpftool-prog.rst‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ DESCRIPTION
7575
program run. Activation or deactivation of the feature is
7676
performed via the **kernel.bpf_stats_enabled** sysctl knob.
7777

78+
Since Linux 5.8 bpftool is able to discover information about
79+
processes that hold open file descriptors (FDs) against BPF
80+
programs. On such kernels bpftool will automatically emit this
81+
information as well.
82+
7883
**bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** | **visual** | **linum** }]
7984
Dump eBPF instructions of the programs from the kernel. By
8085
default, eBPF will be disassembled and printed to standard
@@ -243,6 +248,7 @@ EXAMPLES
243248
10: xdp name some_prog tag 005a3d2123620c8b gpl run_time_ns 81632 run_cnt 10
244249
loaded_at 2017-09-29T20:11:00+0000 uid 0
245250
xlated 528B jited 370B memlock 4096B map_ids 10
251+
pids systemd(1)
246252

247253
**# bpftool --json --pretty prog show**
248254

@@ -262,6 +268,11 @@ EXAMPLES
262268
"bytes_jited": 370,
263269
"bytes_memlock": 4096,
264270
"map_ids": [10
271+
],
272+
"pids": [{
273+
"pid": 1,
274+
"comm": "systemd"
275+
}
265276
]
266277
}
267278
]

0 commit comments

Comments
 (0)