* [PATCH bpf-next v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
@ 2024-10-21 5:07 Jason Xing
2024-10-21 7:41 ` Jiri Olsa
0 siblings, 1 reply; 6+ messages in thread
From: Jason Xing @ 2024-10-21 5:07 UTC (permalink / raw)
To: ast, daniel, andrii, eddyz87, mykolal, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah
Cc: bpf, linux-kselftest, Jason Xing
From: Jason Xing <kernelxing@tencent.com>
When I compiled the tools/testing/selftests/bpf, the following error
pops out:
uprobe_multi.c: In function ‘trigger_uprobe’:
uprobe_multi.c:109:26: error: ‘MADV_PAGEOUT’ undeclared (first use in this function); did you mean ‘MADV_RANDOM’?
madvise(addr, page_sz, MADV_PAGEOUT);
^~~~~~~~~~~~
MADV_RANDOM
Including the <linux/linux/mman.h> header file solves this compilation error.
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
v2
Link: https://lore.kernel.org/all/20241020031422.46894-1-kerneljasonxing@gmail.com/
1. handle it in a proper way
---
tools/testing/selftests/bpf/uprobe_multi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/bpf/uprobe_multi.c b/tools/testing/selftests/bpf/uprobe_multi.c
index c7828b13e5ff..40231f02b95d 100644
--- a/tools/testing/selftests/bpf/uprobe_multi.c
+++ b/tools/testing/selftests/bpf/uprobe_multi.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
+#include <linux/mman.h>
#include <sys/mman.h>
#include <unistd.h>
#include <sdt.h>
--
2.37.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
2024-10-21 5:07 [PATCH bpf-next v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c Jason Xing
@ 2024-10-21 7:41 ` Jiri Olsa
2024-10-21 7:51 ` Jason Xing
0 siblings, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2024-10-21 7:41 UTC (permalink / raw)
To: Jason Xing
Cc: ast, daniel, andrii, eddyz87, mykolal, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, shuah, bpf,
linux-kselftest, Jason Xing
On Mon, Oct 21, 2024 at 01:07:06PM +0800, Jason Xing wrote:
> From: Jason Xing <kernelxing@tencent.com>
>
> When I compiled the tools/testing/selftests/bpf, the following error
> pops out:
> uprobe_multi.c: In function ‘trigger_uprobe’:
> uprobe_multi.c:109:26: error: ‘MADV_PAGEOUT’ undeclared (first use in this function); did you mean ‘MADV_RANDOM’?
> madvise(addr, page_sz, MADV_PAGEOUT);
> ^~~~~~~~~~~~
> MADV_RANDOM
>
> Including the <linux/linux/mman.h> header file solves this compilation error.
hi,
strange, uprobe_multi.c even has:
#ifndef MADV_PAGEOUT
#define MADV_PAGEOUT 21
#endif
and '#include <sys/mman.h>' should be all that's needed
could you please share more details (extra flags) on how you compile?
thanks,
jirka
>
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
> ---
> v2
> Link: https://lore.kernel.org/all/20241020031422.46894-1-kerneljasonxing@gmail.com/
> 1. handle it in a proper way
> ---
> tools/testing/selftests/bpf/uprobe_multi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/bpf/uprobe_multi.c b/tools/testing/selftests/bpf/uprobe_multi.c
> index c7828b13e5ff..40231f02b95d 100644
> --- a/tools/testing/selftests/bpf/uprobe_multi.c
> +++ b/tools/testing/selftests/bpf/uprobe_multi.c
> @@ -4,6 +4,7 @@
> #include <string.h>
> #include <stdbool.h>
> #include <stdint.h>
> +#include <linux/mman.h>
> #include <sys/mman.h>
> #include <unistd.h>
> #include <sdt.h>
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
2024-10-21 7:41 ` Jiri Olsa
@ 2024-10-21 7:51 ` Jason Xing
2024-10-21 8:07 ` Jason Xing
0 siblings, 1 reply; 6+ messages in thread
From: Jason Xing @ 2024-10-21 7:51 UTC (permalink / raw)
To: Jiri Olsa
Cc: ast, daniel, andrii, eddyz87, mykolal, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, shuah, bpf,
linux-kselftest, Jason Xing
On Mon, Oct 21, 2024 at 3:41 PM Jiri Olsa <olsajiri@gmail.com> wrote:
>
> On Mon, Oct 21, 2024 at 01:07:06PM +0800, Jason Xing wrote:
> > From: Jason Xing <kernelxing@tencent.com>
> >
> > When I compiled the tools/testing/selftests/bpf, the following error
> > pops out:
> > uprobe_multi.c: In function ‘trigger_uprobe’:
> > uprobe_multi.c:109:26: error: ‘MADV_PAGEOUT’ undeclared (first use in this function); did you mean ‘MADV_RANDOM’?
> > madvise(addr, page_sz, MADV_PAGEOUT);
> > ^~~~~~~~~~~~
> > MADV_RANDOM
> >
> > Including the <linux/linux/mman.h> header file solves this compilation error.
>
> hi,
> strange, uprobe_multi.c even has:
>
> #ifndef MADV_PAGEOUT
> #define MADV_PAGEOUT 21
> #endif
>
> and '#include <sys/mman.h>' should be all that's needed
>
> could you please share more details (extra flags) on how you compile?
OMG, thanks for reminding me. The net-next branch that I compiled
doesn't have those three lines. Now I can see them in bpf-next. So I
think the issue has been fixed already :)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
2024-10-21 7:51 ` Jason Xing
@ 2024-10-21 8:07 ` Jason Xing
2024-10-21 9:34 ` Jiri Olsa
0 siblings, 1 reply; 6+ messages in thread
From: Jason Xing @ 2024-10-21 8:07 UTC (permalink / raw)
To: Jiri Olsa
Cc: ast, daniel, andrii, eddyz87, mykolal, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, shuah, bpf,
linux-kselftest, Jason Xing
On Mon, Oct 21, 2024 at 3:51 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> On Mon, Oct 21, 2024 at 3:41 PM Jiri Olsa <olsajiri@gmail.com> wrote:
> >
> > On Mon, Oct 21, 2024 at 01:07:06PM +0800, Jason Xing wrote:
> > > From: Jason Xing <kernelxing@tencent.com>
> > >
> > > When I compiled the tools/testing/selftests/bpf, the following error
> > > pops out:
> > > uprobe_multi.c: In function ‘trigger_uprobe’:
> > > uprobe_multi.c:109:26: error: ‘MADV_PAGEOUT’ undeclared (first use in this function); did you mean ‘MADV_RANDOM’?
> > > madvise(addr, page_sz, MADV_PAGEOUT);
> > > ^~~~~~~~~~~~
> > > MADV_RANDOM
> > >
> > > Including the <linux/linux/mman.h> header file solves this compilation error.
> >
> > hi,
> > strange, uprobe_multi.c even has:
> >
> > #ifndef MADV_PAGEOUT
> > #define MADV_PAGEOUT 21
> > #endif
> >
> > and '#include <sys/mman.h>' should be all that's needed
> >
> > could you please share more details (extra flags) on how you compile?
>
> OMG, thanks for reminding me. The net-next branch that I compiled
> doesn't have those three lines. Now I can see them in bpf-next. So I
> think the issue has been fixed already :)
Link is https://lore.kernel.org/bpf/d9846ceb-b758-4c17-82d1-e5504122a50a@oracle.com/
The previous comment is not that right. Making sure to include
<sys/mman.h> first solves the issue so there are no complaints when
compiling. No need to define MADV_PAGEOUT, I think.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
2024-10-21 8:07 ` Jason Xing
@ 2024-10-21 9:34 ` Jiri Olsa
2024-10-21 10:49 ` Jason Xing
0 siblings, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2024-10-21 9:34 UTC (permalink / raw)
To: Jason Xing, Alan Maguire
Cc: Jiri Olsa, ast, daniel, andrii, eddyz87, mykolal, martin.lau,
song, yonghong.song, john.fastabend, kpsingh, sdf, haoluo, shuah,
bpf, linux-kselftest, Jason Xing
On Mon, Oct 21, 2024 at 04:07:15PM +0800, Jason Xing wrote:
> On Mon, Oct 21, 2024 at 3:51 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
> >
> > On Mon, Oct 21, 2024 at 3:41 PM Jiri Olsa <olsajiri@gmail.com> wrote:
> > >
> > > On Mon, Oct 21, 2024 at 01:07:06PM +0800, Jason Xing wrote:
> > > > From: Jason Xing <kernelxing@tencent.com>
> > > >
> > > > When I compiled the tools/testing/selftests/bpf, the following error
> > > > pops out:
> > > > uprobe_multi.c: In function ‘trigger_uprobe’:
> > > > uprobe_multi.c:109:26: error: ‘MADV_PAGEOUT’ undeclared (first use in this function); did you mean ‘MADV_RANDOM’?
> > > > madvise(addr, page_sz, MADV_PAGEOUT);
> > > > ^~~~~~~~~~~~
> > > > MADV_RANDOM
> > > >
> > > > Including the <linux/linux/mman.h> header file solves this compilation error.
> > >
> > > hi,
> > > strange, uprobe_multi.c even has:
> > >
> > > #ifndef MADV_PAGEOUT
> > > #define MADV_PAGEOUT 21
> > > #endif
> > >
> > > and '#include <sys/mman.h>' should be all that's needed
> > >
> > > could you please share more details (extra flags) on how you compile?
> >
> > OMG, thanks for reminding me. The net-next branch that I compiled
> > doesn't have those three lines. Now I can see them in bpf-next. So I
> > think the issue has been fixed already :)
>
> Link is https://lore.kernel.org/bpf/d9846ceb-b758-4c17-82d1-e5504122a50a@oracle.com/
>
> The previous comment is not that right. Making sure to include
> <sys/mman.h> first solves the issue so there are no complaints when
> compiling. No need to define MADV_PAGEOUT, I think.
right, but looks like it was not enough on Alan's setup [1]
jirka
[1] c27d8235ba97 selftests/bpf: Fix uprobe_multi compilation error
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
2024-10-21 9:34 ` Jiri Olsa
@ 2024-10-21 10:49 ` Jason Xing
0 siblings, 0 replies; 6+ messages in thread
From: Jason Xing @ 2024-10-21 10:49 UTC (permalink / raw)
To: Jiri Olsa
Cc: Alan Maguire, ast, daniel, andrii, eddyz87, mykolal, martin.lau,
song, yonghong.song, john.fastabend, kpsingh, sdf, haoluo, shuah,
bpf, linux-kselftest, Jason Xing
On Mon, Oct 21, 2024 at 5:34 PM Jiri Olsa <olsajiri@gmail.com> wrote:
>
> On Mon, Oct 21, 2024 at 04:07:15PM +0800, Jason Xing wrote:
> > On Mon, Oct 21, 2024 at 3:51 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
> > >
> > > On Mon, Oct 21, 2024 at 3:41 PM Jiri Olsa <olsajiri@gmail.com> wrote:
> > > >
> > > > On Mon, Oct 21, 2024 at 01:07:06PM +0800, Jason Xing wrote:
> > > > > From: Jason Xing <kernelxing@tencent.com>
> > > > >
> > > > > When I compiled the tools/testing/selftests/bpf, the following error
> > > > > pops out:
> > > > > uprobe_multi.c: In function ‘trigger_uprobe’:
> > > > > uprobe_multi.c:109:26: error: ‘MADV_PAGEOUT’ undeclared (first use in this function); did you mean ‘MADV_RANDOM’?
> > > > > madvise(addr, page_sz, MADV_PAGEOUT);
> > > > > ^~~~~~~~~~~~
> > > > > MADV_RANDOM
> > > > >
> > > > > Including the <linux/linux/mman.h> header file solves this compilation error.
> > > >
> > > > hi,
> > > > strange, uprobe_multi.c even has:
> > > >
> > > > #ifndef MADV_PAGEOUT
> > > > #define MADV_PAGEOUT 21
> > > > #endif
> > > >
> > > > and '#include <sys/mman.h>' should be all that's needed
> > > >
> > > > could you please share more details (extra flags) on how you compile?
> > >
> > > OMG, thanks for reminding me. The net-next branch that I compiled
> > > doesn't have those three lines. Now I can see them in bpf-next. So I
> > > think the issue has been fixed already :)
> >
> > Link is https://lore.kernel.org/bpf/d9846ceb-b758-4c17-82d1-e5504122a50a@oracle.com/
> >
> > The previous comment is not that right. Making sure to include
> > <sys/mman.h> first solves the issue so there are no complaints when
> > compiling. No need to define MADV_PAGEOUT, I think.
>
> right, but looks like it was not enough on Alan's setup [1]
I know what happened in his environment. If he wrote the following
code in this order, he would see the redefinition error:
#include <sys/mman.h>
+#include <linux/mman.h>
The key is to reorder those two lines like this:
+#include <linux/mman.h>
#include <sys/mman.h>
Then everything goes fine :) That's why I said his comment is not that right.
>
> jirka
>
>
> [1] c27d8235ba97 selftests/bpf: Fix uprobe_multi compilation error
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-21 10:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 5:07 [PATCH bpf-next v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c Jason Xing
2024-10-21 7:41 ` Jiri Olsa
2024-10-21 7:51 ` Jason Xing
2024-10-21 8:07 ` Jason Xing
2024-10-21 9:34 ` Jiri Olsa
2024-10-21 10:49 ` Jason Xing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox