public inbox for dwarves@vger.kernel.org
 help / color / mirror / Atom feed
From: "Alexis Lothoré" <alexis.lothore@bootlin.com>
To: "Ihor Solodrai" <ihor.solodrai@linux.dev>, <dwarves@vger.kernel.org>
Cc: <bpf@vger.kernel.org>, "Alan Maguire" <alan.maguire@oracle.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Alexei Starovoitov" <ast@fb.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Bastien Curutchet" <bastien.curutchet@bootlin.com>,
	<ebpf@linuxfoundation.org>
Subject: Re: [PATCH v2 2/3] tests: add some tests validating skipped functions due to uncertain arg location
Date: Fri, 04 Jul 2025 11:06:12 +0200	[thread overview]
Message-ID: <DB35GID20CS5.3LRBJWIK4E1YU@bootlin.com> (raw)
In-Reply-To: <f696f834-bca6-4f9e-a81e-f7e45126e2eb@linux.dev>

On Thu Jul 3, 2025 at 8:31 PM CEST, Ihor Solodrai wrote:
> On 7/3/25 2:02 AM, Alexis Lothoré (eBPF Foundation) wrote:
>> Add a small kernel module representing specific cases likely absent from
>> standard vmlinux files. As a starter, the introduced module exposes a
>> few functions consuming structs passed by value, some passed by
>> register, some passed on the stack:
>> 
>>    int kmod_test_init(void);
>>    int test_kmod_func_ok(int, void *, char, short int);
>>    int test_kmod_func_struct_ok(int, void *, char, struct kmod_struct);
>>    int test_kmod_func_struct_on_stack_ok(int, void *, char, short int, int, \
>>      void *, char, short int, struct kmod_struct);
>>    int test_kmod_func_struct_on_stack_ko(int, void *, char, short int, int, \
>>      void *, char, short int, struct kmod_struct_packed);
>> 
>> Then enrich btf_functions.sh to make it perform the following steps:
>> - build the module
>> - generate BTF info and pfunct listing, both with dwarf and the
>>    generated BTF
>> - check that any function encoded in BTF is found in DWARF
>> - check that any function announced as skipped is indeed absent from BTF
>> - check that any skipped function has been skipped due to uncertain
>>    parameter location
>> 
>> Those new tests are executed only if a kernel directory is provided as
>> script's second argument, they are otherwise skipped.
>
> While this shouldn't be a problem for CI, since it checks out a kernel
> tree to test vmlinux as input, I wonder if there is a way to do the
> same test without this dependency.
>
> We need to generate a binary with DWARF, containing function
> prototypes with packed/aligned attributes. Give it to pahole and see
> that those functions were skipped.
>
> Any reason it must be a kernel module? Am I missing something?

I guess I have no valid reason, I just focused too much on a specific use
case :) It would indeed be simpler with a bare userspace binary, I'll check
further and change it.

>> Example of the new test execution:
>>    Encoding...Matched 4 functions exactly.
>>    Ok
>>    Validation of skipped function logic...
>>    Skipped encoding 1 functions in BTF.
>>    Ok
>>    Validating skipped functions have uncertain parameter location...
>>    Found 1 legitimately skipped function due to uncertain loc
>>    Ok

> This part fails for me:
>
> isolodrai@isolodrai-fedora-PC2K40WQ:~/pahole/tests$ 
> KDIR=/home/isolodrai/kernels/bpf-next 
> vmlinux=/home/isolodrai/kernels/bpf-next/vmlinux ./btf_functions.sh
> Validation of BTF encoding of functions; this may take some time: Ok
> Validation of BTF encoding corner cases with kmod functions; this may 
> take some time: make: Entering directory '/home/isolodrai/kernels/bpf-next'
> Makefile:199: *** specified external module directory "./kmod" does not 
> exist.  Stop.
> make: Leaving directory '/home/isolodrai/kernels/bpf-next'
> No skipped functions.  Done.
>
> Maybe:
>
> diff --git a/tests/btf_functions.sh b/tests/btf_functions.sh
> index 64810b7..fcb1591 100755
> --- a/tests/btf_functions.sh
> +++ b/tests/btf_functions.sh
> @@ -208,7 +208,7 @@ fi
>   echo -n "Validation of BTF encoding corner cases with kmod functions; 
> this may take some time: "
>
>   test -n "$VERBOSE" && printf "\nBuilding kmod..."
> -tests_dir=$(dirname $0)
> +tests_dir=$(realpath $(dirname $0))
>   make -C ${KDIR} M=${tests_dir}/kmod
>
>   test -n "$VERBOSE" && printf "\nEncoding..."
>
>
> Also, in case kernel is built with LLVM, one must set LLVM=1.
> Not sure if this is detectable by the test.

Yeah, the tests_dir computation is a bit fragile. I saw it in tests.sh, and
so I assumed use cases were simple enough to keep this simple logic. I'll
update it to make it more robust.

Alexis

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


  reply	other threads:[~2025-07-04  9:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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é [this message]
2025-07-03  9:02 ` [PATCH v2 3/3] gitignore: ignore all the test kmod build-related files Alexis Lothoré (eBPF Foundation)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB35GID20CS5.3LRBJWIK4E1YU@bootlin.com \
    --to=alexis.lothore@bootlin.com \
    --cc=acme@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=ast@fb.com \
    --cc=bastien.curutchet@bootlin.com \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=ebpf@linuxfoundation.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox