From: Alan Maguire <alan.maguire@oracle.com>
To: Eduard Zingerman <eddyz87@gmail.com>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org
Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, mykolal@fb.com,
bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next] selftests/bpf: fix uprobe_multi compilation error
Date: Fri, 27 Sep 2024 11:26:07 +0100 [thread overview]
Message-ID: <d9846ceb-b758-4c17-82d1-e5504122a50a@oracle.com> (raw)
In-Reply-To: <084902540a09a7036b713bd2336955e9b63fb30b.camel@gmail.com>
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...)
>
> [...]
>
next prev parent reply other threads:[~2024-09-27 10:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-09-27 20:50 ` patchwork-bot+netdevbpf
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=d9846ceb-b758-4c17-82d1-e5504122a50a@oracle.com \
--to=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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