[systemd-devel] Setting Environment Configuration (Affinity) for Slices
Lennart Poettering
lennart at poettering.net
Mon Oct 19 11:15:00 PDT 2015
On Mon, 19.10.15 17:37, Chris Bell (cwbell at narmos.org) wrote:
> >I was mostly wondering about the env var issue you raised...
> >
> >>I also think it would be convenient in some cases to be able to use the
> >>'Nice' and 'Private{Network,Devices,etc}' directives apply to an entire
> >>slice. That way I can use slices to control, manage, and group related
> >>services. (Example: I'd like to manage postfix and dovecot together in
> >>system-mail.slice. I'd like to be able to use the slice to set exec
> >>options
> >>for both services. Then if I add another service to system-mail.slice,
> >>it
> >>would also automatically be constrained by the limits set in
> >>system-mail.slice.)
> >
> >Use CPUShares= as per-slice/per-service/per-scope equivalent of
> >Nice=.
> >
> >PrivateXYZ= otoh is very specific to what a daemon does, it's a
> >sandboxing feature, and sandboxes must always be adjusted to the
> >individual daemons. I doubt that this is something to support as
> >anything but a service-specific knob.
> >
> >Lennart
>
> Ok, so it seems like most of what I've been trying to implement is available
> in some form, just not how I was expecting. I'll take another look at the
> Resource Control directives and see how to adjust them for my needs. It's
> not as direct as I was hoping, but they seem like they'll do what I need.
>
> If I have a set of services that really need to be finely controlled I
> should probably just run them in a container, and set limits for the
> container. Will that work as I am expecting? Will a systemd-nspawn container
> respect CPUAffinity settings from the service override file?
CPUAffinity= is generally inherited down the process tree. Hence yes,
this will work. But do note that processes may freely readjust ther
own affinity using sched_setaffinity() at any time, and thus are free
to undo the setting. Hooking up cpuset with systemd as proposed this
is not possible anymore. Also, if you we hook up cpuset then it's easy
to readjust the cpuset stuff dynmaically at runtime.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list