Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Determine cgroup mode in add_task() #104

Merged
merged 2 commits into from
Feb 9, 2023

Conversation

yaoyinnan
Copy link
Member

Determine the cgroup mode in add_task() to avoid the wrong operation of the caller writing threads to cgroup.threads in non-thread mode.

Fixes: #103

Signed-off-by: yaoyinnan yaoyinnan@foxmail.com

@yaoyinnan yaoyinnan requested a review from liubin January 13, 2023 07:51
@Tim-Zhang Tim-Zhang self-requested a review February 7, 2023 03:39
@yaoyinnan yaoyinnan force-pushed the 103/fix/add-task branch 7 times, most recently from c834a31 to 6236b49 Compare February 7, 2023 07:47
Determine the cgroup mode in add_task() to avoid the wrong operation of the caller writing threads to cgroup.threads in non-thread mode.

Fixes: kata-containers#103

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
Add UT for add_task() for cgroup v1 and v2.

Fixes: kata-containers#103

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
@yaoyinnan
Copy link
Member Author

@Tim-Zhang @liubin I fixed add_task(). In cgroup v2, it is only allowed to write to cgroup.threads when cgroup type is threaded or domain threaded. At other times, an error message prompts that the method is called in the wrong cgroup mode.

@Tim-Zhang Tim-Zhang requested a review from liubin February 9, 2023 02:34
Copy link
Member

@Tim-Zhang Tim-Zhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @yaoyinnan

@Tim-Zhang Tim-Zhang merged commit 257012f into kata-containers:main Feb 9, 2023
Tim-Zhang added a commit to Tim-Zhang/cgroups-rs that referenced this pull request Mar 15, 2023
To include patches kata-containers#104, kata-containers#113.

Signed-off-by: Tim Zhang <tim@hyper.sh>
@Tim-Zhang Tim-Zhang mentioned this pull request Mar 15, 2023
jsturtevant added a commit to jsturtevant/rust-extensions that referenced this pull request Oct 24, 2023
in cgroupv2 we should use the cgroups.proc file when adding a process (https://www.man7.org/linux/man-pages/man7/cgroups.7.html).  The add_tasks function was writing to the cgroup.threads file which is only avaliable when in threaded mode.  In either case our intent is to add the process not the individual threads to we should use add_task_by_tgid. See kata-containers/cgroups-rs#104 for when this was added

Signed-off-by: James Sturtevant <jstur@microsoft.com>
jsturtevant added a commit to jsturtevant/rust-extensions that referenced this pull request Oct 24, 2023
in cgroupv2 we should use the cgroups.proc file when adding a process (https://www.man7.org/linux/man-pages/man7/cgroups.7.html).  The add_tasks function was writing to the cgroup.threads file which is only avaliable when in threaded mode.  In either case our intent is to add the process not the individual threads to we should use add_task_by_tgid. See kata-containers/cgroups-rs#104 for when this was added

Signed-off-by: James Sturtevant <jstur@microsoft.com>
github-merge-queue bot pushed a commit to containerd/rust-extensions that referenced this pull request Oct 25, 2023
in cgroupv2 we should use the cgroups.proc file when adding a process (https://www.man7.org/linux/man-pages/man7/cgroups.7.html).  The add_tasks function was writing to the cgroup.threads file which is only avaliable when in threaded mode.  In either case our intent is to add the process not the individual threads to we should use add_task_by_tgid. See kata-containers/cgroups-rs#104 for when this was added

Signed-off-by: James Sturtevant <jstur@microsoft.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Determine cgroup mode in add_task()
3 participants