Skip to content

Inline bpf_get_branch_snapshot() BPF helper

Andrii Nakryiko bpf 3 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 8 repliesApplied 2/2
  2. v22 patches 4 repliesSuperseded
  3. v13 patches 19 repliesSuperseded

Changes in v3 from the cover letter

- fix BPF_MUL instruction definition;

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: make bpf_get_branch_snapshot() architecture-agnostickernel/trace/bpf_trace.c+0 -41 replyApplied
2/2bpf: inline bpf_get_branch_snapshot() helperkernel/bpf/verifier.c+55 -07 repliesApplied

Reviews trailers per patch

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

PatchJohn FastabendYonghong Song
1/2A-b
2/2A-b A-b

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

Read the v3 thread

Cover letter [PATCH v3 bpf-next 0/2] Inline bpf_get_branch_snapshot() BPF helper

Implement inlining of bpf_get_branch_snapshot() BPF helper using generic BPF assembly approach. This allows to reduce LBR record usage right before LBR records are captured from inside BPF program.

See v1 cover letter ([0]) for some visual examples. I dropped them from v2 because there are multiple independent changes landing and being reviewed, all of which remove different parts of LBR record waste, so presenting final state of LBR "waste" gets more complicated until all of the pieces land.

[0] https://lore.kernel.org/bpf/[email protected]/

v2->v3:
- fix BPF_MUL instruction definition;
v1->v2:
- inlining of bpf_get_smp_processor_id() split out into a separate patch set

    implementing internal per-CPU BPF instruction;

- add efficient divide-by-24 through multiplication logic, and leave comments to explain the idea behind it; this way inlined version of bpf_get_branch_snapshot() has no compromises compared to non-inlined version of the helper (Alexei).

Andrii Nakryiko (2):
bpf: make bpf_get_branch_snapshot() architecture-agnostic
bpf: inline bpf_get_branch_snapshot() helper

 kernel/bpf/verifier.c    | 55 ++++++++++++++++++++++++++++++++++++++++
 kernel/trace/bpf_trace.c |  4 ---
 2 files changed, 55 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0