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@xxxxxxxxx/
[...]
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202308162115.Hn23vv3n-lkp@xxxxxxxxx/
Signed-off-by: David Vernet <void@xxxxxxxxxxxxx>
---
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)
{