Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'bpf: remove the cgroup -> bpf header dependecy'

Jakub Kicinski says:

====================

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
sock.h 4959
tcp.h 4048

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.

v4: https://lore.kernel.org/all/20211215181231.1053479-1-kuba@kernel.org/
Change course - break off cgroup instead of breaking off bpf.

v5:
Add forward declaration of struct bpf_prog to perf_event.h
when !CONFIG_BPF_SYSCALL (kbuild bot).
====================

Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+84 -57
+1
arch/s390/mm/hugetlbpage.c
··· 9 9 #define KMSG_COMPONENT "hugetlb" 10 10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 11 11 12 + #include <asm/pgalloc.h> 12 13 #include <linux/mm.h> 13 14 #include <linux/hugetlb.h> 14 15 #include <linux/mman.h>
+70
include/linux/bpf-cgroup-defs.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _BPF_CGROUP_DEFS_H 3 + #define _BPF_CGROUP_DEFS_H 4 + 5 + #ifdef CONFIG_CGROUP_BPF 6 + 7 + #include <linux/list.h> 8 + #include <linux/percpu-refcount.h> 9 + #include <linux/workqueue.h> 10 + 11 + struct bpf_prog_array; 12 + 13 + enum cgroup_bpf_attach_type { 14 + CGROUP_BPF_ATTACH_TYPE_INVALID = -1, 15 + CGROUP_INET_INGRESS = 0, 16 + CGROUP_INET_EGRESS, 17 + CGROUP_INET_SOCK_CREATE, 18 + CGROUP_SOCK_OPS, 19 + CGROUP_DEVICE, 20 + CGROUP_INET4_BIND, 21 + CGROUP_INET6_BIND, 22 + CGROUP_INET4_CONNECT, 23 + CGROUP_INET6_CONNECT, 24 + CGROUP_INET4_POST_BIND, 25 + CGROUP_INET6_POST_BIND, 26 + CGROUP_UDP4_SENDMSG, 27 + CGROUP_UDP6_SENDMSG, 28 + CGROUP_SYSCTL, 29 + CGROUP_UDP4_RECVMSG, 30 + CGROUP_UDP6_RECVMSG, 31 + CGROUP_GETSOCKOPT, 32 + CGROUP_SETSOCKOPT, 33 + CGROUP_INET4_GETPEERNAME, 34 + CGROUP_INET6_GETPEERNAME, 35 + CGROUP_INET4_GETSOCKNAME, 36 + CGROUP_INET6_GETSOCKNAME, 37 + CGROUP_INET_SOCK_RELEASE, 38 + MAX_CGROUP_BPF_ATTACH_TYPE 39 + }; 40 + 41 + struct cgroup_bpf { 42 + /* array of effective progs in this cgroup */ 43 + struct bpf_prog_array __rcu *effective[MAX_CGROUP_BPF_ATTACH_TYPE]; 44 + 45 + /* attached progs to this cgroup and attach flags 46 + * when flags == 0 or BPF_F_ALLOW_OVERRIDE the progs list will 47 + * have either zero or one element 48 + * when BPF_F_ALLOW_MULTI the list can have up to BPF_CGROUP_MAX_PROGS 49 + */ 50 + struct list_head progs[MAX_CGROUP_BPF_ATTACH_TYPE]; 51 + u32 flags[MAX_CGROUP_BPF_ATTACH_TYPE]; 52 + 53 + /* list of cgroup shared storages */ 54 + struct list_head storages; 55 + 56 + /* temp storage for effective prog array used by prog_attach/detach */ 57 + struct bpf_prog_array *inactive; 58 + 59 + /* reference counter used to detach bpf programs after cgroup removal */ 60 + struct percpu_ref refcnt; 61 + 62 + /* cgroup_bpf is released using a work queue */ 63 + struct work_struct release_work; 64 + }; 65 + 66 + #else /* CONFIG_CGROUP_BPF */ 67 + struct cgroup_bpf {}; 68 + #endif /* CONFIG_CGROUP_BPF */ 69 + 70 + #endif
+1 -56
include/linux/bpf-cgroup.h
··· 3 3 #define _BPF_CGROUP_H 4 4 5 5 #include <linux/bpf.h> 6 + #include <linux/bpf-cgroup-defs.h> 6 7 #include <linux/errno.h> 7 8 #include <linux/jump_label.h> 8 9 #include <linux/percpu.h> 9 - #include <linux/percpu-refcount.h> 10 10 #include <linux/rbtree.h> 11 11 #include <uapi/linux/bpf.h> 12 12 ··· 23 23 struct task_struct; 24 24 25 25 #ifdef CONFIG_CGROUP_BPF 26 - enum cgroup_bpf_attach_type { 27 - CGROUP_BPF_ATTACH_TYPE_INVALID = -1, 28 - CGROUP_INET_INGRESS = 0, 29 - CGROUP_INET_EGRESS, 30 - CGROUP_INET_SOCK_CREATE, 31 - CGROUP_SOCK_OPS, 32 - CGROUP_DEVICE, 33 - CGROUP_INET4_BIND, 34 - CGROUP_INET6_BIND, 35 - CGROUP_INET4_CONNECT, 36 - CGROUP_INET6_CONNECT, 37 - CGROUP_INET4_POST_BIND, 38 - CGROUP_INET6_POST_BIND, 39 - CGROUP_UDP4_SENDMSG, 40 - CGROUP_UDP6_SENDMSG, 41 - CGROUP_SYSCTL, 42 - CGROUP_UDP4_RECVMSG, 43 - CGROUP_UDP6_RECVMSG, 44 - CGROUP_GETSOCKOPT, 45 - CGROUP_SETSOCKOPT, 46 - CGROUP_INET4_GETPEERNAME, 47 - CGROUP_INET6_GETPEERNAME, 48 - CGROUP_INET4_GETSOCKNAME, 49 - CGROUP_INET6_GETSOCKNAME, 50 - CGROUP_INET_SOCK_RELEASE, 51 - MAX_CGROUP_BPF_ATTACH_TYPE 52 - }; 53 26 54 27 #define CGROUP_ATYPE(type) \ 55 28 case BPF_##type: return type ··· 98 125 struct bpf_prog *prog; 99 126 struct bpf_cgroup_link *link; 100 127 struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE]; 101 - }; 102 - 103 - struct bpf_prog_array; 104 - 105 - struct cgroup_bpf { 106 - /* array of effective progs in this cgroup */ 107 - struct bpf_prog_array __rcu *effective[MAX_CGROUP_BPF_ATTACH_TYPE]; 108 - 109 - /* attached progs to this cgroup and attach flags 110 - * when flags == 0 or BPF_F_ALLOW_OVERRIDE the progs list will 111 - * have either zero or one element 112 - * when BPF_F_ALLOW_MULTI the list can have up to BPF_CGROUP_MAX_PROGS 113 - */ 114 - struct list_head progs[MAX_CGROUP_BPF_ATTACH_TYPE]; 115 - u32 flags[MAX_CGROUP_BPF_ATTACH_TYPE]; 116 - 117 - /* list of cgroup shared storages */ 118 - struct list_head storages; 119 - 120 - /* temp storage for effective prog array used by prog_attach/detach */ 121 - struct bpf_prog_array *inactive; 122 - 123 - /* reference counter used to detach bpf programs after cgroup removal */ 124 - struct percpu_ref refcnt; 125 - 126 - /* cgroup_bpf is released using a work queue */ 127 - struct work_struct release_work; 128 128 }; 129 129 130 130 int cgroup_bpf_inherit(struct cgroup *cgrp); ··· 397 451 union bpf_attr __user *uattr); 398 452 #else 399 453 400 - struct cgroup_bpf {}; 401 454 static inline int cgroup_bpf_inherit(struct cgroup *cgrp) { return 0; } 402 455 static inline void cgroup_bpf_offline(struct cgroup *cgrp) {} 403 456
+1 -1
include/linux/cgroup-defs.h
··· 19 19 #include <linux/percpu-rwsem.h> 20 20 #include <linux/u64_stats_sync.h> 21 21 #include <linux/workqueue.h> 22 - #include <linux/bpf-cgroup.h> 22 + #include <linux/bpf-cgroup-defs.h> 23 23 #include <linux/psi_types.h> 24 24 25 25 #ifdef CONFIG_CGROUPS
+1
include/linux/perf_event.h
··· 611 611 #define PERF_ATTACH_SCHED_CB 0x20 612 612 #define PERF_ATTACH_CHILD 0x40 613 613 614 + struct bpf_prog; 614 615 struct perf_cgroup; 615 616 struct perf_buffer; 616 617
+1
kernel/bpf/helpers.c
··· 2 2 /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com 3 3 */ 4 4 #include <linux/bpf.h> 5 + #include <linux/bpf-cgroup.h> 5 6 #include <linux/rcupdate.h> 6 7 #include <linux/random.h> 7 8 #include <linux/smp.h>
+1
kernel/bpf/syscall.c
··· 2 2 /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com 3 3 */ 4 4 #include <linux/bpf.h> 5 + #include <linux/bpf-cgroup.h> 5 6 #include <linux/bpf_trace.h> 6 7 #include <linux/bpf_lirc.h> 7 8 #include <linux/bpf_verifier.h>
+1
kernel/bpf/verifier.c
··· 4 4 * Copyright (c) 2018 Covalent IO, Inc. http://covalent.io 5 5 */ 6 6 #include <uapi/linux/btf.h> 7 + #include <linux/bpf-cgroup.h> 7 8 #include <linux/kernel.h> 8 9 #include <linux/types.h> 9 10 #include <linux/slab.h>
+1
kernel/cgroup/cgroup.c
··· 30 30 31 31 #include "cgroup-internal.h" 32 32 33 + #include <linux/bpf-cgroup.h> 33 34 #include <linux/cred.h> 34 35 #include <linux/errno.h> 35 36 #include <linux/init_task.h>
+1
kernel/trace/trace_kprobe.c
··· 7 7 */ 8 8 #define pr_fmt(fmt) "trace_kprobe: " fmt 9 9 10 + #include <linux/bpf-cgroup.h> 10 11 #include <linux/security.h> 11 12 #include <linux/module.h> 12 13 #include <linux/uaccess.h>
+1
kernel/trace/trace_uprobe.c
··· 7 7 */ 8 8 #define pr_fmt(fmt) "trace_uprobe: " fmt 9 9 10 + #include <linux/bpf-cgroup.h> 10 11 #include <linux/security.h> 11 12 #include <linux/ctype.h> 12 13 #include <linux/module.h>
+1
net/ipv4/udp.c
··· 74 74 75 75 #define pr_fmt(fmt) "UDP: " fmt 76 76 77 + #include <linux/bpf-cgroup.h> 77 78 #include <linux/uaccess.h> 78 79 #include <asm/ioctls.h> 79 80 #include <linux/memblock.h>
+1
net/ipv6/udp.c
··· 17 17 * YOSHIFUJI Hideaki @USAGI: convert /proc/net/udp6 to seq_file. 18 18 */ 19 19 20 + #include <linux/bpf-cgroup.h> 20 21 #include <linux/errno.h> 21 22 #include <linux/types.h> 22 23 #include <linux/socket.h>
+1
net/socket.c
··· 52 52 * Based upon Swansea University Computer Society NET3.039 53 53 */ 54 54 55 + #include <linux/bpf-cgroup.h> 55 56 #include <linux/ethtool.h> 56 57 #include <linux/mm.h> 57 58 #include <linux/socket.h>
+1
security/device_cgroup.c
··· 5 5 * Copyright 2007 IBM Corp 6 6 */ 7 7 8 + #include <linux/bpf-cgroup.h> 8 9 #include <linux/device_cgroup.h> 9 10 #include <linux/cgroup.h> 10 11 #include <linux/ctype.h>