Skip to content

Introduce bpf_line_info

Martin KaFai Lau netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7bpf: Add bpf_line_info supportarch/x86/net/bpf_jit_comp.c include/linux/bpf.h include/linux/bpf_verifier.h +7 more+419 -330 replies
2/7bpf: tools: Sync uapi bpf.htools/include/uapi/linux/bpf.h+19 -00 replies
3/7bpf: Refactor and bug fix in test_func_type in test_btf.ctools/testing/selftests/bpf/test_btf.c+125 -860 replies
4/7bpf: Add unit tests for bpf_line_infotools/testing/selftests/bpf/test_btf.c+580 -170 replies
5/7bpf: libbpf: Refactor and bug fix on the bpf_func_info loading logictools/lib/bpf/bpf.c tools/lib/bpf/btf.c tools/lib/bpf/btf.h +1 more+177 -1770 replies
6/7bpf: libbpf: Add btf_line_info support to libbpftools/lib/bpf/bpf.c tools/lib/bpf/bpf.h tools/lib/bpf/btf.c +2 more+239 -890 replies
7/7bpf: libbpf: bpftool: Print bpf_line_info during prog dumptools/bpf/bpftool/Documentation/bpftool-prog.rst tools/bpf/bpftool/bash-completion/bpftool tools/bpf/bpftool/btf_dumper.c +9 more+516 -251 reply

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchYonghong Song
1/7A-b
2/7A-b
3/7A-b
4/7A-b
5/7A-b
6/7A-b
7/7A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH bpf-next 0/7] Introduce bpf_line_info

This patch series introduces the bpf_line_info. Please see individual patch for details.

It will be useful for introspection purpose, like:

[root@arch-fb-vm1 bpf]# ~/devshare/fb-kernel/linux/tools/bpf/bpftool/bpftool prog dump jited pinned /sys/fs/bpf/test_btf_haskv [...]
int test_long_fname_2(struct dummy_tracepoint_args * arg):
bpf_prog_44a040bf25481309_test_long_fname_2:
; static int test_long_fname_2(struct dummy_tracepoint_args *arg)

   0:   push   %rbp
   1:   mov    %rsp,%rbp
   4:   sub    $0x30,%rsp
   b:   sub    $0x28,%rbp
   f:   mov    %rbx,0x0(%rbp)
  13:   mov    %r13,0x8(%rbp)
  17:   mov    %r14,0x10(%rbp)
  1b:   mov    %r15,0x18(%rbp)
  1f:   xor    %eax,%eax
  21:   mov    %rax,0x20(%rbp)
  25:   xor    %esi,%esi

; int key = 0;
27: mov %esi,-0x4(%rbp)
; if (!arg->sock)
2a: mov 0x8(%rdi),%rdi
; if (!arg->sock)

  2e:   cmp    $0x0,%rdi
  32:   je     0x0000000000000070
  34:   mov    %rbp,%rsi
; counts = bpf_map_lookup_elem(&btf_map, &key);
  37:   add    $0xfffffffffffffffc,%rsi
  3b:   movabs $0xffff8881139d7480,%rdi
  45:   add    $0x110,%rdi
  4c:   mov    0x0(%rsi),%eax
  4f:   cmp    $0x4,%rax
  53:   jae    0x000000000000005e
  55:   shl    $0x3,%rax
  59:   add    %rdi,%rax
  5c:   jmp    0x0000000000000060
  5e:   xor    %eax,%eax
; if (!counts)
  60:   cmp    $0x0,%rax
  64:   je     0x0000000000000070
; counts->v6++;
  66:   mov    0x4(%rax),%edi
  69:   add    $0x1,%rdi
  6d:   mov    %edi,0x4(%rax)
  70:   mov    0x0(%rbp),%rbx
  74:   mov    0x8(%rbp),%r13
  78:   mov    0x10(%rbp),%r14
  7c:   mov    0x18(%rbp),%r15
  80:   add    $0x28,%rbp
  84:   leaveq
  85:   retq

[...]

Martin KaFai Lau (7):
bpf: Add bpf_line_info support
bpf: tools: Sync uapi bpf.h
bpf: Refactor and bug fix in test_func_type in test_btf.c
bpf: Add unit tests for bpf_line_info
bpf: libbpf: Refactor and bug fix on the bpf_func_info loading logic
bpf: libbpf: Add btf_line_info support to libbpf
bpf: libbpf: bpftool: Print bpf_line_info during prog dump

 arch/x86/net/bpf_jit_comp.c                   |   2 +
 include/linux/bpf.h                           |  21 +
 include/linux/bpf_verifier.h                  |   1 +
 include/linux/btf.h                           |   1 +
 include/linux/filter.h                        |   7 +
 include/uapi/linux/bpf.h                      |  19 +
 kernel/bpf/btf.c                              |   2 +-
 kernel/bpf/core.c                             | 118 ++-
 kernel/bpf/syscall.c                          |  83 +-
 kernel/bpf/verifier.c                         | 198 ++++-
 .../bpftool/Documentation/bpftool-prog.rst    |  16 +-
 tools/bpf/bpftool/bash-completion/bpftool     |   6 +-
 tools/bpf/bpftool/btf_dumper.c                |  64 ++
 tools/bpf/bpftool/jit_disasm.c                |  23 +-
 tools/bpf/bpftool/main.h                      |  23 +-
 tools/bpf/bpftool/prog.c                      | 100 ++-
 tools/bpf/bpftool/xlated_dumper.c             |  30 +-
 tools/bpf/bpftool/xlated_dumper.h             |   7 +-
 tools/include/uapi/linux/bpf.h                |  19 +
 tools/lib/bpf/Build                           |   2 +-
 tools/lib/bpf/bpf.c                           |  93 ++-
 tools/lib/bpf/bpf.h                           |   3 +
 tools/lib/bpf/bpf_prog_linfo.c                | 253 ++++++
 tools/lib/bpf/btf.c                           | 342 ++++----
 tools/lib/bpf/btf.h                           |  25 +-
 tools/lib/bpf/libbpf.c                        | 159 +++-
 tools/lib/bpf/libbpf.h                        |  13 +
 tools/lib/bpf/libbpf.map                      |   4 +
 tools/testing/selftests/bpf/test_btf.c        | 790 +++++++++++++++---
 29 files changed, 2036 insertions(+), 388 deletions(-)
 create mode 100644 tools/lib/bpf/bpf_prog_linfo.c
Signature · 1 line
2.17.1