bpf: handle MADV_PAGEOUT error in uprobe_multi.c
Subsystems (3)
PATCH 1/1 bpf: handle MADV_PAGEOUT error in uprobe_multi.c
From: Jason Xing <[email protected]>
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_RANDOMWe can see MADV_PAGEOUT existing in mman-common.h on x86 arch, so including this header file solves this compilation error.
--- tools/testing/selftests/bpf/uprobe_multi.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/uprobe_multi.c +1 -0
@@ -5,6 +5,7 @@#include <stdbool.h> #include <stdint.h> #include <sys/mman.h> +#include <mman-common.h> #include <unistd.h> #include <sdt.h>
Signature · 1 line
2.37.3
Quoted 24 lines · Jason Xing
From: Jason Xing <[email protected]>
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_RANDOMWe can see
MADV_PAGEOUTexisting inmman-common.hon x86 arch, so including this header file solves this compilation error.Signed-off-by Jason Xing <[email protected]>--- tools/testing/selftests/bpf/uprobe_multi.c | 1 + 1 file changed, 1 insertion(+)tools/testing/selftests/bpf/uprobe_multi.c +0
-0
tools/testing/selftests/bpf/uprobe_multi.c line 8
Quoted 4 lines
tools/testing/selftests/bpf/uprobe_multi.c +1
-0@@ -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
Quoted 45 lines · Jason Xing
Quoted 24 lines · Jason Xing
From: Jason Xing <[email protected]>
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_RANDOMWe can see
MADV_PAGEOUTexisting inmman-common.hon x86 arch, so including this header file solves this compilation error.Signed-off-by Jason Xing <[email protected]>--- tools/testing/selftests/bpf/uprobe_multi.c | 1 + 1 file changed, 1 insertion(+)tools/testing/selftests/bpf/uprobe_multi.c +0
-0tools/testing/selftests/bpf/uprobe_multi.c line 8
Quoted 4 lines
tools/testing/selftests/bpf/uprobe_multi.c +1
-0@@ -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.hto/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]
#defineMAP_POPULATE0x008000/* populate (prefault) pagetables */
Quoted 7 lines
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:
(quoted diff) +0 -0
b/tools/testing/selftests/bpf/uprobe_multi.c
index c7828b13e5ff..40231f02b95d 100644
tools/testing/selftests/bpf/uprobe_multi.c +1 -0
@@ -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.