lkml.org 
[lkml]   [2023]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH bpf-next] bpf: Disable -Wmissing-declarations for globally-linked kfuncs
From


On 8/16/23 8:06 AM, David Vernet wrote:
> We recently got an lkp warning about missing declarations, as in e.g.
> [0]. This warning is largely redundant with -Wmissing-prototypes, which
> we already disable for kfuncs that have global linkage and are meant to
> be exported in BTF, and called from BPF programs. Let's also disable
> -Wmissing-declarations for kfuncs. For what it's worth, I wasn't able to
> reproduce the warning even on W <= 3, so I can't actually be 100% sure
> this fixes the issue.
>
> [0]: https://lore.kernel.org/all/202308162115.Hn23vv3n-lkp@intel.com/

Okay, I just got a similar email to [0] which complains
bpf_obj_new_impl, ..., bpf_cast_to_kern_ctx
missing declarations.

In the email, the used compiler is
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0

Unfortunately, I did not have gcc-7 to verify this.
Also, what is the minimum gcc version kernel supports? 5.1?

>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202308162115.Hn23vv3n-lkp@intel.com/
> Signed-off-by: David Vernet <void@manifault.com>
> ---
> Documentation/bpf/kfuncs.rst | 4 +++-
> kernel/bpf/bpf_iter.c | 2 ++
> kernel/bpf/cpumask.c | 2 ++
> kernel/bpf/helpers.c | 2 ++
> kernel/bpf/map_iter.c | 2 ++
> kernel/cgroup/rstat.c | 2 ++
> kernel/trace/bpf_trace.c | 2 ++
> net/bpf/test_run.c | 2 ++
> net/core/filter.c | 4 ++++
> net/core/xdp.c | 2 ++
> net/ipv4/fou_bpf.c | 2 ++
> net/netfilter/nf_conntrack_bpf.c | 2 ++
> net/netfilter/nf_nat_bpf.c | 2 ++
> net/xfrm/xfrm_interface_bpf.c | 2 ++
> tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 2 ++
> 15 files changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst
> index 0d2647fb358d..62ce5a7b92b4 100644
> --- a/Documentation/bpf/kfuncs.rst
> +++ b/Documentation/bpf/kfuncs.rst
> @@ -36,10 +36,12 @@ prototype in a header for the wrapper kfunc.
>
> An example is given below::
>
> - /* Disables missing prototype warnings */
> + /* Disables missing prototypes and declarations warnings */
> __diag_push();
> __diag_ignore_all("-Wmissing-prototypes",
> "Global kfuncs as their definitions will be in BTF");
> + __diag_ignore_all("-Wmissing-declarations",
> + "Global kfuncs as their definitions will be in BTF");
>
> __bpf_kfunc struct task_struct *bpf_find_get_task_by_vpid(pid_t nr)
> {
> diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
> index 96856f130cbf..b8def6e4e5e8 100644
> --- a/kernel/bpf/bpf_iter.c
> +++ b/kernel/bpf/bpf_iter.c
> @@ -785,6 +785,8 @@ struct bpf_iter_num_kern {
> __diag_push();
> __diag_ignore_all("-Wmissing-prototypes",
> "Global functions as their definitions will be in vmlinux BTF");
> +__diag_ignore_all("-Wmissing-declarations",
> + "Global functions as their definitions will be in vmlinux BTF");
>
> __bpf_kfunc int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end)
> {
[...]

\
 
 \ /
  Last update: 2023-08-17 05:39    [W:0.059 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site