[systemd-devel] unable to attach pid to service delegated directory in unified mode after restart

Felip Moll felip at schedmd.com
Wed Mar 16 17:29:08 UTC 2022


On Wed, Mar 16, 2022 at 5:53 PM Lennart Poettering <lennart at poettering.net>
wrote:

> On Mi, 16.03.22 17:30, Felip Moll (felip at schedmd.com) wrote:
>
> > AFAIK RemainAfterExit for services actually does cleanup the cgroup tree
> if
> > there are no more processes in it.
>
> It doesn't do that if delegation is on (iirc, if not I'd consider that
> a bug). Same logic should apply here.
>
>
I will recheck that, but I am quite sure that on some tests I did the
cgroup was cleaned up on a delegated service after the main pid terminated.



> > If that behavior of keeping the cgroup tree even if there are no pids is
> > what you agree with, then I coincide is a good idea to include this
> option
> > to scopes.
>
> Yes, that is what I was suggesting this would do.
>
>
Excellent.



> > Or are you saying that I can just migrate processes wildly without
> > informing systemd and just doing an 'echo > cgroup.procs' from one
> > non-delegated tree to my delegated subtree?
>
> yeah, you can do that.
>
>
Ok, so I understood that incorrectly from a former paragraph you wrote in
our first e-mails. you said:

> Migrating processes wildly between cgroups is messy, because it fucks
> up accounting and is restricted permission-wise. Typically you want to
> create a cgroup and populate it, and then stick to that.

There, I understood you were referring to "systemd" accounting, not
"kernel" accounting.
This has been a big misunderstanding for this issue.


> Note that (independently of systemd) you shouldn't migrate stuff to
> aggressively, since it fucks up kernel resource accounting. i.e. it is
> wise to minimize process migration in cgroups and always migrate plus
> shortly after exec()
>

Yeah, that makes sense and I am aware of it.
I am migrating before any real work is done, exactly as you describe.


I will continue a bit more with this and inform you on what I see, but we
seem to be close to a solution.

Thank you!.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220316/51fc7c8a/attachment.htm>


More information about the systemd-devel mailing list