Skip to content

Commit cb61a1e

Browse files
committed
doc: eBPF desc how to deduct number of eBPF instructions
The byte size of the xdp_prog is not too relevant, as this will get JIT'ed anyhow (and change size). It is more relevant to know the number of eBPF instructions the restricted-C program generated. Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
1 parent c5cf59f commit cb61a1e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

kernel/Documentation/bpf/troubleshooting.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ with tools like ``readelf`` or ``llvm-objdump``. ::
4141
7 .symtab 000000d8 0000000000000000
4242

4343
From the above output some trivial information can be extracted. This
44-
is an XDP program, as the defined program section Idx 3 starts with the
45-
letters "xdp". From the same line the size column also show
46-
the program size 0001b8 in hex, which is easily converted on the
47-
cmdline to 440 bytes. Do notice this size is not the JIT'ed program
48-
size::
49-
50-
$ echo $((0x0001b8))
51-
440
44+
is an XDP program, as the defined program section Idx 3 starts with
45+
the letters "xdp". From the same line the size column also show the
46+
program size in hex 0001b8 equal 440 bytes, or 55 bpf instructions, as
47+
each insns is 8 bytes (see `struct bpf_insn`_) (shell trick ``echo
48+
$((0x1b8)) insns=$((0x1b8 / 8))``). Do notice this size is not the
49+
JIT'ed program size.
5250

5351
The loader code samples/bpf/bpf_load.c parse this elf file, extract needed
5452
program sections, uses the maps section and relocation section (here
5553
.relxdp_prog ) to remap the BPF_PSEUDO_MAP_FD instruction to
5654
point to the correct map (which gets created during parsing of the
5755
maps section, via standard bpf-syscall bpf_create_map).
5856

57+
.. _struct bpf_insn: http://lxr.free-electrons.com/ident?i=bpf_insn
58+
5959
LLVM disassemble support
6060
------------------------
6161

0 commit comments

Comments
 (0)