bpf: handle MADV_PAGEOUT error in uprobe_multi.c
Subsystems (3)
PATCH v2 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_RANDOMIncluding the <linux/linux/mman.h> header file solves this compilation error.
---
v2
1. handle it in a proper way
--- tools/testing/selftests/bpf/uprobe_multi.c | 1 + 1 file changed, 1 insertion(+)
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>
Signature · 1 line
2.37.3
Quoted 11 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_RANDOMIncluding 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
Quoted 25 lines
Signed-off-by Jason Xing <[email protected]>---
v21. handle it in a proper way
--- tools/testing/selftests/bpf/uprobe_multi.c | 1 + 1 file changed, 1 insertion(+)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> Signature · 1 line
2.37.3
Quoted 17 lines · Jiri Olsa
Quoted 11 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_RANDOMIncluding the <
linux/linux/mman.h> header file solves this compilation error.hi,
strange,uprobe_multi.ceven has:
Quoted 7 lines
#ifndef
MADV_PAGEOUT
#defineMADV_PAGEOUT21
#endifand '#include <
sys/mman.h>' should be all that's neededcould 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 :)
Quoted 23 lines · Jason Xing
Quoted 21 lines · Jiri Olsa
Quoted 11 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_RANDOMIncluding the <
linux/linux/mman.h> header file solves this compilation error.hi,
strange,uprobe_multi.ceven has:#ifndef
MADV_PAGEOUT
#defineMADV_PAGEOUT21
#endif
Quoted 7 lines
Quoted 3 lines
and '#include <
sys/mman.h>' should be all that's neededcould 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/[email protected]/
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.
Quoted 32 lines · Jason Xing
Quoted 23 lines · Jason Xing
Quoted 21 lines · Jiri Olsa
Quoted 11 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_RANDOMIncluding the <
linux/linux/mman.h> header file solves this compilation error.hi,
strange,uprobe_multi.ceven has:#ifndef
MADV_PAGEOUT
#defineMADV_PAGEOUT21
#endifQuoted 7 lines
Quoted 3 lines
and '#include <
sys/mman.h>' should be all that's neededcould 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 :)
Quoted 5 lines
Link is https://lore.kernel.org/bpf/[email protected]/
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 defineMADV_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
Quoted 34 lines · Jiri Olsa
Quoted 32 lines · Jason Xing
Quoted 30 lines · Jason Xing
Quoted 17 lines · Jiri Olsa
Quoted 11 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_RANDOMIncluding the <
linux/linux/mman.h> header file solves this compilation error.hi,
strange,uprobe_multi.ceven has:Quoted 7 lines
#ifndef
MADV_PAGEOUT
#defineMADV_PAGEOUT21
#endifand '#include <
sys/mman.h>' should be all that's neededcould 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 :)
Quoted 7 lines
Quoted 5 lines
Link is https://lore.kernel.org/bpf/[email protected]/
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 defineMADV_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.
Quoted 5 lines
jirka
[1]
c27d8235ba97selftests/bpf: Fixuprobe_multicompilation error