* [PATCH bpf-next v4 0/3] bpf: remove the cgroup -> bpf header dependecy
@ 2021-12-15 18:12 Jakub Kicinski
2021-12-15 18:12 ` [PATCH bpf-next v4 1/3] add includes masked by cgroup -> bpf dependency Jakub Kicinski
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Jakub Kicinski @ 2021-12-15 18:12 UTC (permalink / raw)
To: daniel, ast, andrii; +Cc: bpf, Jakub Kicinski
Changes to bpf.h tend to clog up our build systems. The netdev/bpf
build bot does incremental builds to save time (reusing the build
directory to only rebuild changed objects).
This is the rough breakdown of how many objects needs to be rebuilt
based on file touched:
kernel.h 40633
bpf.h 17881
bpf-cgroup.h 17875
skbuff.h 10696
bpf-netns.h 7604
netdevice.h 7452
filter.h 5003
tcp.h 4048
sock.h 4959
As the stats show touching bpf.h is _very_ expensive.
Bulk of the objects get rebuilt because MM includes cgroup headers.
Luckily bpf-cgroup.h does not fundamentally depend on bpf.h so we
can break that dependency and reduce the number of objects.
With the patches applied touching bpf.h causes 5019 objects to be rebuilt
(17881 / 5019 = 3.56x). That's pretty much down to filter.h plus noise.
v2:
Try to make the new headers wider in scope. Collapse bpf-link and
bpf-cgroup-types into one header, which may serve as "BPF kernel
API" header in the future if needed. Rename bpf-cgroup-storage.h
to bpf-inlines.h.
Add a fix for the s390 build issue.
v3: https://lore.kernel.org/all/20211215061916.715513-1-kuba@kernel.org/
Merge bpf-includes.h into bpf.h.
Remember to git format-patch after fixing build issues.
v4:
Change course - break off cgroup instead of breaking off bpf.
Jakub Kicinski (3):
add includes masked by cgroup -> bpf dependency
add missing bpf-cgroup.h includes
bpf: remove the cgroup -> bpf header dependecy
arch/s390/mm/hugetlbpage.c | 1 +
include/linux/bpf-cgroup-defs.h | 70 +++++++++++++++++++++++++++++++++
include/linux/bpf-cgroup.h | 57 +--------------------------
include/linux/cgroup-defs.h | 2 +-
kernel/bpf/helpers.c | 1 +
kernel/bpf/syscall.c | 1 +
kernel/bpf/verifier.c | 1 +
kernel/cgroup/cgroup.c | 1 +
kernel/trace/trace_kprobe.c | 1 +
kernel/trace/trace_uprobe.c | 1 +
net/ipv4/udp.c | 1 +
net/ipv6/udp.c | 1 +
net/socket.c | 1 +
security/device_cgroup.c | 1 +
14 files changed, 83 insertions(+), 57 deletions(-)
create mode 100644 include/linux/bpf-cgroup-defs.h
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH bpf-next v4 1/3] add includes masked by cgroup -> bpf dependency
2021-12-15 18:12 [PATCH bpf-next v4 0/3] bpf: remove the cgroup -> bpf header dependecy Jakub Kicinski
@ 2021-12-15 18:12 ` Jakub Kicinski
2021-12-15 18:12 ` [PATCH bpf-next v4 2/3] add missing bpf-cgroup.h includes Jakub Kicinski
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2021-12-15 18:12 UTC (permalink / raw)
To: daniel, ast, andrii
Cc: bpf, Jakub Kicinski, hca, gor, borntraeger, agordeev, akpm,
peterx, linux-s390
cgroup pulls in BPF which pulls in a lot of includes.
We're about to break that chain so fix those who were
depending on it.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: hca@linux.ibm.com
CC: gor@linux.ibm.com
CC: borntraeger@linux.ibm.com
CC: agordeev@linux.ibm.com
CC: akpm@linux-foundation.org
CC: peterx@redhat.com
CC: linux-s390@vger.kernel.org
---
arch/s390/mm/hugetlbpage.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
index da36d13ffc16..082793d497ec 100644
--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -9,6 +9,7 @@
#define KMSG_COMPONENT "hugetlb"
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+#include <asm/pgalloc.h>
#include <linux/mm.h>
#include <linux/hugetlb.h>
#include <linux/mman.h>
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH bpf-next v4 2/3] add missing bpf-cgroup.h includes
2021-12-15 18:12 [PATCH bpf-next v4 0/3] bpf: remove the cgroup -> bpf header dependecy Jakub Kicinski
2021-12-15 18:12 ` [PATCH bpf-next v4 1/3] add includes masked by cgroup -> bpf dependency Jakub Kicinski
@ 2021-12-15 18:12 ` Jakub Kicinski
2021-12-15 18:28 ` Tejun Heo
2021-12-15 18:12 ` Jakub Kicinski
2021-12-15 19:47 ` [PATCH bpf-next v4 0/3] " Alexei Starovoitov
3 siblings, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2021-12-15 18:12 UTC (permalink / raw)
To: daniel, ast, andrii
Cc: bpf, Jakub Kicinski, kafai, songliubraving, yhs, john.fastabend,
kpsingh, tj, lizefan.x, hannes, rostedt, mingo, yoshfuji, dsahern,
jmorris, serge, cgroups, linux-security-module
We're about to break the cgroup-defs.h -> bpf-cgroup.h dependency,
make sure those who actually need more than the definition of
struct cgroup_bpf include bpf-cgroup.h explicitly.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: ast@kernel.org
CC: daniel@iogearbox.net
CC: andrii@kernel.org
CC: kafai@fb.com
CC: songliubraving@fb.com
CC: yhs@fb.com
CC: john.fastabend@gmail.com
CC: kpsingh@kernel.org
CC: tj@kernel.org
CC: lizefan.x@bytedance.com
CC: hannes@cmpxchg.org
CC: rostedt@goodmis.org
CC: mingo@redhat.com
CC: yoshfuji@linux-ipv6.org
CC: dsahern@kernel.org
CC: jmorris@namei.org
CC: serge@hallyn.com
CC: bpf@vger.kernel.org
CC: cgroups@vger.kernel.org
CC: linux-security-module@vger.kernel.org
---
kernel/bpf/helpers.c | 1 +
kernel/bpf/syscall.c | 1 +
kernel/bpf/verifier.c | 1 +
kernel/cgroup/cgroup.c | 1 +
kernel/trace/trace_kprobe.c | 1 +
kernel/trace/trace_uprobe.c | 1 +
net/ipv4/udp.c | 1 +
net/ipv6/udp.c | 1 +
net/socket.c | 1 +
security/device_cgroup.c | 1 +
10 files changed, 10 insertions(+)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 8babae03d30a..34d6f91dec1c 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2,6 +2,7 @@
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
*/
#include <linux/bpf.h>
+#include <linux/bpf-cgroup.h>
#include <linux/rcupdate.h>
#include <linux/random.h>
#include <linux/smp.h>
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index ddd81d543203..da07bdf71697 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2,6 +2,7 @@
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
*/
#include <linux/bpf.h>
+#include <linux/bpf-cgroup.h>
#include <linux/bpf_trace.h>
#include <linux/bpf_lirc.h>
#include <linux/bpf_verifier.h>
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index d74e8a99412e..f0604796132f 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4,6 +4,7 @@
* Copyright (c) 2018 Covalent IO, Inc. http://covalent.io
*/
#include <uapi/linux/btf.h>
+#include <linux/bpf-cgroup.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/slab.h>
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 919194de39c8..cd4c23f7e3df 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -30,6 +30,7 @@
#include "cgroup-internal.h"
+#include <linux/bpf-cgroup.h>
#include <linux/cred.h>
#include <linux/errno.h>
#include <linux/init_task.h>
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 33272a7b6912..4e1257f50aa3 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -7,6 +7,7 @@
*/
#define pr_fmt(fmt) "trace_kprobe: " fmt
+#include <linux/bpf-cgroup.h>
#include <linux/security.h>
#include <linux/module.h>
#include <linux/uaccess.h>
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index f5f0039d31e5..4f35514a48f3 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -7,6 +7,7 @@
*/
#define pr_fmt(fmt) "trace_uprobe: " fmt
+#include <linux/bpf-cgroup.h>
#include <linux/security.h>
#include <linux/ctype.h>
#include <linux/module.h>
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 69d30053fed9..99536127650b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -74,6 +74,7 @@
#define pr_fmt(fmt) "UDP: " fmt
+#include <linux/bpf-cgroup.h>
#include <linux/uaccess.h>
#include <asm/ioctls.h>
#include <linux/memblock.h>
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 6a0e569f0bb8..ba8986d12413 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -17,6 +17,7 @@
* YOSHIFUJI Hideaki @USAGI: convert /proc/net/udp6 to seq_file.
*/
+#include <linux/bpf-cgroup.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/socket.h>
diff --git a/net/socket.c b/net/socket.c
index 7f64a6eccf63..721a5a1b1106 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -52,6 +52,7 @@
* Based upon Swansea University Computer Society NET3.039
*/
+#include <linux/bpf-cgroup.h>
#include <linux/ethtool.h>
#include <linux/mm.h>
#include <linux/socket.h>
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 04375df52fc9..842889f3dcb7 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -5,6 +5,7 @@
* Copyright 2007 IBM Corp
*/
+#include <linux/bpf-cgroup.h>
#include <linux/device_cgroup.h>
#include <linux/cgroup.h>
#include <linux/ctype.h>
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH bpf-next v4 3/3] bpf: remove the cgroup -> bpf header dependecy
@ 2021-12-15 18:12 ` Jakub Kicinski
0 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2021-12-15 18:12 UTC (permalink / raw)
To: daniel, ast, andrii
Cc: bpf, Jakub Kicinski, kafai, songliubraving, yhs, john.fastabend,
kpsingh, tj, lizefan.x, hannes, cgroups
Remove the dependency from cgroup-defs.h to bpf-cgroup.h and bpf.h.
This reduces the incremental build size of x86 allmodconfig after
bpf.h was touched from ~17k objects rebuilt to ~5k objects.
bpf.h is 2.2kLoC and is modified relatively often.
We need a new header with just the definition of struct cgroup_bpf
and enum cgroup_bpf_attach_type, this is akin to cgroup-defs.h.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: ast@kernel.org
CC: daniel@iogearbox.net
CC: andrii@kernel.org
CC: kafai@fb.com
CC: songliubraving@fb.com
CC: yhs@fb.com
CC: john.fastabend@gmail.com
CC: kpsingh@kernel.org
CC: tj@kernel.org
CC: lizefan.x@bytedance.com
CC: hannes@cmpxchg.org
CC: bpf@vger.kernel.org
CC: cgroups@vger.kernel.org
---
include/linux/bpf-cgroup-defs.h | 70 +++++++++++++++++++++++++++++++++
include/linux/bpf-cgroup.h | 57 +--------------------------
include/linux/cgroup-defs.h | 2 +-
3 files changed, 72 insertions(+), 57 deletions(-)
create mode 100644 include/linux/bpf-cgroup-defs.h
diff --git a/include/linux/bpf-cgroup-defs.h b/include/linux/bpf-cgroup-defs.h
new file mode 100644
index 000000000000..695d1224a71b
--- /dev/null
+++ b/include/linux/bpf-cgroup-defs.h
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _BPF_CGROUP_DEFS_H
+#define _BPF_CGROUP_DEFS_H
+
+#ifdef CONFIG_CGROUP_BPF
+
+#include <linux/list.h>
+#include <linux/percpu-refcount.h>
+#include <linux/workqueue.h>
+
+struct bpf_prog_array;
+
+enum cgroup_bpf_attach_type {
+ CGROUP_BPF_ATTACH_TYPE_INVALID = -1,
+ CGROUP_INET_INGRESS = 0,
+ CGROUP_INET_EGRESS,
+ CGROUP_INET_SOCK_CREATE,
+ CGROUP_SOCK_OPS,
+ CGROUP_DEVICE,
+ CGROUP_INET4_BIND,
+ CGROUP_INET6_BIND,
+ CGROUP_INET4_CONNECT,
+ CGROUP_INET6_CONNECT,
+ CGROUP_INET4_POST_BIND,
+ CGROUP_INET6_POST_BIND,
+ CGROUP_UDP4_SENDMSG,
+ CGROUP_UDP6_SENDMSG,
+ CGROUP_SYSCTL,
+ CGROUP_UDP4_RECVMSG,
+ CGROUP_UDP6_RECVMSG,
+ CGROUP_GETSOCKOPT,
+ CGROUP_SETSOCKOPT,
+ CGROUP_INET4_GETPEERNAME,
+ CGROUP_INET6_GETPEERNAME,
+ CGROUP_INET4_GETSOCKNAME,
+ CGROUP_INET6_GETSOCKNAME,
+ CGROUP_INET_SOCK_RELEASE,
+ MAX_CGROUP_BPF_ATTACH_TYPE
+};
+
+struct cgroup_bpf {
+ /* array of effective progs in this cgroup */
+ struct bpf_prog_array __rcu *effective[MAX_CGROUP_BPF_ATTACH_TYPE];
+
+ /* attached progs to this cgroup and attach flags
+ * when flags == 0 or BPF_F_ALLOW_OVERRIDE the progs list will
+ * have either zero or one element
+ * when BPF_F_ALLOW_MULTI the list can have up to BPF_CGROUP_MAX_PROGS
+ */
+ struct list_head progs[MAX_CGROUP_BPF_ATTACH_TYPE];
+ u32 flags[MAX_CGROUP_BPF_ATTACH_TYPE];
+
+ /* list of cgroup shared storages */
+ struct list_head storages;
+
+ /* temp storage for effective prog array used by prog_attach/detach */
+ struct bpf_prog_array *inactive;
+
+ /* reference counter used to detach bpf programs after cgroup removal */
+ struct percpu_ref refcnt;
+
+ /* cgroup_bpf is released using a work queue */
+ struct work_struct release_work;
+};
+
+#else /* CONFIG_CGROUP_BPF */
+struct cgroup_bpf {};
+#endif /* CONFIG_CGROUP_BPF */
+
+#endif
diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index 11820a430d6c..b525d8cdc25b 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -3,10 +3,10 @@
#define _BPF_CGROUP_H
#include <linux/bpf.h>
+#include <linux/bpf-cgroup-defs.h>
#include <linux/errno.h>
#include <linux/jump_label.h>
#include <linux/percpu.h>
-#include <linux/percpu-refcount.h>
#include <linux/rbtree.h>
#include <uapi/linux/bpf.h>
@@ -23,33 +23,6 @@ struct ctl_table_header;
struct task_struct;
#ifdef CONFIG_CGROUP_BPF
-enum cgroup_bpf_attach_type {
- CGROUP_BPF_ATTACH_TYPE_INVALID = -1,
- CGROUP_INET_INGRESS = 0,
- CGROUP_INET_EGRESS,
- CGROUP_INET_SOCK_CREATE,
- CGROUP_SOCK_OPS,
- CGROUP_DEVICE,
- CGROUP_INET4_BIND,
- CGROUP_INET6_BIND,
- CGROUP_INET4_CONNECT,
- CGROUP_INET6_CONNECT,
- CGROUP_INET4_POST_BIND,
- CGROUP_INET6_POST_BIND,
- CGROUP_UDP4_SENDMSG,
- CGROUP_UDP6_SENDMSG,
- CGROUP_SYSCTL,
- CGROUP_UDP4_RECVMSG,
- CGROUP_UDP6_RECVMSG,
- CGROUP_GETSOCKOPT,
- CGROUP_SETSOCKOPT,
- CGROUP_INET4_GETPEERNAME,
- CGROUP_INET6_GETPEERNAME,
- CGROUP_INET4_GETSOCKNAME,
- CGROUP_INET6_GETSOCKNAME,
- CGROUP_INET_SOCK_RELEASE,
- MAX_CGROUP_BPF_ATTACH_TYPE
-};
#define CGROUP_ATYPE(type) \
case BPF_##type: return type
@@ -127,33 +100,6 @@ struct bpf_prog_list {
struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE];
};
-struct bpf_prog_array;
-
-struct cgroup_bpf {
- /* array of effective progs in this cgroup */
- struct bpf_prog_array __rcu *effective[MAX_CGROUP_BPF_ATTACH_TYPE];
-
- /* attached progs to this cgroup and attach flags
- * when flags == 0 or BPF_F_ALLOW_OVERRIDE the progs list will
- * have either zero or one element
- * when BPF_F_ALLOW_MULTI the list can have up to BPF_CGROUP_MAX_PROGS
- */
- struct list_head progs[MAX_CGROUP_BPF_ATTACH_TYPE];
- u32 flags[MAX_CGROUP_BPF_ATTACH_TYPE];
-
- /* list of cgroup shared storages */
- struct list_head storages;
-
- /* temp storage for effective prog array used by prog_attach/detach */
- struct bpf_prog_array *inactive;
-
- /* reference counter used to detach bpf programs after cgroup removal */
- struct percpu_ref refcnt;
-
- /* cgroup_bpf is released using a work queue */
- struct work_struct release_work;
-};
-
int cgroup_bpf_inherit(struct cgroup *cgrp);
void cgroup_bpf_offline(struct cgroup *cgrp);
@@ -451,7 +397,6 @@ int cgroup_bpf_prog_query(const union bpf_attr *attr,
union bpf_attr __user *uattr);
#else
-struct cgroup_bpf {};
static inline int cgroup_bpf_inherit(struct cgroup *cgrp) { return 0; }
static inline void cgroup_bpf_offline(struct cgroup *cgrp) {}
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index db2e147e069f..411684c80cf3 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -19,7 +19,7 @@
#include <linux/percpu-rwsem.h>
#include <linux/u64_stats_sync.h>
#include <linux/workqueue.h>
-#include <linux/bpf-cgroup.h>
+#include <linux/bpf-cgroup-defs.h>
#include <linux/psi_types.h>
#ifdef CONFIG_CGROUPS
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH bpf-next v4 3/3] bpf: remove the cgroup -> bpf header dependecy
@ 2021-12-15 18:12 ` Jakub Kicinski
0 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2021-12-15 18:12 UTC (permalink / raw)
To: daniel-FeC+5ew28dpmcu3hnIyYJQ, ast-DgEjT+Ai2ygdnm+yROfE0A,
andrii-DgEjT+Ai2ygdnm+yROfE0A
Cc: bpf-u79uwXL29TY76Z2rM5mHXA, Jakub Kicinski, kafai-b10kYP2dOMg,
songliubraving-b10kYP2dOMg, yhs-b10kYP2dOMg,
john.fastabend-Re5JQEeQqe8AvxtiuMwx3w,
kpsingh-DgEjT+Ai2ygdnm+yROfE0A, tj-DgEjT+Ai2ygdnm+yROfE0A,
lizefan.x-EC8Uxl6Npydl57MIdRCFDg, hannes-druUgvl0LCNAfugRpC6u6w,
cgroups-u79uwXL29TY76Z2rM5mHXA
Remove the dependency from cgroup-defs.h to bpf-cgroup.h and bpf.h.
This reduces the incremental build size of x86 allmodconfig after
bpf.h was touched from ~17k objects rebuilt to ~5k objects.
bpf.h is 2.2kLoC and is modified relatively often.
We need a new header with just the definition of struct cgroup_bpf
and enum cgroup_bpf_attach_type, this is akin to cgroup-defs.h.
Signed-off-by: Jakub Kicinski <kuba-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
CC: ast-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
CC: daniel-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org
CC: andrii-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
CC: kafai-b10kYP2dOMg@public.gmane.org
CC: songliubraving-b10kYP2dOMg@public.gmane.org
CC: yhs-b10kYP2dOMg@public.gmane.org
CC: john.fastabend-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
CC: kpsingh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
CC: tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
CC: lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org
CC: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org
CC: bpf-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
CC: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
include/linux/bpf-cgroup-defs.h | 70 +++++++++++++++++++++++++++++++++
include/linux/bpf-cgroup.h | 57 +--------------------------
include/linux/cgroup-defs.h | 2 +-
3 files changed, 72 insertions(+), 57 deletions(-)
create mode 100644 include/linux/bpf-cgroup-defs.h
diff --git a/include/linux/bpf-cgroup-defs.h b/include/linux/bpf-cgroup-defs.h
new file mode 100644
index 000000000000..695d1224a71b
--- /dev/null
+++ b/include/linux/bpf-cgroup-defs.h
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _BPF_CGROUP_DEFS_H
+#define _BPF_CGROUP_DEFS_H
+
+#ifdef CONFIG_CGROUP_BPF
+
+#include <linux/list.h>
+#include <linux/percpu-refcount.h>
+#include <linux/workqueue.h>
+
+struct bpf_prog_array;
+
+enum cgroup_bpf_attach_type {
+ CGROUP_BPF_ATTACH_TYPE_INVALID = -1,
+ CGROUP_INET_INGRESS = 0,
+ CGROUP_INET_EGRESS,
+ CGROUP_INET_SOCK_CREATE,
+ CGROUP_SOCK_OPS,
+ CGROUP_DEVICE,
+ CGROUP_INET4_BIND,
+ CGROUP_INET6_BIND,
+ CGROUP_INET4_CONNECT,
+ CGROUP_INET6_CONNECT,
+ CGROUP_INET4_POST_BIND,
+ CGROUP_INET6_POST_BIND,
+ CGROUP_UDP4_SENDMSG,
+ CGROUP_UDP6_SENDMSG,
+ CGROUP_SYSCTL,
+ CGROUP_UDP4_RECVMSG,
+ CGROUP_UDP6_RECVMSG,
+ CGROUP_GETSOCKOPT,
+ CGROUP_SETSOCKOPT,
+ CGROUP_INET4_GETPEERNAME,
+ CGROUP_INET6_GETPEERNAME,
+ CGROUP_INET4_GETSOCKNAME,
+ CGROUP_INET6_GETSOCKNAME,
+ CGROUP_INET_SOCK_RELEASE,
+ MAX_CGROUP_BPF_ATTACH_TYPE
+};
+
+struct cgroup_bpf {
+ /* array of effective progs in this cgroup */
+ struct bpf_prog_array __rcu *effective[MAX_CGROUP_BPF_ATTACH_TYPE];
+
+ /* attached progs to this cgroup and attach flags
+ * when flags == 0 or BPF_F_ALLOW_OVERRIDE the progs list will
+ * have either zero or one element
+ * when BPF_F_ALLOW_MULTI the list can have up to BPF_CGROUP_MAX_PROGS
+ */
+ struct list_head progs[MAX_CGROUP_BPF_ATTACH_TYPE];
+ u32 flags[MAX_CGROUP_BPF_ATTACH_TYPE];
+
+ /* list of cgroup shared storages */
+ struct list_head storages;
+
+ /* temp storage for effective prog array used by prog_attach/detach */
+ struct bpf_prog_array *inactive;
+
+ /* reference counter used to detach bpf programs after cgroup removal */
+ struct percpu_ref refcnt;
+
+ /* cgroup_bpf is released using a work queue */
+ struct work_struct release_work;
+};
+
+#else /* CONFIG_CGROUP_BPF */
+struct cgroup_bpf {};
+#endif /* CONFIG_CGROUP_BPF */
+
+#endif
diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index 11820a430d6c..b525d8cdc25b 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -3,10 +3,10 @@
#define _BPF_CGROUP_H
#include <linux/bpf.h>
+#include <linux/bpf-cgroup-defs.h>
#include <linux/errno.h>
#include <linux/jump_label.h>
#include <linux/percpu.h>
-#include <linux/percpu-refcount.h>
#include <linux/rbtree.h>
#include <uapi/linux/bpf.h>
@@ -23,33 +23,6 @@ struct ctl_table_header;
struct task_struct;
#ifdef CONFIG_CGROUP_BPF
-enum cgroup_bpf_attach_type {
- CGROUP_BPF_ATTACH_TYPE_INVALID = -1,
- CGROUP_INET_INGRESS = 0,
- CGROUP_INET_EGRESS,
- CGROUP_INET_SOCK_CREATE,
- CGROUP_SOCK_OPS,
- CGROUP_DEVICE,
- CGROUP_INET4_BIND,
- CGROUP_INET6_BIND,
- CGROUP_INET4_CONNECT,
- CGROUP_INET6_CONNECT,
- CGROUP_INET4_POST_BIND,
- CGROUP_INET6_POST_BIND,
- CGROUP_UDP4_SENDMSG,
- CGROUP_UDP6_SENDMSG,
- CGROUP_SYSCTL,
- CGROUP_UDP4_RECVMSG,
- CGROUP_UDP6_RECVMSG,
- CGROUP_GETSOCKOPT,
- CGROUP_SETSOCKOPT,
- CGROUP_INET4_GETPEERNAME,
- CGROUP_INET6_GETPEERNAME,
- CGROUP_INET4_GETSOCKNAME,
- CGROUP_INET6_GETSOCKNAME,
- CGROUP_INET_SOCK_RELEASE,
- MAX_CGROUP_BPF_ATTACH_TYPE
-};
#define CGROUP_ATYPE(type) \
case BPF_##type: return type
@@ -127,33 +100,6 @@ struct bpf_prog_list {
struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE];
};
-struct bpf_prog_array;
-
-struct cgroup_bpf {
- /* array of effective progs in this cgroup */
- struct bpf_prog_array __rcu *effective[MAX_CGROUP_BPF_ATTACH_TYPE];
-
- /* attached progs to this cgroup and attach flags
- * when flags == 0 or BPF_F_ALLOW_OVERRIDE the progs list will
- * have either zero or one element
- * when BPF_F_ALLOW_MULTI the list can have up to BPF_CGROUP_MAX_PROGS
- */
- struct list_head progs[MAX_CGROUP_BPF_ATTACH_TYPE];
- u32 flags[MAX_CGROUP_BPF_ATTACH_TYPE];
-
- /* list of cgroup shared storages */
- struct list_head storages;
-
- /* temp storage for effective prog array used by prog_attach/detach */
- struct bpf_prog_array *inactive;
-
- /* reference counter used to detach bpf programs after cgroup removal */
- struct percpu_ref refcnt;
-
- /* cgroup_bpf is released using a work queue */
- struct work_struct release_work;
-};
-
int cgroup_bpf_inherit(struct cgroup *cgrp);
void cgroup_bpf_offline(struct cgroup *cgrp);
@@ -451,7 +397,6 @@ int cgroup_bpf_prog_query(const union bpf_attr *attr,
union bpf_attr __user *uattr);
#else
-struct cgroup_bpf {};
static inline int cgroup_bpf_inherit(struct cgroup *cgrp) { return 0; }
static inline void cgroup_bpf_offline(struct cgroup *cgrp) {}
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index db2e147e069f..411684c80cf3 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -19,7 +19,7 @@
#include <linux/percpu-rwsem.h>
#include <linux/u64_stats_sync.h>
#include <linux/workqueue.h>
-#include <linux/bpf-cgroup.h>
+#include <linux/bpf-cgroup-defs.h>
#include <linux/psi_types.h>
#ifdef CONFIG_CGROUPS
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH bpf-next v4 2/3] add missing bpf-cgroup.h includes
2021-12-15 18:12 ` [PATCH bpf-next v4 2/3] add missing bpf-cgroup.h includes Jakub Kicinski
@ 2021-12-15 18:28 ` Tejun Heo
0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2021-12-15 18:28 UTC (permalink / raw)
To: Jakub Kicinski
Cc: daniel, ast, andrii, bpf, kafai, songliubraving, yhs,
john.fastabend, kpsingh, lizefan.x, hannes, rostedt, mingo,
yoshfuji, dsahern, jmorris, serge, cgroups, linux-security-module
On Wed, Dec 15, 2021 at 10:12:30AM -0800, Jakub Kicinski wrote:
> We're about to break the cgroup-defs.h -> bpf-cgroup.h dependency,
> make sure those who actually need more than the definition of
> struct cgroup_bpf include bpf-cgroup.h explicitly.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH bpf-next v4 3/3] bpf: remove the cgroup -> bpf header dependecy
@ 2021-12-15 18:28 ` Tejun Heo
0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2021-12-15 18:28 UTC (permalink / raw)
To: Jakub Kicinski
Cc: daniel, ast, andrii, bpf, kafai, songliubraving, yhs,
john.fastabend, kpsingh, lizefan.x, hannes, cgroups
On Wed, Dec 15, 2021 at 10:12:31AM -0800, Jakub Kicinski wrote:
> Remove the dependency from cgroup-defs.h to bpf-cgroup.h and bpf.h.
> This reduces the incremental build size of x86 allmodconfig after
> bpf.h was touched from ~17k objects rebuilt to ~5k objects.
> bpf.h is 2.2kLoC and is modified relatively often.
>
> We need a new header with just the definition of struct cgroup_bpf
> and enum cgroup_bpf_attach_type, this is akin to cgroup-defs.h.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH bpf-next v4 3/3] bpf: remove the cgroup -> bpf header dependecy
@ 2021-12-15 18:28 ` Tejun Heo
0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2021-12-15 18:28 UTC (permalink / raw)
To: Jakub Kicinski
Cc: daniel-FeC+5ew28dpmcu3hnIyYJQ, ast-DgEjT+Ai2ygdnm+yROfE0A,
andrii-DgEjT+Ai2ygdnm+yROfE0A, bpf-u79uwXL29TY76Z2rM5mHXA,
kafai-b10kYP2dOMg, songliubraving-b10kYP2dOMg, yhs-b10kYP2dOMg,
john.fastabend-Re5JQEeQqe8AvxtiuMwx3w,
kpsingh-DgEjT+Ai2ygdnm+yROfE0A, lizefan.x-EC8Uxl6Npydl57MIdRCFDg,
hannes-druUgvl0LCNAfugRpC6u6w, cgroups-u79uwXL29TY76Z2rM5mHXA
On Wed, Dec 15, 2021 at 10:12:31AM -0800, Jakub Kicinski wrote:
> Remove the dependency from cgroup-defs.h to bpf-cgroup.h and bpf.h.
> This reduces the incremental build size of x86 allmodconfig after
> bpf.h was touched from ~17k objects rebuilt to ~5k objects.
> bpf.h is 2.2kLoC and is modified relatively often.
>
> We need a new header with just the definition of struct cgroup_bpf
> and enum cgroup_bpf_attach_type, this is akin to cgroup-defs.h.
>
> Signed-off-by: Jakub Kicinski <kuba-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Acked-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH bpf-next v4 0/3] bpf: remove the cgroup -> bpf header dependecy
2021-12-15 18:12 [PATCH bpf-next v4 0/3] bpf: remove the cgroup -> bpf header dependecy Jakub Kicinski
` (2 preceding siblings ...)
2021-12-15 18:12 ` Jakub Kicinski
@ 2021-12-15 19:47 ` Alexei Starovoitov
3 siblings, 0 replies; 11+ messages in thread
From: Alexei Starovoitov @ 2021-12-15 19:47 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: daniel, ast, andrii, bpf
On Wed, Dec 15, 2021 at 10:12:28AM -0800, Jakub Kicinski wrote:
> Changes to bpf.h tend to clog up our build systems. The netdev/bpf
> build bot does incremental builds to save time (reusing the build
> directory to only rebuild changed objects).
>
> This is the rough breakdown of how many objects needs to be rebuilt
> based on file touched:
>
> kernel.h 40633
> bpf.h 17881
> bpf-cgroup.h 17875
> skbuff.h 10696
> bpf-netns.h 7604
> netdevice.h 7452
> filter.h 5003
> tcp.h 4048
> sock.h 4959
>
> As the stats show touching bpf.h is _very_ expensive.
>
> Bulk of the objects get rebuilt because MM includes cgroup headers.
> Luckily bpf-cgroup.h does not fundamentally depend on bpf.h so we
> can break that dependency and reduce the number of objects.
>
> With the patches applied touching bpf.h causes 5019 objects to be rebuilt
> (17881 / 5019 = 3.56x). That's pretty much down to filter.h plus noise.
>
> v2:
> Try to make the new headers wider in scope. Collapse bpf-link and
> bpf-cgroup-types into one header, which may serve as "BPF kernel
> API" header in the future if needed. Rename bpf-cgroup-storage.h
> to bpf-inlines.h.
>
> Add a fix for the s390 build issue.
>
> v3: https://lore.kernel.org/all/20211215061916.715513-1-kuba@kernel.org/
> Merge bpf-includes.h into bpf.h.
> Remember to git format-patch after fixing build issues.
>
> v4:
> Change course - break off cgroup instead of breaking off bpf.
Nice. I think this approach is the best so far.
I'll wait a bit for 0-bot to test it with different configs
and BPF CI to catch up.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH bpf-next v4 3/3] bpf: remove the cgroup -> bpf header dependecy
2021-12-15 18:12 ` Jakub Kicinski
(?)
(?)
@ 2021-12-15 23:07 ` kernel test robot
-1 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-12-15 23:07 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 16978 bytes --]
Hi Jakub,
I love your patch! Perhaps something to improve:
[auto build test WARNING on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/Jakub-Kicinski/bpf-remove-the-cgroup-bpf-header-dependecy/20211216-021426
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20211216/202112160753.yRz2i2rn-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/4dc3a2bcf4720df1766ff9dc2bcbf14b3f221a31
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jakub-Kicinski/bpf-remove-the-cgroup-bpf-header-dependecy/20211216-021426
git checkout 4dc3a2bcf4720df1766ff9dc2bcbf14b3f221a31
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from init/main.c:21:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
init/main.c:768:20: warning: no previous prototype for 'arch_post_acpi_subsys_init' [-Wmissing-prototypes]
768 | void __init __weak arch_post_acpi_subsys_init(void) { }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
init/main.c:780:20: warning: no previous prototype for 'mem_encrypt_init' [-Wmissing-prototypes]
780 | void __init __weak mem_encrypt_init(void) { }
| ^~~~~~~~~~~~~~~~
init/main.c:782:20: warning: no previous prototype for 'poking_init' [-Wmissing-prototypes]
782 | void __init __weak poking_init(void) { }
| ^~~~~~~~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from init/noinitramfs.c:11:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from arch/um/kernel/syscall.c:11:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
arch/um/kernel/syscall.c:17:6: warning: no previous prototype for 'old_mmap' [-Wmissing-prototypes]
17 | long old_mmap(unsigned long addr, unsigned long len,
| ^~~~~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from arch/x86/um/tls_32.c:8:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
arch/x86/um/tls_32.c:23:5: warning: no previous prototype for 'do_set_thread_area' [-Wmissing-prototypes]
23 | int do_set_thread_area(struct user_desc *info)
| ^~~~~~~~~~~~~~~~~~
arch/x86/um/tls_32.c:39:5: warning: no previous prototype for 'do_get_thread_area' [-Wmissing-prototypes]
39 | int do_get_thread_area(struct user_desc *info)
| ^~~~~~~~~~~~~~~~~~
arch/x86/um/tls_32.c:187:5: warning: no previous prototype for 'arch_switch_tls' [-Wmissing-prototypes]
187 | int arch_switch_tls(struct task_struct *to)
| ^~~~~~~~~~~~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from kernel/fork.c:54:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
kernel/fork.c:161:13: warning: no previous prototype for 'arch_release_task_struct' [-Wmissing-prototypes]
161 | void __weak arch_release_task_struct(struct task_struct *tsk)
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/fork.c:763:20: warning: no previous prototype for 'arch_task_cache_init' [-Wmissing-prototypes]
763 | void __init __weak arch_task_cache_init(void) { }
| ^~~~~~~~~~~~~~~~~~~~
kernel/fork.c:858:12: warning: no previous prototype for 'arch_dup_task_struct' [-Wmissing-prototypes]
858 | int __weak arch_dup_task_struct(struct task_struct *dst,
| ^~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from kernel/exit.c:42:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
kernel/exit.c:1817:13: warning: no previous prototype for 'abort' [-Wmissing-prototypes]
1817 | __weak void abort(void)
| ^~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from fs/pipe.c:24:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
fs/pipe.c:755:15: warning: no previous prototype for 'account_pipe_buffers' [-Wmissing-prototypes]
755 | unsigned long account_pipe_buffers(struct user_struct *user,
| ^~~~~~~~~~~~~~~~~~~~
fs/pipe.c:761:6: warning: no previous prototype for 'too_many_pipe_buffers_soft' [-Wmissing-prototypes]
761 | bool too_many_pipe_buffers_soft(unsigned long user_bufs)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
fs/pipe.c:768:6: warning: no previous prototype for 'too_many_pipe_buffers_hard' [-Wmissing-prototypes]
768 | bool too_many_pipe_buffers_hard(unsigned long user_bufs)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
fs/pipe.c:775:6: warning: no previous prototype for 'pipe_is_unprivileged_user' [-Wmissing-prototypes]
775 | bool pipe_is_unprivileged_user(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
fs/pipe.c:1245:5: warning: no previous prototype for 'pipe_resize_ring' [-Wmissing-prototypes]
1245 | int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
| ^~~~~~~~~~~~~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from fs/d_path.c:2:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
fs/d_path.c:318:7: warning: no previous prototype for 'simple_dname' [-Wmissing-prototypes]
318 | char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
| ^~~~~~~~~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from fs/io_uring.c:45:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
fs/io_uring.c: In function '__io_submit_flush_completions':
fs/io_uring.c:2403:33: warning: variable 'prev' set but not used [-Wunused-but-set-variable]
2403 | struct io_wq_work_node *node, *prev;
| ^~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from kernel/time/timer.c:35:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
kernel/time/timer.c:254:5: warning: no previous prototype for 'timer_migration_handler' [-Wmissing-prototypes]
254 | int timer_migration_handler(struct ctl_table *table, int write,
| ^~~~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from kernel/time/hrtimer.c:30:
>> include/linux/perf_event.h:1499:48: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1499 | static inline void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
kernel/time/hrtimer.c:120:21: warning: initialized field overwritten [-Woverride-init]
120 | [CLOCK_REALTIME] = HRTIMER_BASE_REALTIME,
| ^~~~~~~~~~~~~~~~~~~~~
kernel/time/hrtimer.c:120:21: note: (near initialization for 'hrtimer_clock_to_base_table[0]')
kernel/time/hrtimer.c:121:22: warning: initialized field overwritten [-Woverride-init]
121 | [CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC,
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/time/hrtimer.c:121:22: note: (near initialization for 'hrtimer_clock_to_base_table[1]')
kernel/time/hrtimer.c:122:21: warning: initialized field overwritten [-Woverride-init]
122 | [CLOCK_BOOTTIME] = HRTIMER_BASE_BOOTTIME,
| ^~~~~~~~~~~~~~~~~~~~~
kernel/time/hrtimer.c:122:21: note: (near initialization for 'hrtimer_clock_to_base_table[7]')
kernel/time/hrtimer.c:123:17: warning: initialized field overwritten [-Woverride-init]
123 | [CLOCK_TAI] = HRTIMER_BASE_TAI,
| ^~~~~~~~~~~~~~~~
kernel/time/hrtimer.c:123:17: note: (near initialization for 'hrtimer_clock_to_base_table[11]')
kernel/time/hrtimer.c: In function '__run_hrtimer':
kernel/time/hrtimer.c:1648:7: warning: variable 'expires_in_hardirq' set but not used [-Wunused-but-set-variable]
1648 | bool expires_in_hardirq;
| ^~~~~~~~~~~~~~~~~~
..
vim +1499 include/linux/perf_event.h
76193a94522f1d include/linux/perf_event.h Song Liu 2019-01-17 1495
76193a94522f1d include/linux/perf_event.h Song Liu 2019-01-17 1496 typedef int (perf_ksymbol_get_name_f)(char *name, int name_len, void *data);
76193a94522f1d include/linux/perf_event.h Song Liu 2019-01-17 1497 static inline void perf_event_ksymbol(u16 ksym_type, u64 addr, u32 len,
76193a94522f1d include/linux/perf_event.h Song Liu 2019-01-17 1498 bool unregister, const char *sym) { }
6ee52e2a3fe4ea include/linux/perf_event.h Song Liu 2019-01-17 @1499 static inline void perf_event_bpf_event(struct bpf_prog *prog,
6ee52e2a3fe4ea include/linux/perf_event.h Song Liu 2019-01-17 1500 enum perf_bpf_event_type type,
6ee52e2a3fe4ea include/linux/perf_event.h Song Liu 2019-01-17 1501 u16 flags) { }
e041e328c4b41e include/linux/perf_event.h Peter Zijlstra 2014-05-21 1502 static inline void perf_event_exec(void) { }
82b897782d10fc include/linux/perf_event.h Adrian Hunter 2014-05-28 1503 static inline void perf_event_comm(struct task_struct *tsk, bool exec) { }
e422267322cd31 include/linux/perf_event.h Hari Bathini 2017-03-08 1504 static inline void perf_event_namespaces(struct task_struct *tsk) { }
cdd6c482c9ff9c include/linux/perf_event.h Ingo Molnar 2009-09-21 1505 static inline void perf_event_fork(struct task_struct *tsk) { }
e17d43b93e544f include/linux/perf_event.h Adrian Hunter 2020-05-12 1506 static inline void perf_event_text_poke(const void *addr,
e17d43b93e544f include/linux/perf_event.h Adrian Hunter 2020-05-12 1507 const void *old_bytes,
e17d43b93e544f include/linux/perf_event.h Adrian Hunter 2020-05-12 1508 size_t old_len,
e17d43b93e544f include/linux/perf_event.h Adrian Hunter 2020-05-12 1509 const void *new_bytes,
e17d43b93e544f include/linux/perf_event.h Adrian Hunter 2020-05-12 1510 size_t new_len) { }
cdd6c482c9ff9c include/linux/perf_event.h Ingo Molnar 2009-09-21 1511 static inline void perf_event_init(void) { }
4ed7c92d68a538 include/linux/perf_event.h Peter Zijlstra 2009-11-23 1512 static inline int perf_swevent_get_recursion_context(void) { return -1; }
4ed7c92d68a538 include/linux/perf_event.h Peter Zijlstra 2009-11-23 1513 static inline void perf_swevent_put_recursion_context(int rctx) { }
ab573844e3058e include/linux/perf_event.h Jiri Olsa 2013-05-01 1514 static inline u64 perf_swevent_set_period(struct perf_event *event) { return 0; }
44234adcdce38f include/linux/perf_event.h Frederic Weisbecker 2009-12-09 1515 static inline void perf_event_enable(struct perf_event *event) { }
44234adcdce38f include/linux/perf_event.h Frederic Weisbecker 2009-12-09 1516 static inline void perf_event_disable(struct perf_event *event) { }
500ad2d8b01390 include/linux/perf_event.h K.Prasad 2012-08-02 1517 static inline int __perf_event_disable(void *info) { return -1; }
e9d2b064149ff7 include/linux/perf_event.h Peter Zijlstra 2010-09-17 1518 static inline void perf_event_task_tick(void) { }
ffe8690c85b842 include/linux/perf_event.h Kaixu Xia 2015-08-06 1519 static inline int perf_event_release_kernel(struct perf_event *event) { return 0; }
3ca270fc9edb25 include/linux/perf_event.h Like Xu 2019-10-27 1520 static inline int perf_event_period(struct perf_event *event, u64 value)
3ca270fc9edb25 include/linux/perf_event.h Like Xu 2019-10-27 1521 {
3ca270fc9edb25 include/linux/perf_event.h Like Xu 2019-10-27 1522 return -EINVAL;
3ca270fc9edb25 include/linux/perf_event.h Like Xu 2019-10-27 1523 }
52ba4b0b99770e include/linux/perf_event.h Like Xu 2019-10-27 1524 static inline u64 perf_event_pause(struct perf_event *event, bool reset)
52ba4b0b99770e include/linux/perf_event.h Like Xu 2019-10-27 1525 {
52ba4b0b99770e include/linux/perf_event.h Like Xu 2019-10-27 1526 return 0;
52ba4b0b99770e include/linux/perf_event.h Like Xu 2019-10-27 1527 }
0793a61d4df8da include/linux/perf_counter.h Thomas Gleixner 2008-12-04 1528 #endif
0793a61d4df8da include/linux/perf_counter.h Thomas Gleixner 2008-12-04 1529
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH bpf-next v4 3/3] bpf: remove the cgroup -> bpf header dependecy
2021-12-15 18:12 ` Jakub Kicinski
` (2 preceding siblings ...)
(?)
@ 2021-12-15 23:59 ` kernel test robot
-1 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-12-15 23:59 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 5614 bytes --]
Hi Jakub,
I love your patch! Yet something to improve:
[auto build test ERROR on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/Jakub-Kicinski/bpf-remove-the-cgroup-bpf-header-dependecy/20211216-021426
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: nds32-defconfig (https://download.01.org/0day-ci/archive/20211216/202112160742.WbIAtZxD-lkp(a)intel.com/config)
compiler: nds32le-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/4dc3a2bcf4720df1766ff9dc2bcbf14b3f221a31
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jakub-Kicinski/bpf-remove-the-cgroup-bpf-header-dependecy/20211216-021426
git checkout 4dc3a2bcf4720df1766ff9dc2bcbf14b3f221a31
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=nds32 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from kernel/events/core.c:34:
include/linux/perf_event.h:1239:41: warning: 'struct bpf_prog' declared inside parameter list will not be visible outside of this definition or declaration
1239 | extern void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~
>> kernel/events/core.c:8935:6: error: conflicting types for 'perf_event_bpf_event'; have 'void(struct bpf_prog *, enum perf_bpf_event_type, u16)' {aka 'void(struct bpf_prog *, enum perf_bpf_event_type, short unsigned int)'}
8935 | void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~~~~~~~~~~~~~
In file included from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:88,
from kernel/events/core.c:34:
include/linux/perf_event.h:1239:13: note: previous declaration of 'perf_event_bpf_event' with type 'void(struct bpf_prog *, enum perf_bpf_event_type, u16)' {aka 'void(struct bpf_prog *, enum perf_bpf_event_type, short unsigned int)'}
1239 | extern void perf_event_bpf_event(struct bpf_prog *prog,
| ^~~~~~~~~~~~~~~~~~~~
vim +8935 kernel/events/core.c
6ee52e2a3fe4ea Song Liu 2019-01-17 8934
6ee52e2a3fe4ea Song Liu 2019-01-17 @8935 void perf_event_bpf_event(struct bpf_prog *prog,
6ee52e2a3fe4ea Song Liu 2019-01-17 8936 enum perf_bpf_event_type type,
6ee52e2a3fe4ea Song Liu 2019-01-17 8937 u16 flags)
6ee52e2a3fe4ea Song Liu 2019-01-17 8938 {
6ee52e2a3fe4ea Song Liu 2019-01-17 8939 struct perf_bpf_event bpf_event;
6ee52e2a3fe4ea Song Liu 2019-01-17 8940
6ee52e2a3fe4ea Song Liu 2019-01-17 8941 if (type <= PERF_BPF_EVENT_UNKNOWN ||
6ee52e2a3fe4ea Song Liu 2019-01-17 8942 type >= PERF_BPF_EVENT_MAX)
6ee52e2a3fe4ea Song Liu 2019-01-17 8943 return;
6ee52e2a3fe4ea Song Liu 2019-01-17 8944
6ee52e2a3fe4ea Song Liu 2019-01-17 8945 switch (type) {
6ee52e2a3fe4ea Song Liu 2019-01-17 8946 case PERF_BPF_EVENT_PROG_LOAD:
6ee52e2a3fe4ea Song Liu 2019-01-17 8947 case PERF_BPF_EVENT_PROG_UNLOAD:
6ee52e2a3fe4ea Song Liu 2019-01-17 8948 if (atomic_read(&nr_ksymbol_events))
6ee52e2a3fe4ea Song Liu 2019-01-17 8949 perf_event_bpf_emit_ksymbols(prog, type);
6ee52e2a3fe4ea Song Liu 2019-01-17 8950 break;
6ee52e2a3fe4ea Song Liu 2019-01-17 8951 default:
6ee52e2a3fe4ea Song Liu 2019-01-17 8952 break;
6ee52e2a3fe4ea Song Liu 2019-01-17 8953 }
6ee52e2a3fe4ea Song Liu 2019-01-17 8954
6ee52e2a3fe4ea Song Liu 2019-01-17 8955 if (!atomic_read(&nr_bpf_events))
6ee52e2a3fe4ea Song Liu 2019-01-17 8956 return;
6ee52e2a3fe4ea Song Liu 2019-01-17 8957
6ee52e2a3fe4ea Song Liu 2019-01-17 8958 bpf_event = (struct perf_bpf_event){
6ee52e2a3fe4ea Song Liu 2019-01-17 8959 .prog = prog,
6ee52e2a3fe4ea Song Liu 2019-01-17 8960 .event_id = {
6ee52e2a3fe4ea Song Liu 2019-01-17 8961 .header = {
6ee52e2a3fe4ea Song Liu 2019-01-17 8962 .type = PERF_RECORD_BPF_EVENT,
6ee52e2a3fe4ea Song Liu 2019-01-17 8963 .size = sizeof(bpf_event.event_id),
6ee52e2a3fe4ea Song Liu 2019-01-17 8964 },
6ee52e2a3fe4ea Song Liu 2019-01-17 8965 .type = type,
6ee52e2a3fe4ea Song Liu 2019-01-17 8966 .flags = flags,
6ee52e2a3fe4ea Song Liu 2019-01-17 8967 .id = prog->aux->id,
6ee52e2a3fe4ea Song Liu 2019-01-17 8968 },
6ee52e2a3fe4ea Song Liu 2019-01-17 8969 };
6ee52e2a3fe4ea Song Liu 2019-01-17 8970
6ee52e2a3fe4ea Song Liu 2019-01-17 8971 BUILD_BUG_ON(BPF_TAG_SIZE % sizeof(u64));
6ee52e2a3fe4ea Song Liu 2019-01-17 8972
6ee52e2a3fe4ea Song Liu 2019-01-17 8973 memcpy(bpf_event.event_id.tag, prog->tag, BPF_TAG_SIZE);
6ee52e2a3fe4ea Song Liu 2019-01-17 8974 perf_iterate_sb(perf_event_bpf_output, &bpf_event, NULL);
6ee52e2a3fe4ea Song Liu 2019-01-17 8975 }
6ee52e2a3fe4ea Song Liu 2019-01-17 8976
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-12-15 23:59 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-15 18:12 [PATCH bpf-next v4 0/3] bpf: remove the cgroup -> bpf header dependecy Jakub Kicinski
2021-12-15 18:12 ` [PATCH bpf-next v4 1/3] add includes masked by cgroup -> bpf dependency Jakub Kicinski
2021-12-15 18:12 ` [PATCH bpf-next v4 2/3] add missing bpf-cgroup.h includes Jakub Kicinski
2021-12-15 18:28 ` Tejun Heo
2021-12-15 18:12 ` [PATCH bpf-next v4 3/3] bpf: remove the cgroup -> bpf header dependecy Jakub Kicinski
2021-12-15 18:12 ` Jakub Kicinski
2021-12-15 18:28 ` Tejun Heo
2021-12-15 18:28 ` Tejun Heo
2021-12-15 23:07 ` kernel test robot
2021-12-15 23:59 ` kernel test robot
2021-12-15 19:47 ` [PATCH bpf-next v4 0/3] " Alexei Starovoitov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.