linux-IllusionX/include
Hao Luo d4ccaf58a8 bpf: Introduce cgroup iter
Cgroup_iter is a type of bpf_iter. It walks over cgroups in four modes:

 - walking a cgroup's descendants in pre-order.
 - walking a cgroup's descendants in post-order.
 - walking a cgroup's ancestors.
 - process only the given cgroup.

When attaching cgroup_iter, one can set a cgroup to the iter_link
created from attaching. This cgroup is passed as a file descriptor
or cgroup id and serves as the starting point of the walk. If no
cgroup is specified, the starting point will be the root cgroup v2.

For walking descendants, one can specify the order: either pre-order or
post-order. For walking ancestors, the walk starts at the specified
cgroup and ends at the root.

One can also terminate the walk early by returning 1 from the iter
program.

Note that because walking cgroup hierarchy holds cgroup_mutex, the iter
program is called with cgroup_mutex held.

Currently only one session is supported, which means, depending on the
volume of data bpf program intends to send to user space, the number
of cgroups that can be walked is limited. For example, given the current
buffer size is 8 * PAGE_SIZE, if the program sends 64B data for each
cgroup, assuming PAGE_SIZE is 4kb, the total number of cgroups that can
be walked is 512. This is a limitation of cgroup_iter. If the output
data is larger than the kernel buffer size, after all data in the
kernel buffer is consumed by user space, the subsequent read() syscall
will signal EOPNOTSUPP. In order to work around, the user may have to
update their program to reduce the volume of data sent to output. For
example, skip some uninteresting cgroups. In future, we may extend
bpf_iter flags to allow customizing buffer size.

Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Hao Luo <haoluo@google.com>
Link: https://lore.kernel.org/r/20220824233117.1312810-2-haoluo@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2022-08-25 11:35:37 -07:00
..
acpi Merge branch 'acpi-properties' 2022-08-11 19:21:03 +02:00
asm-generic Bitmap patches for v6.0-rc1 2022-08-07 17:52:35 -07:00
clocksource - Add the missing DT bindings for the MTU nomadik timer (Linus 2022-07-28 12:33:34 +02:00
crypto for-5.20/block-2022-08-04 2022-08-04 20:00:14 -07:00
drm Driver uAPI changes: 2022-07-22 15:51:31 +10:00
dt-bindings Pin control bulk changes for v6.0: 2022-08-10 11:01:44 -07:00
keys
kunit
kvm
linux bpf: Introduce cgroup iter 2022-08-25 11:35:37 -07:00
math-emu
media SPDX changes for 6.0-rc1 2022-08-04 12:12:54 -07:00
memory
misc
net bpf: Change bpf_setsockopt(SOL_IPV6) to reuse do_ipv6_setsockopt() 2022-08-18 17:06:13 -07:00
pcmcia
ras mm, hwpoison: enable memory error handling on 1GB hugepage 2022-08-08 18:06:44 -07:00
rdma dma-mapping updates 2022-08-06 10:56:45 -07:00
rv Documentation/rv: Add deterministic automata monitor synthesis documentation 2022-07-30 14:01:29 -04:00
scsi dma-mapping updates 2022-08-06 10:56:45 -07:00
soc Char / Misc driver changes for 6.0-rc1 2022-08-04 11:05:48 -07:00
sound ASoC: More updates for v5.20 2022-08-01 15:26:40 +02:00
target
trace * Xen timer fixes 2022-08-11 12:10:08 -07:00
uapi bpf: Introduce cgroup iter 2022-08-25 11:35:37 -07:00
ufs
vdso
video
xen xen: don't require virtio with grants for non-PV guests 2022-08-01 07:43:03 +02:00