BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: fix uprobe_multi compilation error
@ 2024-09-26 14:49 Alan Maguire
  2024-09-26 23:44 ` Eduard Zingerman
  2024-09-27 20:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Maguire @ 2024-09-26 14:49 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: martin.lau, eddyz87, song, yonghong.song, john.fastabend, kpsingh,
	sdf, haoluo, jolsa, mykolal, bpf, Alan Maguire

When building selftests, the following was seen:

uprobe_multi.c: In function ‘trigger_uprobe’:
uprobe_multi.c:108:40: error: ‘MADV_PAGEOUT’ undeclared (first use in this function)
  108 |                 madvise(addr, page_sz, MADV_PAGEOUT);
      |                                        ^~~~~~~~~~~~
uprobe_multi.c:108:40: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Makefile:850: bpf-next/tools/testing/selftests/bpf/uprobe_multi] Error 1

...even with updated UAPI headers. It seems the above value is
defined in UAPI <linux/mman.h> but including that file triggers
other redefinition errors.  Simplest solution is to add a
guarded definition, as was done for MADV_POPULATE_READ.

Fixes: 3c217a182018 ("selftests/bpf: add build ID tests")
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
 tools/testing/selftests/bpf/uprobe_multi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/bpf/uprobe_multi.c b/tools/testing/selftests/bpf/uprobe_multi.c
index c7828b13e5ff..dd38dc68f635 100644
--- a/tools/testing/selftests/bpf/uprobe_multi.c
+++ b/tools/testing/selftests/bpf/uprobe_multi.c
@@ -12,6 +12,10 @@
 #define MADV_POPULATE_READ 22
 #endif
 
+#ifndef MADV_PAGEOUT
+#define MADV_PAGEOUT 21
+#endif
+
 int __attribute__((weak)) uprobe(void)
 {
 	return 0;
-- 
2.43.5


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

* Re: [PATCH bpf-next] selftests/bpf: fix uprobe_multi compilation error
  2024-09-26 14:49 [PATCH bpf-next] selftests/bpf: fix uprobe_multi compilation error Alan Maguire
@ 2024-09-26 23:44 ` Eduard Zingerman
  2024-09-27 10:26   ` Alan Maguire
  2024-09-27 20:50 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Eduard Zingerman @ 2024-09-26 23:44 UTC (permalink / raw)
  To: Alan Maguire, ast, daniel, andrii
  Cc: martin.lau, song, yonghong.song, john.fastabend, kpsingh, sdf,
	haoluo, jolsa, mykolal, bpf

On Thu, 2024-09-26 at 15:49 +0100, Alan Maguire wrote:
> When building selftests, the following was seen:
> 
> uprobe_multi.c: In function ‘trigger_uprobe’:
> uprobe_multi.c:108:40: error: ‘MADV_PAGEOUT’ undeclared (first use in this function)
>   108 |                 madvise(addr, page_sz, MADV_PAGEOUT);
>       |                                        ^~~~~~~~~~~~
> uprobe_multi.c:108:40: note: each undeclared identifier is reported only once for each function it appears in
> make: *** [Makefile:850: bpf-next/tools/testing/selftests/bpf/uprobe_multi] Error 1
> 
> ...even with updated UAPI headers. It seems the above value is
> defined in UAPI <linux/mman.h> but including that file triggers
> other redefinition errors.  Simplest solution is to add a
> guarded definition, as was done for MADV_POPULATE_READ.
> 
> Fixes: 3c217a182018 ("selftests/bpf: add build ID tests")
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---

I was curious why this error is not triggered on my local machine or CI.
MADV_PAGEOUT is indeed defined in UAPI.
Selftests build picks it from host system header, which is
/usr/include/bits/mman-linux.h for my Fedora 40 setup.
The MADV_PAGEOUT was added by commit [1] back in 2019
(and should be available from Linux 5.4, I guess Alan uses a very old kernel).

I think that at some point in time we should adjust selftests to use
UAPI headers that come from the kernel being tested, not from the host.
Until that happens, I think this fix is fine.

[1] 1a4e58cce84e ("mm: introduce MADV_PAGEOUT")

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

(I want back to 2019...)

[...]


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

* Re: [PATCH bpf-next] selftests/bpf: fix uprobe_multi compilation error
  2024-09-26 23:44 ` Eduard Zingerman
