bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] btf_encoder: do not encode functions consuming packed structs on stack
@ 2025-07-03  9:02 Alexis Lothoré (eBPF Foundation)
  2025-07-03  9:02 ` [PATCH v2 1/3] btf_encoder: skip functions consuming packed structs passed by value " Alexis Lothoré (eBPF Foundation)
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Alexis Lothoré (eBPF Foundation) @ 2025-07-03  9:02 UTC (permalink / raw)
  To: dwarves
  Cc: bpf, Alan Maguire, Arnaldo Carvalho de Melo, Alexei Starovoitov,
	Thomas Petazzoni, Bastien Curutchet, ebpf,
	Alexis Lothoré (eBPF Foundation)

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@bootlin.com/

Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
---
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@bootlin.com

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


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

end of thread, other threads:[~2025-07-04 21:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03  9:02 [PATCH v2 0/3] btf_encoder: do not encode functions consuming packed structs on stack Alexis Lothoré (eBPF Foundation)
2025-07-03  9:02 ` [PATCH v2 1/3] btf_encoder: skip functions consuming packed structs passed by value " Alexis Lothoré (eBPF Foundation)
2025-07-03 18:17   ` Ihor Solodrai
2025-07-04  9:01     ` Alexis Lothoré
2025-07-04 19:59       ` Ihor Solodrai
2025-07-04 21:10         ` Alexis Lothoré
2025-07-04 20:05   ` Ihor Solodrai
2025-07-04 21:12     ` Alexis Lothoré
2025-07-03  9:02 ` [PATCH v2 2/3] tests: add some tests validating skipped functions due to uncertain arg location Alexis Lothoré (eBPF Foundation)
2025-07-03 18:31   ` Ihor Solodrai
2025-07-04  9:06     ` Alexis Lothoré
2025-07-03  9:02 ` [PATCH v2 3/3] gitignore: ignore all the test kmod build-related files Alexis Lothoré (eBPF Foundation)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).