BPF List
 help / color / mirror / Atom feed
* [PATCH] bpf: hide cgroup functions for configs without cgroups
@ 2023-10-20 13:27 Arnd Bergmann
  2023-10-20 17:26 ` Alexei Starovoitov
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2023-10-20 13:27 UTC (permalink / raw)
  To: Yonghong Song, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Chuyi Zhou, Tejun Heo
  Cc: Arnd Bergmann, Martin KaFai Lau, Song Liu, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Oleg Nesterov,
	bpf, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

When cgroups are disabled, the newly added functions don't build:

kernel/bpf/task_iter.c: In function 'bpf_iter_css_task_new':
kernel/bpf/task_iter.c:917:14: error: 'CSS_TASK_ITER_PROCS' undeclared (first use in this function)
  917 |         case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
      |              ^~~~~~~~~~~~~~~~~~~
kernel/bpf/task_iter.c:925:60: error: invalid application of 'sizeof' to incomplete type 'struct css_task_iter'
  925 |         kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter));
      |                                                            ^~~~~~

Hide them in an #ifdef section.

Fixes: 9c66dc94b62ae ("bpf: Introduce css_task open-coded iterator kfuncs")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/bpf/task_iter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
index 654601dd6b493..15a184f4f954d 100644
--- a/kernel/bpf/task_iter.c
+++ b/kernel/bpf/task_iter.c
@@ -904,6 +904,7 @@ __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in vmlinux BTF");
 
+#ifdef CONFIG_CGROUPS
 __bpf_kfunc int bpf_iter_css_task_new(struct bpf_iter_css_task *it,
 		struct cgroup_subsys_state *css, unsigned int flags)
 {
@@ -947,6 +948,7 @@ __bpf_kfunc void bpf_iter_css_task_destroy(struct bpf_iter_css_task *it)
 	css_task_iter_end(kit->css_it);
 	bpf_mem_free(&bpf_global_ma, kit->css_it);
 }
+#endif
 
 __diag_pop();
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-21  3:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20 13:27 [PATCH] bpf: hide cgroup functions for configs without cgroups Arnd Bergmann
2023-10-20 17:26 ` Alexei Starovoitov
2023-10-20 20:06   ` Arnd Bergmann
2023-10-21  3:45     ` Chuyi Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox