pahole: Replace or add functions with true signatures in btf
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 2 repliesIn review
- v13 patches 4 repliesSuperseded
Changes in v2 from the cover letter
- v1: https://lore.kernel.org/bpf/[email protected]/
- For functions like <foo>.llvm.<hash>() where the function <foo> is promoted to <foo>.llvm.<hash>(). Previous llvm ([1]) allows to have new-signature dwarf entries for both <foo> and <foo>.llvm.<hash> and pahole will generate two new functions. Now, llvm will only generate one entry with name <foo>.llvm.<hash> so pahole will generate one entry for <foo>.llvm.<hash>.
- Since v2 approach intends to generate functions with name in kallsyms, removing function suffix is avoided.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | btf_encoder: Refactor elf_functions__new() with struct btf_encoder as argumentbtf_encoder.c | +4 | 0 replies | |
| 2/2 | pahole: Replace or add functions with true signatures in btfbtf_encoder.c dwarf_loader.c dwarves.h +1 more | +132 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH dwarves v2 0/2] pahole: Replace or add functions with true signatures in btf
Current vmlinux BTF encoding is based on the source level signatures. But the compiler may do some optimization and changed the signature. If the user tried with source level signature, their initial implementation may have wrong results and then the user need to check what is the problem and work around it, e.g. through kprobe since kprobe does not need vmlinux BTF.
The following is a concrete example for [1].
The original source signature:
typedef struct {
union {
void *kernel;
void __user *user;
};
bool is_kernel : 1; } sockptr_t;
typedef sockptr_t bpfptr_t;
static int map_create(union bpf_attr *attr, bpfptr_t uattr) { ... }
After compiler optimization, the signature becomes:
static int map_create(union bpf_attr *attr, bool is_kernel) { ... }
To do proper tracing, it would be good for the users to know the changed signature. With the actual signature, both kprobe and fentry should work as usual. This can avoid user surprise and improve developer productivity.
The llvm compiler patch [1] collects true signature and encoded those functions in dwarf. pahole will process these functions and replace old signtures with true signatures. Additionally, new functions (e.g., foo.llvm.<hash>) can be encoded in vmlinux BTF as well.
Patches 1 is a refactor change. Patch 2 has the detailed explanation in commit message and implements the logic to encode replaced or new signatures to vmlinux BTF. Please see Patch 2 for details.
[1] https://github.com/llvm/llvm-project/pull/165310
Changelogs:
v1 -> v2:
- v1: https://lore.kernel.org/bpf/[email protected]/
- For functions like <foo>.llvm.<hash>() where the function <foo> is promoted to <foo>.llvm.<hash>(). Previous llvm ([1]) allows to have new-signature dwarf entries for both <foo> and <foo>.llvm.<hash> and pahole will generate two new functions. Now, llvm will only generate one entry with name <foo>.llvm.<hash> so pahole will generate one entry for <foo>.llvm.<hash>.
- Since v2 approach intends to generate functions with name in kallsyms, removing function suffix is avoided.
Yonghong Song (2):
btf_encoder: Refactor elf_functions__new() with struct btf_encoder as
argument
pahole: Replace or add functions with true signatures in btf
btf_encoder.c | 52 +++++++++++++++++++++++++------- dwarf_loader.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ dwarves.h | 4 +++ pahole.c | 9 ++++++ 4 files changed, 136 insertions(+), 10 deletions(-)
Signature · 1 line
2.47.3