* [PATCH bpf-next] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
@ 2024-10-20 3:14 Jason Xing
2024-10-20 4:10 ` Jason Xing
0 siblings, 1 reply; 3+ messages in thread
From: Jason Xing @ 2024-10-20 3:14 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
We can see MADV_PAGEOUT existing in mman-common.h on x86 arch, so
including this header file solves this compilation error.
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
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..b0e11ffe0e1c 100644
--- a/tools/testing/selftests/bpf/uprobe_multi.c
+++ b/tools/testing/selftests/bpf/uprobe_multi.c
@@ -5,6 +5,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <sys/mman.h>
+#include <mman-common.h>
#include <unistd.h>
#include <sdt.h>
--
2.37.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
2024-10-20 3:14 [PATCH bpf-next] bpf: handle MADV_PAGEOUT error in uprobe_multi.c Jason Xing
@ 2024-10-20 4:10 ` Jason Xing
2024-10-20 5:02 ` Jason Xing
0 siblings, 1 reply; 3+ messages in thread
From: Jason Xing @ 2024-10-20 4:10 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
On Sun, Oct 20, 2024 at 11:14 AM Jason Xing <kerneljasonxing@gmail.com> 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
>
> We can see MADV_PAGEOUT existing in mman-common.h on x86 arch, so
> including this header file solves this compilation error.
>
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
> ---
> 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..b0e11ffe0e1c 100644
> --- a/tools/testing/selftests/bpf/uprobe_multi.c
> +++ b/tools/testing/selftests/bpf/uprobe_multi.c
> @@ -5,6 +5,7 @@
> #include <stdbool.h>
> #include <stdint.h>
> #include <sys/mman.h>
> +#include <mman-common.h>
uprobe_multi.c:8:10: fatal error: mman-common.h: No such file or directory
61 8 | #include <mman-common.h>
62 | ^~~~~~~~~~~~~~~
After seeing the error that CI reported to me, I realized that I did
cp /usr/include/asm-generic/mman-common.h to
/usr/include/mman-common.h.
If I try "#include <asm-generic/mman-common.h>", then I will see
redefinition error:
tools/include/uapi/asm-generic/mman-common.h:26: error: "MAP_POPULATE"
redefined [-Werror]
#define MAP_POPULATE 0x008000 /* populate (prefault) pagetables */
In file included from /usr/include/sys/mman.h:41,
from uprobe_multi.c:7:
/usr/include/bits/mman.h:38: note: this is the location of the
previous definition
# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
It looks odd to me. Let me dig into it more.
Thanks,
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: handle MADV_PAGEOUT error in uprobe_multi.c
2024-10-20 4:10 ` Jason Xing
@ 2024-10-20 5:02 ` Jason Xing
0 siblings, 0 replies; 3+ messages in thread
From: Jason Xing @ 2024-10-20 5:02 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
On Sun, Oct 20, 2024 at 12:10 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> On Sun, Oct 20, 2024 at 11:14 AM Jason Xing <kerneljasonxing@gmail.com> 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
> >
> > We can see MADV_PAGEOUT existing in mman-common.h on x86 arch, so
> > including this header file solves this compilation error.
> >
> > Signed-off-by: Jason Xing <kernelxing@tencent.com>
> > ---
> > 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..b0e11ffe0e1c 100644
> > --- a/tools/testing/selftests/bpf/uprobe_multi.c
> > +++ b/tools/testing/selftests/bpf/uprobe_multi.c
> > @@ -5,6 +5,7 @@
> > #include <stdbool.h>
> > #include <stdint.h>
> > #include <sys/mman.h>
> > +#include <mman-common.h>
>
> uprobe_multi.c:8:10: fatal error: mman-common.h: No such file or directory
> 61 8 | #include <mman-common.h>
> 62 | ^~~~~~~~~~~~~~~
>
> After seeing the error that CI reported to me, I realized that I did
> cp /usr/include/asm-generic/mman-common.h to
> /usr/include/mman-common.h.
>
> If I try "#include <asm-generic/mman-common.h>", then I will see
> redefinition error:
> tools/include/uapi/asm-generic/mman-common.h:26: error: "MAP_POPULATE"
> redefined [-Werror]
> #define MAP_POPULATE 0x008000 /* populate (prefault) pagetables */
>
> In file included from /usr/include/sys/mman.h:41,
> from uprobe_multi.c:7:
> /usr/include/bits/mman.h:38: note: this is the location of the
> previous definition
> # define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
>
> It looks odd to me. Let me dig into it more.
Ah, I know how to fix it:
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>
It works. I'll post it in 24 hours.
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-20 5:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-20 3:14 [PATCH bpf-next] bpf: handle MADV_PAGEOUT error in uprobe_multi.c Jason Xing
2024-10-20 4:10 ` Jason Xing
2024-10-20 5:02 ` Jason Xing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox