Score:1

How to move already running processes to different `cgroup` with systemd?

cn flag

I'm using Ubuntu 20.04 LTS with MATE desktop which doesn't natively support launching desktop UI and window manager in a separate cgroup from the other applications.

Is it possible to run some systemd specific commands via .xsessionrc to create nested cgroup as child of user@${UID}.service and move selected processes there? I'd prefer something that doesn't require sudo or root so that the required commands could be safely executed by the respective user account (with the effective user id $UID).

Basically I'm looking for real world replacements for following imaginary commands

systemd-cgroup-create --parent "user@${UID}.service" "gui-desktop@${UID}.slice"
systemd-cgroup-move-process --to "gui-desktop@${UID}.slice" $(pgrep --uid $UID marco) $(pgrep --uid $UID mate-panel) $(pgrep --uid $UID mate-session)
systemd-cgroup-modify --set "MemoryMin=1G" --set "IOWeight=1000" "gui-desktop@${UID}.slice"

All I can see is systemd-run but that only supports starting a single process instead of manipulating already existing processes.

I know that cgclassify and similar old tools can technically do this given root acces but systemd expects that it's the sole source of modifications to the cgroup hierarchy so this would need to be done via systemd specific commands.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.