[systemd-devel] Moving a service from one systemd slice to another..

Tomasz Torcz tomek at pipebreaker.pl
Thu May 7 06:28:07 UTC 2020


On Wed, May 06, 2020 at 11:53:14PM +0200, Lennart Poettering wrote:
> > > >
> > > >   You can use low-level cgroup access to move it. Something like:
> > > > systemctl show --property MainPID --value your.service >
> > > > /sys/fs/cgroup/NEW.slice/cgroup.procs
> > >
> > > You void your warranty if you do that. Moreover, on cgroupvs2 this
> > > doesn't work really, since inner cgroups cannot have processes and
> > > slices are by definition inner cgroups.
> >
> >   Doesn't work? I beg to differ, the following is on Fedora 31:
> >
> > Control group /:
> > -.slice
> > ├─kodi.slice
> > │ └─2872766 /usr/lib64/kodi/kodi-wayland      ← here it has process
> 
> 
> >  Is there an API in systemd to move specific program to a dedicated
> >  slice?
> 
> Use Slice= in the service file.
 
  That would require having a service file.  I don't have it. I just have a
single process in session which I need to treat specially.  Thus I move
it to separate slice.  I have /etc/systemd/system/kodi.slice to define
this separate slice and resource controls for it.


> >   In my usecase, I've created a top-level .slice for Kodi player. I want
> > it to have priority over everything on my machine - over other users'
> > processes, over virtual machines, over everything in system.slice.
> > I achieve it by having this top-level slice with CPUShares, CPUWeight,
> > BlockIOWeight, IOWeight much higher and IODeviceLatencyTargetSec
> > much lower than rest of the slices.  Seems to work.
> 
> I presume you you mean a top-level slice in the system manager? If so
> you need to run kodi as a system service too.

  That wouldn't work, Kodi is strictly tied to user session - file
permissions, configurations, access to screen and audio (Kodi is a media
player), interaction with other parts of user session.

> If you want to run kodi as user service, then assign your user the
> resources you want to assign to kodi, and then distribute them from
> there to kodi, and reduce it for the rest.

  This user has a bunch of other things running (compilation, emails,
batch jobs, torrents). I want Kodi to be isolated from the interference.
Slices/scopes (are they different? Manpage descriptions of them seem to say the
same things using slightly different words) should do the trick.

 P.S. I'm sorry for hijacking original poster's thread.

-- 
Tomasz Torcz                                                       72->|   80->|
tomek at pipebreaker.pl                                               72->|   80->|



More information about the systemd-devel mailing list