forked from torvalds/linux
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
bpf: remove the cgroup -> bpf header dependecy
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>
- Loading branch information
1 parent
11a2f86
commit 4dc3a2bcf4720df1766ff9dc2bcbf14b3f221a31
Showing
3 changed files
with
72 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters