cgroup: expose cpu.stat and io.stat to BPF - #8840
cgroup: expose cpu.stat and io.stat to BPF#8840kernel-patches-daemon-bpf-rc[bot] wants to merge 4 commits into
Conversation
|
Upstream branch: d19862d |
681fb2f to
209cb87
Compare
|
Upstream branch: 4191e49 |
81f9d4e to
c9e1c3f
Compare
209cb87 to
1187f2e
Compare
|
Upstream branch: 4954de7 |
c9e1c3f to
15671b8
Compare
1187f2e to
129fef6
Compare
|
Upstream branch: e40f61a |
15671b8 to
e77eb14
Compare
129fef6 to
0841678
Compare
|
Upstream branch: 669e4fa |
e77eb14 to
7471e19
Compare
0841678 to
fe422a2
Compare
|
Upstream branch: a284ed4 |
7471e19 to
d8254c1
Compare
fe422a2 to
8483dd1
Compare
|
Upstream branch: 5e289c5 |
d8254c1 to
38e7e82
Compare
8483dd1 to
9069116
Compare
Collecting cgroup statistics is expensive because the existing method opens and parses a cgroup file. memcg already provides an efficient BPF interface; extend that model to the CPU controller. Register css_rstat_flush() as a common kfunc and add bpf_cgroup_base_stat(). The latter returns cgroup_base_stat after the same cputime adjustment used by cpu.stat. The BPF program reads the plain CFS bandwidth counters directly. Add bpf_css_to_task_group() to check the controller and give the verifier a typed task_group pointer for bpf_per_cpu_ptr(). css_rstat_flush() may reschedule and requires a sleepable program. bpf_cgroup_base_stat() only takes locks and is not marked sleepable, but those locks are not NMI-safe. Suggested-by: Shakeel Butt <shakeel.butt@linux.dev> Suggested-by: Tejun Heo <tj@kernel.org> Assisted-by: Claude:claude-opus-5 Signed-off-by: Ziyang Men <ziyang.meme@gmail.com>
Add cgroup_iter_cpu, a selftest for the CPU controller BPF kfuncs.
The userspace side runs a CPU hog in a test cgroup with cpu.max settled
then:
- checks the CPU-time and throttling counters are nonzero,
- compares whether all values the program read are same as those
reading from cgroup file.
Enable CONFIG_CGROUP_SCHED, CONFIG_FAIR_GROUP_SCHED and
CONFIG_CFS_BANDWIDTH in the selftest config.
Tested on VM with v7.2-rc5.
Suggested-by: Shakeel Butt <shakeel.butt@linux.dev>
Assisted-by: Claude:claude-opus-5
Signed-off-by: Ziyang Men <ziyang.meme@gmail.com>
Collecting cgroup statistics is expensive because the existing method opens and parses a cgroup file for every cgroup. memcg already provides an efficient BPF interface; extend that model to the block controller. Add bpf_cgroup_css() and bpf_css_release() to acquire a controller's css from a cgroup. The reference keeps the css alive across the sleepable css_rstat_flush(). Add bpf_css_to_blkcg() as a checked RCU-protected css-to-blkcg conversion and an open-coded iterator for the per-device blkgs. Suggested-by: Shakeel Butt <shakeel.butt@linux.dev> Suggested-by: Tejun Heo <tj@kernel.org> Assisted-by: Claude:claude-opus-5 Signed-off-by: Ziyang Men <ziyang.meme@gmail.com>
Add cgroup_iter_io to test the blkcg io.stat BPF kfuncs. The BPF program acquires the I/O css, flushes its statistics, converts it to a typed blkcg under RCU, walks the blkgs, and releases the css reference. The test performs O_DIRECT I/O on a private loop device. It checks the device ID and counters against io.stat. Assisted-by: Claude:claude-opus-5 Signed-off-by: Ziyang Men <ziyang.meme@gmail.com>
|
Upstream branch: 5e289c5 |
38e7e82 to
cc2e601
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1149338 expired. Closing PR. |
Pull request for series with
subject: cgroup: expose cpu.stat and io.stat to BPF
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1149338