Support cgroup1 in get from fd/file interfaces
Subsystems (3)
v2 cover Support cgroup1 in get from fd/file interfaces
commit f3a2aebdd6fb ("cgroup: enable cgroup_get_from_file() on cgroup1") enabled using cgroup_get_from_file() and cgroup_get_from_fd() on cgroup1, to enable bpf cgroup_iter to attach to cgroup1.
Apparently, other callers depended on these functions only supporting cgroup2, so f3a2aebdd6 was reverted. Instead, add new separate interfaces that support both cgroup1 and cgroup2 and use them in bpf cgroup_iter.
Yosry Ahmed (2):
cgroup: add cgroup_v1v2_get_from_[fd/file]()
bpf: cgroup_iter: support cgroup1 using cgroup fd
include/linux/cgroup.h | 1 + kernel/bpf/cgroup_iter.c | 2 +- kernel/cgroup/cgroup.c | 50 +++++++++++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 7 deletions(-)
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
PATCH v2 1/2 cgroup: add cgroup_v1v2_get_from_[fd/file]()
Add cgroup_v1v2_get_from_fd() and cgroup_v1v2_get_from_file() that support both cgroup1 and cgroup2.
--- include/linux/cgroup.h | 1 + kernel/cgroup/cgroup.c | 50 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 6 deletions(-)
include/linux/cgroup.h +1 -0
@@ -106,6 +106,7 @@ struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,struct cgroup *cgroup_get_from_path (const char *path);struct cgroup *cgroup_get_from_fd (int fd); +struct cgroup *cgroup_v1v2_get_from_fd (int fd);int cgroup_attach_task_all (struct task_struct *from,struct task_struct *);int cgroup_transfer_tasks (struct cgroup *to,struct cgroup *from);
kernel/cgroup/cgroup.c +44 -6
84 lines not on this page · raw message
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
PATCH v2 2/2 bpf: cgroup_iter: support cgroup1 using cgroup fd
In reply to Yosry AhmedUse cgroup_v1v2_get_from_fd() in cgroup_iter to support attaching to both cgroup v1 and v2 using fds.
--- kernel/bpf/cgroup_iter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/cgroup_iter.c +1 -1
@@ -196,7 +196,7 @@ static int bpf_iter_attach_cgroup(struct bpf_prog *prog,return -EINVAL ;if (fd) - cgrp =cgroup_get_from_fd (fd); + cgrp =cgroup_v1v2_get_from_fd (fd);else if (id) cgrp =cgroup_get_from_id (id);else /* walk the entire hierarchy by default. */
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
Re: [PATCH v2 2/2] bpf: cgroup_iter: support cgroup1 using cgroup fd
Quoted 13 lines · Yosry Ahmed
Use
cgroup_v1v2_get_from_fd()incgroup_iterto support attaching to both cgroup v1 and v2 using fds.Signed-off-by Yosry Ahmed <[email protected]>--- kernel/bpf/cgroup_iter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/bpf/cgroup_iter.c +0
-0
kernel/bpf/cgroup_iter.c static int bpf_iter_attach_cgroup(struct bpf_prog *prog, · line 199
Quoted 5 lines
kernel/bpf/cgroup_iter.c +1
-1@@ -196,7 +196,7 @@ static int bpf_iter_attach_cgroup(struct bpf_prog *prog,return -EINVAL ;if (fd) - cgrp =cgroup_get_from_fd (fd); + cgrp =cgroup_v1v2_get_from_fd (fd);
Tejun, patch 1 should depend on a recent revert that is not in the bpf tree yet.
Do you want to take this set to the cgroup tree?
Quoted 3 lines
kernel/bpf/cgroup_iter.c +0
-0else if (id) cgrp =cgroup_get_from_id (id);else /* walk the entire hierarchy by default. */
Tejun Heo
maintainerRe: [PATCH v2 2/2] bpf: cgroup_iter: support cgroup1 using cgroup fd
Quoted 21 lines · Martin KaFai Lau
Quoted 13 lines · Yosry Ahmed
Use
cgroup_v1v2_get_from_fd()incgroup_iterto support attaching to both cgroup v1 and v2 using fds.Signed-off-by Yosry Ahmed <[email protected]>--- kernel/bpf/cgroup_iter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/bpf/cgroup_iter.c +0
-0kernel/bpf/cgroup_iter.c static int bpf_iter_attach_cgroup(struct bpf_prog *prog, · line 198
Quoted 4 lines
kernel/bpf/cgroup_iter.c +1
-1@@ -196,7 +196,7 @@ static int bpf_iter_attach_cgroup(struct bpf_prog *prog,return -EINVAL ;if (fd) - cgrp =cgroup_get_from_fd (fd); + cgrp =cgroup_v1v2_get_from_fd (fd);Acked-by Martin KaFai Lau <[email protected]>
Quoted 2 lines
Tejun, patch 1 should depend on a recent revert that is not in the bpf tree yet. Do you want to take this set to the cgroup tree?
Yeah, will do.
Thanks.
Signature · 1 line
tejun
Quoted 7 lines · Yosry Ahmed
commit
f3a2aebdd6fb("cgroup: enablecgroup_get_from_file()on cgroup1") enabled usingcgroup_get_from_file()andcgroup_get_from_fd()on cgroup1, to enable bpfcgroup_iterto attach to cgroup1.Apparently, other callers depended on these functions only supporting cgroup2, so
f3a2aebdd6was reverted. Instead, add new separate interfaces that support both cgroup1 and cgroup2 and use them in bpfcgroup_iter.
Applied to cgroup/for-6.1-fixes.
Thanks.
Signature · 1 line
tejun