@ 2024-09-27 10:26   ` Alan Maguire
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Maguire @ 2024-09-27 10:26 UTC (permalink / raw)
  To: Eduard Zingerman, ast, daniel, andrii
  Cc: martin.lau, song, yonghong.song, john.fastabend, kpsingh, sdf,
	haoluo, jolsa, mykolal, bpf

On 27/09/2024 00:44, Eduard Zingerman wrote:
> On Thu, 2024-09-26 at 15:49 +0100, Alan Maguire wrote:
>> When building selftests, the following was seen:
>>
>> uprobe_multi.c: In function ‘trigger_uprobe’:
>> uprobe_multi.c:108:40: error: ‘MADV_PAGEOUT’ undeclared (first use in this function)
>>   108 |                 madvise(addr, page_sz, MADV_PAGEOUT);
>>       |                                        ^~~~~~~~~~~~
>> uprobe_multi.c:108:40: note: each undeclared identifier is reported only once for each function it appears in
>> make: *** [Makefile:850: bpf-next/tools/testing/selftests/bpf/uprobe_multi] Error 1
>>
>> ...even with updated UAPI headers. It seems the above value is
>> defined in UAPI <linux/mman.h> but including that file triggers
>> other redefinition errors.  Simplest solution is to add a
>> guarded definition, as was done for MADV_POPULATE_READ.
>>
>> Fixes: 3c217a182018 ("selftests/bpf: add build ID tests")
>> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
>> ---
> 
> I was curious why this error is not triggered on my local machine or CI.
> MADV_PAGEOUT is indeed defined in UAPI.
> Selftests build picks it from host system header, which is
> /usr/include/bits/mman-linux.h for my Fedora 40 setup.
> The MADV_PAGEOUT was added by commit [1] back in 2019
> (and should be available from Linux 5.4, I guess Alan uses a very old kernel).
> 
> I think that at some point in time we should adjust selftests to use
> UAPI headers that come from the kernel being tested, not from the host.
> Until that happens, I think this fix is fine.
> 

From what I can see at my end, /usr/include/bits/mman.h is provided by
glibc-headers. On distros the glibc-headers can get quite out of date. I
do a "make headers_install" prior to running bpf selftests to get latest
UAPI headers from the kernel in /usr/include/linux, but that wasn't
enough in this case since /usr/include/sys/mman.h and
/usr/include/bits/mman.h were provided via glibc-headers.

When I tried using <linux/mman.h> in the program, I ended up getting
complaints about madvise() being undefined, and when I used both
<sys/mman.h> and <linux/mman.h> there were complaints about mutiple
definitions so the approach taken in the patch seemed like the most
straightforward.

Thanks for taking a look!

Alan

> [1] 1a4e58cce84e ("mm: introduce MADV_PAGEOUT")
> 
> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> 
> (I want back to 2019...)
> 
> [...]
> 


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

* Re: [PATCH bpf-next] selftests/bpf: fix uprobe_multi compilation error
  2024-09-26 14:49 [PATCH bpf-next] selftests/bpf: fix uprobe_multi compilation error Alan Maguire
  2024-09-26 23:44 ` Eduard Zingerman
@ 2024-09-27 20:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-27 20:50 UTC (permalink / raw)
  To: Alan Maguire
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal, bpf

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Thu, 26 Sep 2024 15:49:48 +0100 you wrote:
> When building selftests, the following was seen:
> 
> uprobe_multi.c: In function ‘trigger_uprobe’:
> uprobe_multi.c:108:40: error: ‘MADV_PAGEOUT’ undeclared (first use in this function)
>   108 |                 madvise(addr, page_sz, MADV_PAGEOUT);
>       |                                        ^~~~~~~~~~~~
> uprobe_multi.c:108:40: note: each undeclared identifier is reported only once for each function it appears in
> make: *** [Makefile:850: bpf-next/tools/testing/selftests/bpf/uprobe_multi] Error 1
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: fix uprobe_multi compilation error
    https://git.kernel.org/bpf/bpf-next/c/db38ed2cfa62

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-09-27 20:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 14:49 [PATCH bpf-next] selftests/bpf: fix uprobe_multi compilation error Alan Maguire
2024-09-26 23:44 ` Eduard Zingerman
2024-09-27 10:26   ` Alan Maguire
2024-09-27 20:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox