Skip to content

ebpf: move parca-only bpfdefs.h helpers to bottom of file#288

Merged
gnurizen merged 1 commit into
mainfrom
move-parca-bpfdefs-to-bottom
Jun 1, 2026
Merged

ebpf: move parca-only bpfdefs.h helpers to bottom of file#288
gnurizen merged 1 commit into
mainfrom
move-parca-bpfdefs-to-bottom

Conversation

@gnurizen
Copy link
Copy Markdown
Collaborator

Moves parca-only helper declarations in support/ebpf/bpfdefs.h (bpf_ringbuf_reserve/submit/discard, bpf_probe_read_user_str, bpf_get_attach_cookie) from their current interleaved positions into a single trailing block at the bottom of the non-TESTING_COREDUMP arm. No behavior change.

Why

These three helpers are only used by parca-specific eBPF programs (support/ebpf/cuda.ebpf.c and support/ebpf/usdt_test.ebpf.c), but they sit inside the static <type> (*<name>)(...) = (void *)BPF_FUNC_<name>; block that upstream actively maintains. Upstream's typical insertion pattern is "add the new helper alphabetically next to the existing ones", which is exactly where parca's additions live now.

Concrete consequence: upstream-merge.sh currently can't auto-resolve upstream PR 0320a2a8 (open-telemetry#1278 Recover python frames when BPF fails to read PyCodeObject), which only adds a single small helper. The 3-way merge sees parca's additions overlap with upstream's hunk and stops the script before open-telemetry#1278.

What's moved

From To
static void *(*bpf_ringbuf_reserve)/_submit/_discard (lines 122-125, between bpf_get_prandom_u32 and bpf_trace_printk) Trailing block before #endif // !TESTING_COREDUMP
bpf_probe_read_user_str declaration + kernel-doc (lines 137-184) Trailing block
bpf_get_attach_cookie declaration + kernel-doc (lines 186-203) Trailing block

Also dropped: the now-obsolete // The sizeof in bpf_trace_printk() must include \0, else no output is generated. The \n is not needed on 5.8+ kernels, but definitely on 5.4 kernels. comment above #define printt. The macro no longer adds \n (upstream PR open-telemetry#1422 made ____fmt static and removed it), so the comment is historical context, and it sits in the same conflict-prone region.

Net effect on bpfdefs.h

96 lines removed, 21 added — the kernel-doc comments for bpf_probe_read_user_str and bpf_get_attach_cookie (66 lines combined) are stripped because they're verbatim copies of the Linux kernel man pages and aren't necessary for compilation. If we want them back as reference, we can keep a one-line comment with a kernel.org link.

The upstream-touched region of bpfdefs.h is now byte-identical to upstream's view of the same region (modulo unrelated parca commits in tsd_get_base, etc.).

Validation

  • make -C support/ebpf clean && make TARGET_ARCH=amd64 && make TARGET_ARCH=arm64: clean build, instructions amd64 51384 / arm64 64397.
  • 6.16 amd64 distro QEMU passes locally: rtld + USDT + cudaverify all green, timing events received on first simulation attempt for both TestCUDAEndToEnd{SingleShot,MultiProbe}.

Follow-up

After this lands, the next attempted upstream-merge.sh run should be able to auto-resolve open-telemetry#1278 (and likely several commits past it). That progress is unblocked by this PR.

The bpf_ringbuf_*, bpf_probe_read_user_str, and bpf_get_attach_cookie
declarations are parca-only (used by cuda.ebpf.c and usdt_test.ebpf.c)
but sit in the same block where upstream adds new helpers, so they
collide with most upstream merges. Move them to a trailing block to
keep that region byte-aligned with upstream.

Also drops the obsolete \n comment above #define printt (the macro no
longer adds \n).
@gnurizen gnurizen force-pushed the move-parca-bpfdefs-to-bottom branch from 0a64b0e to 64a3a4a Compare June 1, 2026 09:54
@gnurizen gnurizen marked this pull request as ready for review June 1, 2026 12:07
@gnurizen gnurizen merged commit 9a731d8 into main Jun 1, 2026
38 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant