[PATCH v2 0/3] btf_encoder: do not encode functions consuming packed structs on stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
this series is a follow-up to the RFC sent in [1], which aimed to make
sure that functions consuming struct by value on stack were not encoded
in BTF.

This new series comes with a less "aggressive" strategy, and only skips
function encoding if:
- the function consumes a struct by value
- the struct is passed on the stack
- it is detected as packed (see class__infer_packed_attributes)

The detection is not done anymore in parameter__new, as it may be done
too early to have all the relevant info to properly infer the
attributes; it is now done in btf_encoder__encode_cu. The series also
comes with a simple test, but as the kernel don't have such case
exposed, this new test comes with a small out-of-tree module. The logic
is kept simple and the test is by default skipped (it needs to be
provided with a path to some kernel sources), as I am not sure how it
should integrate with the current CI effort done by Alan.

[1] https://lore.kernel.org/dwarves/20250618-btf_skip_structs_on_stack-v1-1-e70be639cc53@xxxxxxxxxxx/

Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@xxxxxxxxxxx>
---
Changes in v2:
- infer structs attributes
- skip function encoded if some consumed struct (passed on stack) is
  marked as packed
- add some tests in btf_functions.sh
- drop RFC prefix
- Link to v1: https://lore.kernel.org/r/20250618-btf_skip_structs_on_stack-v1-1-e70be639cc53@xxxxxxxxxxx

---
Alexis Lothoré (eBPF Foundation) (3):
      btf_encoder: skip functions consuming packed structs passed by value on stack
      tests: add some tests validating skipped functions due to uncertain arg location
      gitignore: ignore all the test kmod build-related files

 .gitignore             |  3 ++
 btf_encoder.c          | 50 ++++++++++++++++++++++++-
 dwarves.h              |  1 +
 tests/btf_functions.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/kmod/Makefile    |  1 +
 tests/kmod/kmod.c      | 69 +++++++++++++++++++++++++++++++++++
 6 files changed, 221 insertions(+), 2 deletions(-)
---
base-commit: 042d73962d35fdd1466e056f1ea14590b1cdbb9b
change-id: 20250617-btf_skip_structs_on_stack-006adf457d50

Best regards,
-- 
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux