diff mbox series

[bpf-next,v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c

Message ID 20241021050706.29403-1-kerneljasonxing@gmail.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next,v2] bpf: handle MADV_PAGEOUT error in uprobe_multi.c | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success Errors and warnings before: 0 (+1) this patch: 0 (+1)
netdev/cc_maintainers success CCed 16 of 16 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-40 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-31 success Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-38 success Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-39 success Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18-O2
bpf/vmtest-bpf-next-VM_Test-17 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17-O2
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-18 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc

Commit Message

Jason Xing Oct. 21, 2024, 5:07 a.m. UTC
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(+)

Comments

Jiri Olsa Oct. 21, 2024, 7:41 a.m. UTC | #1
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
>
Jason Xing Oct. 21, 2024, 7:51 a.m. UTC | #2
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 :)
Jason Xing Oct. 21, 2024, 8:07 a.m. UTC | #3
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.
Jiri Olsa Oct. 21, 2024, 9:34 a.m. UTC | #4
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
Jason Xing Oct. 21, 2024, 10:49 a.m. UTC | #5
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
diff mbox series

Patch

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>