BPF List
 help / color / mirror / Atom feed
* [PATCH v2 bpf-next 0/2] Inline bpf_get_branch_snapshot() BPF helper
@ 2024-04-02 19:05 Andrii Nakryiko
  2024-04-02 19:05 ` [PATCH v2 bpf-next 1/2] bpf: make bpf_get_branch_snapshot() architecture-agnostic Andrii Nakryiko
  2024-04-02 19:05 ` [PATCH v2 bpf-next 2/2] bpf: inline bpf_get_branch_snapshot() helper Andrii Nakryiko
  0 siblings, 2 replies; 7+ messages in thread
From: Andrii Nakryiko @ 2024-04-02 19:05 UTC (permalink / raw)
  To: bpf, ast, daniel, martin.lau; +Cc: andrii, kernel-team

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/20240321180501.734779-1-andrii@kernel.org/

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(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-03 22:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-02 19:05 [PATCH v2 bpf-next 0/2] Inline bpf_get_branch_snapshot() BPF helper Andrii Nakryiko
2024-04-02 19:05 ` [PATCH v2 bpf-next 1/2] bpf: make bpf_get_branch_snapshot() architecture-agnostic Andrii Nakryiko
2024-04-02 19:05 ` [PATCH v2 bpf-next 2/2] bpf: inline bpf_get_branch_snapshot() helper Andrii Nakryiko
2024-04-02 23:22   ` Andrii Nakryiko
2024-04-03 22:10     ` John Fastabend
2024-04-03 17:51   ` Alexei Starovoitov
2024-04-03 18:09     ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox