diff mbox series

[bpf-next] bpf: fix compilation error without CGROUPS

Message ID 20231031-bpf-compil-err-css-v1-1-e2244c637835@kernel.org (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] bpf: fix compilation error without CGROUPS | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
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: 1373 this patch: 1373
netdev/cc_maintainers success CCed 14 of 14 maintainers
netdev/build_clang success Errors and warnings before: 1388 this patch: 1388
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 Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1398 this patch: 1398
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 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-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-3 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 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-14 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-9 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-llvm-16 / build / build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-16 / veristat
bpf/vmtest-bpf-next-VM_Test-18 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 fail Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-16 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-llvm-16 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-llvm-16 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-llvm-16 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 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-20 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-19 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-13 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for s390x-gcc / test (test_maps, false, 360) / test_maps on s390x with gcc

Commit Message

Matthieu Baerts (NGI0) Oct. 31, 2023, 3:49 p.m. UTC
Our MPTCP CI complained [1] -- and KBuild too -- that it was no longer
possible to build the kernel without CONFIG_CGROUPS:

  kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_new':
  kernel/bpf/task_iter.c:919:14: error: 'CSS_TASK_ITER_PROCS' undeclared (first use in this function)
    919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
        |              ^~~~~~~~~~~~~~~~~~~
  kernel/bpf/task_iter.c:919:14: note: each undeclared identifier is reported only once for each function it appears in
  kernel/bpf/task_iter.c:919:36: error: 'CSS_TASK_ITER_THREADED' undeclared (first use in this function)
    919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
        |                                    ^~~~~~~~~~~~~~~~~~~~~~
  kernel/bpf/task_iter.c:927:60: error: invalid application of 'sizeof' to incomplete type 'struct css_task_iter'
    927 |         kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter));
        |                                                            ^~~~~~
  kernel/bpf/task_iter.c:930:9: error: implicit declaration of function 'css_task_iter_start'; did you mean 'task_seq_start'? [-Werror=implicit-function-declaration]
    930 |         css_task_iter_start(css, flags, kit->css_it);
        |         ^~~~~~~~~~~~~~~~~~~
        |         task_seq_start
  kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_next':
  kernel/bpf/task_iter.c:940:16: error: implicit declaration of function 'css_task_iter_next'; did you mean 'class_dev_iter_next'? [-Werror=implicit-function-declaration]
    940 |         return css_task_iter_next(kit->css_it);
        |                ^~~~~~~~~~~~~~~~~~
        |                class_dev_iter_next
  kernel/bpf/task_iter.c:940:16: error: returning 'int' from a function with return type 'struct task_struct *' makes pointer from integer without a cast [-Werror=int-conversion]
    940 |         return css_task_iter_next(kit->css_it);
        |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_destroy':
  kernel/bpf/task_iter.c:949:9: error: implicit declaration of function 'css_task_iter_end' [-Werror=implicit-function-declaration]
    949 |         css_task_iter_end(kit->css_it);
        |         ^~~~~~~~~~~~~~~~~

This patch simply surrounds with a #ifdef the new code requiring CGroups
support. It seems enough for the compiler and this is similar to
bpf_iter_css_{new,next,destroy}() functions where no other #ifdef have
been added in kernel/bpf/helpers.c and in the selftests.

Fixes: 9c66dc94b62a ("bpf: Introduce css_task open-coded iterator kfuncs")
Link: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/6665206927
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310260528.aHWgVFqq-lkp@intel.com/
Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
---
 kernel/bpf/task_iter.c | 4 ++++
 1 file changed, 4 insertions(+)


---
base-commit: f1c73396133cb3d913e2075298005644ee8dfade
change-id: 20231031-bpf-compil-err-css-056f3db04860

Best regards,

Comments

Jiri Olsa Oct. 31, 2023, 5:05 p.m. UTC | #1
On Tue, Oct 31, 2023 at 04:49:34PM +0100, Matthieu Baerts wrote:
> Our MPTCP CI complained [1] -- and KBuild too -- that it was no longer
> possible to build the kernel without CONFIG_CGROUPS:
> 
>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_new':
>   kernel/bpf/task_iter.c:919:14: error: 'CSS_TASK_ITER_PROCS' undeclared (first use in this function)
>     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
>         |              ^~~~~~~~~~~~~~~~~~~
>   kernel/bpf/task_iter.c:919:14: note: each undeclared identifier is reported only once for each function it appears in
>   kernel/bpf/task_iter.c:919:36: error: 'CSS_TASK_ITER_THREADED' undeclared (first use in this function)
>     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
>         |                                    ^~~~~~~~~~~~~~~~~~~~~~
>   kernel/bpf/task_iter.c:927:60: error: invalid application of 'sizeof' to incomplete type 'struct css_task_iter'
>     927 |         kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter));
>         |                                                            ^~~~~~
>   kernel/bpf/task_iter.c:930:9: error: implicit declaration of function 'css_task_iter_start'; did you mean 'task_seq_start'? [-Werror=implicit-function-declaration]
>     930 |         css_task_iter_start(css, flags, kit->css_it);
>         |         ^~~~~~~~~~~~~~~~~~~
>         |         task_seq_start
>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_next':
>   kernel/bpf/task_iter.c:940:16: error: implicit declaration of function 'css_task_iter_next'; did you mean 'class_dev_iter_next'? [-Werror=implicit-function-declaration]
>     940 |         return css_task_iter_next(kit->css_it);
>         |                ^~~~~~~~~~~~~~~~~~
>         |                class_dev_iter_next
>   kernel/bpf/task_iter.c:940:16: error: returning 'int' from a function with return type 'struct task_struct *' makes pointer from integer without a cast [-Werror=int-conversion]
>     940 |         return css_task_iter_next(kit->css_it);
>         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_destroy':
>   kernel/bpf/task_iter.c:949:9: error: implicit declaration of function 'css_task_iter_end' [-Werror=implicit-function-declaration]
>     949 |         css_task_iter_end(kit->css_it);
>         |         ^~~~~~~~~~~~~~~~~
> 
> This patch simply surrounds with a #ifdef the new code requiring CGroups
> support. It seems enough for the compiler and this is similar to
> bpf_iter_css_{new,next,destroy}() functions where no other #ifdef have
> been added in kernel/bpf/helpers.c and in the selftests.
> 
> Fixes: 9c66dc94b62a ("bpf: Introduce css_task open-coded iterator kfuncs")
> Link: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/6665206927
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202310260528.aHWgVFqq-lkp@intel.com/
> Signed-off-by: Matthieu Baerts <matttbe@kernel.org>

Acked/Tested-by: Jiri Olsa <jolsa@kernel.org>

jirka

> ---
>  kernel/bpf/task_iter.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
> index 59e747938bdb..e0d313114a5b 100644
> --- a/kernel/bpf/task_iter.c
> +++ b/kernel/bpf/task_iter.c
> @@ -894,6 +894,8 @@ __bpf_kfunc void bpf_iter_task_vma_destroy(struct bpf_iter_task_vma *it)
>  
>  __diag_pop();
>  
> +#ifdef CONFIG_CGROUPS
> +
>  struct bpf_iter_css_task {
>  	__u64 __opaque[1];
>  } __attribute__((aligned(8)));
> @@ -952,6 +954,8 @@ __bpf_kfunc void bpf_iter_css_task_destroy(struct bpf_iter_css_task *it)
>  
>  __diag_pop();
>  
> +#endif /* CONFIG_CGROUPS */
> +
>  struct bpf_iter_task {
>  	__u64 __opaque[3];
>  } __attribute__((aligned(8)));
> 
> ---
> base-commit: f1c73396133cb3d913e2075298005644ee8dfade
> change-id: 20231031-bpf-compil-err-css-056f3db04860
> 
> Best regards,
> -- 
> Matthieu Baerts <matttbe@kernel.org>
>
Alexei Starovoitov Nov. 1, 2023, 3:54 a.m. UTC | #2
On Tue, Oct 31, 2023 at 10:05 AM Jiri Olsa <olsajiri@gmail.com> wrote:
>
> On Tue, Oct 31, 2023 at 04:49:34PM +0100, Matthieu Baerts wrote:
> > Our MPTCP CI complained [1] -- and KBuild too -- that it was no longer
> > possible to build the kernel without CONFIG_CGROUPS:
> >
> >   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_new':
> >   kernel/bpf/task_iter.c:919:14: error: 'CSS_TASK_ITER_PROCS' undeclared (first use in this function)
> >     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
> >         |              ^~~~~~~~~~~~~~~~~~~
> >   kernel/bpf/task_iter.c:919:14: note: each undeclared identifier is reported only once for each function it appears in
> >   kernel/bpf/task_iter.c:919:36: error: 'CSS_TASK_ITER_THREADED' undeclared (first use in this function)
> >     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
> >         |                                    ^~~~~~~~~~~~~~~~~~~~~~
> >   kernel/bpf/task_iter.c:927:60: error: invalid application of 'sizeof' to incomplete type 'struct css_task_iter'
> >     927 |         kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter));
> >         |                                                            ^~~~~~
> >   kernel/bpf/task_iter.c:930:9: error: implicit declaration of function 'css_task_iter_start'; did you mean 'task_seq_start'? [-Werror=implicit-function-declaration]
> >     930 |         css_task_iter_start(css, flags, kit->css_it);
> >         |         ^~~~~~~~~~~~~~~~~~~
> >         |         task_seq_start
> >   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_next':
> >   kernel/bpf/task_iter.c:940:16: error: implicit declaration of function 'css_task_iter_next'; did you mean 'class_dev_iter_next'? [-Werror=implicit-function-declaration]
> >     940 |         return css_task_iter_next(kit->css_it);
> >         |                ^~~~~~~~~~~~~~~~~~
> >         |                class_dev_iter_next
> >   kernel/bpf/task_iter.c:940:16: error: returning 'int' from a function with return type 'struct task_struct *' makes pointer from integer without a cast [-Werror=int-conversion]
> >     940 |         return css_task_iter_next(kit->css_it);
> >         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_destroy':
> >   kernel/bpf/task_iter.c:949:9: error: implicit declaration of function 'css_task_iter_end' [-Werror=implicit-function-declaration]
> >     949 |         css_task_iter_end(kit->css_it);
> >         |         ^~~~~~~~~~~~~~~~~
> >
> > This patch simply surrounds with a #ifdef the new code requiring CGroups
> > support. It seems enough for the compiler and this is similar to
> > bpf_iter_css_{new,next,destroy}() functions where no other #ifdef have
> > been added in kernel/bpf/helpers.c and in the selftests.
> >
> > Fixes: 9c66dc94b62a ("bpf: Introduce css_task open-coded iterator kfuncs")
> > Link: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/6665206927
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202310260528.aHWgVFqq-lkp@intel.com/
> > Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
>
> Acked/Tested-by: Jiri Olsa <jolsa@kernel.org>

I believe this patch has the same issue as Arnd's patch:
https://lore.kernel.org/all/CAADnVQL-zoFPPOVu3nM981gKxRu7Q3G3LTRsKstJEeahpoR1RQ@mail.gmail.com/

I'd like to merge the fix asap. Please make it a complete fix.
Jiri Olsa Nov. 1, 2023, 7:25 a.m. UTC | #3
On Tue, Oct 31, 2023 at 08:54:56PM -0700, Alexei Starovoitov wrote:
> On Tue, Oct 31, 2023 at 10:05 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >
> > On Tue, Oct 31, 2023 at 04:49:34PM +0100, Matthieu Baerts wrote:
> > > Our MPTCP CI complained [1] -- and KBuild too -- that it was no longer
> > > possible to build the kernel without CONFIG_CGROUPS:
> > >
> > >   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_new':
> > >   kernel/bpf/task_iter.c:919:14: error: 'CSS_TASK_ITER_PROCS' undeclared (first use in this function)
> > >     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
> > >         |              ^~~~~~~~~~~~~~~~~~~
> > >   kernel/bpf/task_iter.c:919:14: note: each undeclared identifier is reported only once for each function it appears in
> > >   kernel/bpf/task_iter.c:919:36: error: 'CSS_TASK_ITER_THREADED' undeclared (first use in this function)
> > >     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
> > >         |                                    ^~~~~~~~~~~~~~~~~~~~~~
> > >   kernel/bpf/task_iter.c:927:60: error: invalid application of 'sizeof' to incomplete type 'struct css_task_iter'
> > >     927 |         kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter));
> > >         |                                                            ^~~~~~
> > >   kernel/bpf/task_iter.c:930:9: error: implicit declaration of function 'css_task_iter_start'; did you mean 'task_seq_start'? [-Werror=implicit-function-declaration]
> > >     930 |         css_task_iter_start(css, flags, kit->css_it);
> > >         |         ^~~~~~~~~~~~~~~~~~~
> > >         |         task_seq_start
> > >   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_next':
> > >   kernel/bpf/task_iter.c:940:16: error: implicit declaration of function 'css_task_iter_next'; did you mean 'class_dev_iter_next'? [-Werror=implicit-function-declaration]
> > >     940 |         return css_task_iter_next(kit->css_it);
> > >         |                ^~~~~~~~~~~~~~~~~~
> > >         |                class_dev_iter_next
> > >   kernel/bpf/task_iter.c:940:16: error: returning 'int' from a function with return type 'struct task_struct *' makes pointer from integer without a cast [-Werror=int-conversion]
> > >     940 |         return css_task_iter_next(kit->css_it);
> > >         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_destroy':
> > >   kernel/bpf/task_iter.c:949:9: error: implicit declaration of function 'css_task_iter_end' [-Werror=implicit-function-declaration]
> > >     949 |         css_task_iter_end(kit->css_it);
> > >         |         ^~~~~~~~~~~~~~~~~
> > >
> > > This patch simply surrounds with a #ifdef the new code requiring CGroups
> > > support. It seems enough for the compiler and this is similar to
> > > bpf_iter_css_{new,next,destroy}() functions where no other #ifdef have
> > > been added in kernel/bpf/helpers.c and in the selftests.
> > >
> > > Fixes: 9c66dc94b62a ("bpf: Introduce css_task open-coded iterator kfuncs")
> > > Link: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/6665206927
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202310260528.aHWgVFqq-lkp@intel.com/
> > > Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
> >
> > Acked/Tested-by: Jiri Olsa <jolsa@kernel.org>
> 
> I believe this patch has the same issue as Arnd's patch:
> https://lore.kernel.org/all/CAADnVQL-zoFPPOVu3nM981gKxRu7Q3G3LTRsKstJEeahpoR1RQ@mail.gmail.com/
> 
> I'd like to merge the fix asap. Please make it a complete fix.

ugh, it won't fail the build, it just warns.. I think we should
fail the build in that case, I'll check

jirka
Matthieu Baerts (NGI0) Nov. 1, 2023, 8:25 a.m. UTC | #4
Hi Jirka, Alexei,

On 01/11/2023 08:25, Jiri Olsa wrote:
> On Tue, Oct 31, 2023 at 08:54:56PM -0700, Alexei Starovoitov wrote:
>> On Tue, Oct 31, 2023 at 10:05 AM Jiri Olsa <olsajiri@gmail.com> wrote:
>>>
>>> On Tue, Oct 31, 2023 at 04:49:34PM +0100, Matthieu Baerts wrote:
>>>> Our MPTCP CI complained [1] -- and KBuild too -- that it was no longer
>>>> possible to build the kernel without CONFIG_CGROUPS:
>>>>
>>>>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_new':
>>>>   kernel/bpf/task_iter.c:919:14: error: 'CSS_TASK_ITER_PROCS' undeclared (first use in this function)
>>>>     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
>>>>         |              ^~~~~~~~~~~~~~~~~~~
>>>>   kernel/bpf/task_iter.c:919:14: note: each undeclared identifier is reported only once for each function it appears in
>>>>   kernel/bpf/task_iter.c:919:36: error: 'CSS_TASK_ITER_THREADED' undeclared (first use in this function)
>>>>     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
>>>>         |                                    ^~~~~~~~~~~~~~~~~~~~~~
>>>>   kernel/bpf/task_iter.c:927:60: error: invalid application of 'sizeof' to incomplete type 'struct css_task_iter'
>>>>     927 |         kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter));
>>>>         |                                                            ^~~~~~
>>>>   kernel/bpf/task_iter.c:930:9: error: implicit declaration of function 'css_task_iter_start'; did you mean 'task_seq_start'? [-Werror=implicit-function-declaration]
>>>>     930 |         css_task_iter_start(css, flags, kit->css_it);
>>>>         |         ^~~~~~~~~~~~~~~~~~~
>>>>         |         task_seq_start
>>>>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_next':
>>>>   kernel/bpf/task_iter.c:940:16: error: implicit declaration of function 'css_task_iter_next'; did you mean 'class_dev_iter_next'? [-Werror=implicit-function-declaration]
>>>>     940 |         return css_task_iter_next(kit->css_it);
>>>>         |                ^~~~~~~~~~~~~~~~~~
>>>>         |                class_dev_iter_next
>>>>   kernel/bpf/task_iter.c:940:16: error: returning 'int' from a function with return type 'struct task_struct *' makes pointer from integer without a cast [-Werror=int-conversion]
>>>>     940 |         return css_task_iter_next(kit->css_it);
>>>>         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_destroy':
>>>>   kernel/bpf/task_iter.c:949:9: error: implicit declaration of function 'css_task_iter_end' [-Werror=implicit-function-declaration]
>>>>     949 |         css_task_iter_end(kit->css_it);
>>>>         |         ^~~~~~~~~~~~~~~~~
>>>>
>>>> This patch simply surrounds with a #ifdef the new code requiring CGroups
>>>> support. It seems enough for the compiler and this is similar to
>>>> bpf_iter_css_{new,next,destroy}() functions where no other #ifdef have
>>>> been added in kernel/bpf/helpers.c and in the selftests.
>>>>
>>>> Fixes: 9c66dc94b62a ("bpf: Introduce css_task open-coded iterator kfuncs")
>>>> Link: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/6665206927
>>>> Reported-by: kernel test robot <lkp@intel.com>
>>>> Closes: https://lore.kernel.org/oe-kbuild-all/202310260528.aHWgVFqq-lkp@intel.com/
>>>> Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
>>>
>>> Acked/Tested-by: Jiri Olsa <jolsa@kernel.org>
>>
>> I believe this patch has the same issue as Arnd's patch:
>> https://lore.kernel.org/all/CAADnVQL-zoFPPOVu3nM981gKxRu7Q3G3LTRsKstJEeahpoR1RQ@mail.gmail.com/

@Alexei: Arf, sorry, I didn't find this patch when searching for
"9c66dc94b62a" on lore. I don't know why I didn't search for the commit
title as usual...

>> I'd like to merge the fix asap. Please make it a complete fix.
> 
> ugh, it won't fail the build, it just warns.. I think we should
> fail the build in that case, I'll check

@Jirka: Thank you for checking that! Please tell me if you want me to
send a v2 or if you prefer to do that. I don't mind if you prefer to
send your own patches, as long as there is a fix for that at the end :)

Note that if a warning is emitted for these new bpf_iter_css_task_*()
functions, I guess you will have the same issue with bpf_iter_css_*()
and probably others as mentioned in my commit message.

Cheers,
Matt
Jiri Olsa Nov. 1, 2023, 12:53 p.m. UTC | #5
On Wed, Nov 01, 2023 at 09:25:34AM +0100, Matthieu Baerts wrote:
> Hi Jirka, Alexei,
> 
> On 01/11/2023 08:25, Jiri Olsa wrote:
> > On Tue, Oct 31, 2023 at 08:54:56PM -0700, Alexei Starovoitov wrote:
> >> On Tue, Oct 31, 2023 at 10:05 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >>>
> >>> On Tue, Oct 31, 2023 at 04:49:34PM +0100, Matthieu Baerts wrote:
> >>>> Our MPTCP CI complained [1] -- and KBuild too -- that it was no longer
> >>>> possible to build the kernel without CONFIG_CGROUPS:
> >>>>
> >>>>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_new':
> >>>>   kernel/bpf/task_iter.c:919:14: error: 'CSS_TASK_ITER_PROCS' undeclared (first use in this function)
> >>>>     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
> >>>>         |              ^~~~~~~~~~~~~~~~~~~
> >>>>   kernel/bpf/task_iter.c:919:14: note: each undeclared identifier is reported only once for each function it appears in
> >>>>   kernel/bpf/task_iter.c:919:36: error: 'CSS_TASK_ITER_THREADED' undeclared (first use in this function)
> >>>>     919 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
> >>>>         |                                    ^~~~~~~~~~~~~~~~~~~~~~
> >>>>   kernel/bpf/task_iter.c:927:60: error: invalid application of 'sizeof' to incomplete type 'struct css_task_iter'
> >>>>     927 |         kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter));
> >>>>         |                                                            ^~~~~~
> >>>>   kernel/bpf/task_iter.c:930:9: error: implicit declaration of function 'css_task_iter_start'; did you mean 'task_seq_start'? [-Werror=implicit-function-declaration]
> >>>>     930 |         css_task_iter_start(css, flags, kit->css_it);
> >>>>         |         ^~~~~~~~~~~~~~~~~~~
> >>>>         |         task_seq_start
> >>>>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_next':
> >>>>   kernel/bpf/task_iter.c:940:16: error: implicit declaration of function 'css_task_iter_next'; did you mean 'class_dev_iter_next'? [-Werror=implicit-function-declaration]
> >>>>     940 |         return css_task_iter_next(kit->css_it);
> >>>>         |                ^~~~~~~~~~~~~~~~~~
> >>>>         |                class_dev_iter_next
> >>>>   kernel/bpf/task_iter.c:940:16: error: returning 'int' from a function with return type 'struct task_struct *' makes pointer from integer without a cast [-Werror=int-conversion]
> >>>>     940 |         return css_task_iter_next(kit->css_it);
> >>>>         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>>>   kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_destroy':
> >>>>   kernel/bpf/task_iter.c:949:9: error: implicit declaration of function 'css_task_iter_end' [-Werror=implicit-function-declaration]
> >>>>     949 |         css_task_iter_end(kit->css_it);
> >>>>         |         ^~~~~~~~~~~~~~~~~
> >>>>
> >>>> This patch simply surrounds with a #ifdef the new code requiring CGroups
> >>>> support. It seems enough for the compiler and this is similar to
> >>>> bpf_iter_css_{new,next,destroy}() functions where no other #ifdef have
> >>>> been added in kernel/bpf/helpers.c and in the selftests.
> >>>>
> >>>> Fixes: 9c66dc94b62a ("bpf: Introduce css_task open-coded iterator kfuncs")
> >>>> Link: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/6665206927
> >>>> Reported-by: kernel test robot <lkp@intel.com>
> >>>> Closes: https://lore.kernel.org/oe-kbuild-all/202310260528.aHWgVFqq-lkp@intel.com/
> >>>> Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
> >>>
> >>> Acked/Tested-by: Jiri Olsa <jolsa@kernel.org>
> >>
> >> I believe this patch has the same issue as Arnd's patch:
> >> https://lore.kernel.org/all/CAADnVQL-zoFPPOVu3nM981gKxRu7Q3G3LTRsKstJEeahpoR1RQ@mail.gmail.com/
> 
> @Alexei: Arf, sorry, I didn't find this patch when searching for
> "9c66dc94b62a" on lore. I don't know why I didn't search for the commit
> title as usual...
> 
> >> I'd like to merge the fix asap. Please make it a complete fix.
> > 
> > ugh, it won't fail the build, it just warns.. I think we should
> > fail the build in that case, I'll check
> 
> @Jirka: Thank you for checking that! Please tell me if you want me to
> send a v2 or if you prefer to do that. I don't mind if you prefer to
> send your own patches, as long as there is a fix for that at the end :)
> 
> Note that if a warning is emitted for these new bpf_iter_css_task_*()
> functions, I guess you will have the same issue with bpf_iter_css_*()
> and probably others as mentioned in my commit message.

Arnd,
are you planning to send new version for your patch [1] ?
we have a patch collision ;-)

I can send v2 if needed.. so far I'm checking the change below

jirka


[1] https://lore.kernel.org/all/CAADnVQL-zoFPPOVu3nM981gKxRu7Q3G3LTRsKstJEeahpoR1RQ@mail.gmail.com/
---
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index e46ac288a108..95449ea7cc1b 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2564,15 +2564,17 @@ BTF_ID_FLAGS(func, bpf_iter_num_destroy, KF_ITER_DESTROY)
 BTF_ID_FLAGS(func, bpf_iter_task_vma_new, KF_ITER_NEW | KF_RCU)
 BTF_ID_FLAGS(func, bpf_iter_task_vma_next, KF_ITER_NEXT | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_iter_task_vma_destroy, KF_ITER_DESTROY)
+#ifdef CONFIG_CGROUPS
 BTF_ID_FLAGS(func, bpf_iter_css_task_new, KF_ITER_NEW | KF_TRUSTED_ARGS)
 BTF_ID_FLAGS(func, bpf_iter_css_task_next, KF_ITER_NEXT | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_iter_css_task_destroy, KF_ITER_DESTROY)
-BTF_ID_FLAGS(func, bpf_iter_task_new, KF_ITER_NEW | KF_TRUSTED_ARGS | KF_RCU_PROTECTED)
-BTF_ID_FLAGS(func, bpf_iter_task_next, KF_ITER_NEXT | KF_RET_NULL)
-BTF_ID_FLAGS(func, bpf_iter_task_destroy, KF_ITER_DESTROY)
 BTF_ID_FLAGS(func, bpf_iter_css_new, KF_ITER_NEW | KF_TRUSTED_ARGS | KF_RCU_PROTECTED)
 BTF_ID_FLAGS(func, bpf_iter_css_next, KF_ITER_NEXT | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_iter_css_destroy, KF_ITER_DESTROY)
