Skip to content

Commit c93a2da

Browse files
authored
Merge pull request #24 from poettering/pidfd-cgroup
wishlist: an API to add pidfds to cgroups
2 parents a2fad0a + 5df2fd3 commit c93a2da

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,3 +718,21 @@ point that out explicitly and clearly in the associated patches and Cc
718718
since btrfs places files all over the backing store, and thus the
719719
shrinking will generate a lot of nonsensical IO that could be
720720
reduced if the file system was always kept minimal in size anyway.
721+
722+
* Add process by PIDFD to a cgroup
723+
724+
At the moment the canonical way to add a process to a cgroup is by
725+
echoing its PID into the `cgroup.procs` attribute in the target
726+
cgroupfs directory of the cgroup. This is safe as long as the
727+
process doing so just forked off the process it wants to migrate and
728+
hence can control that it hasn't been reaped yet, and hence
729+
guarantees the PID is valid. This is racy however if "foreign"
730+
processes shall be moved into the cgroup.
731+
732+
**Usecase:** In systemd, all user sessions are wrapped in scope
733+
units which are backed by a cgroup. The session processes moved into
734+
the scope unit are typically "foreign" processes, i.e. not children
735+
of the service manager, hence doing the movement is subject to races
736+
in case the process dies and its PID is quickly recycled. (This
737+
assumes systemd can acquire a pidfd of the foreign process without
738+
races, for example via `SCM_PIDFD` and `SO_PEERPIDFD` or similar.)

0 commit comments

Comments
 (0)