+#endif
+BTF_ID_FLAGS(func, bpf_iter_task_new, KF_ITER_NEW | KF_TRUSTED_ARGS | KF_RCU_PROTECTED)
+BTF_ID_FLAGS(func, bpf_iter_task_next, KF_ITER_NEXT | KF_RET_NULL)
+BTF_ID_FLAGS(func, bpf_iter_task_destroy, KF_ITER_DESTROY)
 BTF_ID_FLAGS(func, bpf_dynptr_adjust)
 BTF_ID_FLAGS(func, bpf_dynptr_is_null)
 BTF_ID_FLAGS(func, bpf_dynptr_is_rdonly)
diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
index 59e747938bdb..e0d313114a5b 100644
--- a/kernel/bpf/task_iter.c
+++ b/kernel/bpf/task_iter.c
@@ -894,6 +894,8 @@ __bpf_kfunc void bpf_iter_task_vma_destroy(struct bpf_iter_task_vma *it)
 
 __diag_pop();
 
+#ifdef CONFIG_CGROUPS
+
 struct bpf_iter_css_task {
 	__u64 __opaque[1];
 } __attribute__((aligned(8)));
@@ -952,6 +954,8 @@ __bpf_kfunc void bpf_iter_css_task_destroy(struct bpf_iter_css_task *it)
 
 __diag_pop();
 
+#endif /* CONFIG_CGROUPS */
+
 struct bpf_iter_task {
 	__u64 __opaque[3];
 } __attribute__((aligned(8)));
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index e42ce974b106..f2afb17a1534 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5421,7 +5421,9 @@ static bool in_rcu_cs(struct bpf_verifier_env *env)
 /* Once GCC supports btf_type_tag the following mechanism will be replaced with tag check */
 BTF_SET_START(rcu_protected_types)
 BTF_ID(struct, prog_test_ref_kfunc)
+#ifdef CONFIG_CGROUPS
 BTF_ID(struct, cgroup)
+#endif
 BTF_ID(struct, bpf_cpumask)
 BTF_ID(struct, task_struct)
 BTF_SET_END(rcu_protected_types)
@@ -10873,7 +10875,9 @@ BTF_ID(func, bpf_dynptr_clone)
 BTF_ID(func, bpf_percpu_obj_new_impl)
 BTF_ID(func, bpf_percpu_obj_drop_impl)
 BTF_ID(func, bpf_throw)
+#ifdef CONFIG_CGROUPS
 BTF_ID(func, bpf_iter_css_task_new)
+#endif
 BTF_SET_END(special_kfunc_set)
 
 BTF_ID_LIST(special_kfunc_list)
@@ -10899,7 +10903,11 @@ BTF_ID(func, bpf_dynptr_clone)
 BTF_ID(func, bpf_percpu_obj_new_impl)
 BTF_ID(func, bpf_percpu_obj_drop_impl)
 BTF_ID(func, bpf_throw)
+#ifdef CONFIG_CGROUPS
 BTF_ID(func, bpf_iter_css_task_new)
+#else
+BTF_ID_UNUSED
+#endif
 
 static bool is_kfunc_ret_null(struct bpf_kfunc_call_arg_meta *meta)
 {
diff mbox series

Patch

diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
index 59e747938bdb..e0d313114a5b 100644
--- a/kernel/bpf/task_iter.c
+++ b/kernel/bpf/task_iter.c
@@ -894,6 +894,8 @@  __bpf_kfunc void bpf_iter_task_vma_destroy(struct bpf_iter_task_vma *it)
 
 __diag_pop();
 
+#ifdef CONFIG_CGROUPS
+
 struct bpf_iter_css_task {
 	__u64 __opaque[1];
 } __attribute__((aligned(8)));
@@ -952,6 +954,8 @@  __bpf_kfunc void bpf_iter_css_task_destroy(struct bpf_iter_css_task *it)
 
 __diag_pop();
 
+#endif /* CONFIG_CGROUPS */
+
 struct bpf_iter_task {
 	__u64 __opaque[3];
 } __attribute__((aligned(8)));