cgroup: Add CPUSetPartition= setting

Add support for configuring cpuset partition type via the
CPUSetPartition= unit file setting. This controls the kernel's
cpuset.cpus.partition cgroup attribute.

The setting takes one of "member", "root", or "isolated". This is
useful for real-time workloads that require dedicated CPU resources
without interference from other processes.

When set, systemd will write the partition type to the
cpuset.cpus.partition cgroup file. If the kernel rejects the value
(e.g., due to partition hierarchy rules), a warning is logged and the
unit continues with the kernel's default partition type.

Co-developed-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
This commit is contained in:
glemco
2026-05-14 08:55:44 +02:00
parent 8e6ad359e3
commit 43b53679da
14 changed files with 209 additions and 12 deletions
+54 -12
View File
@@ -3010,6 +3010,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly ay StartupAllowedMemoryNodes = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s CPUSetPartition = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b IOAccounting = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t IOWeight = ...;
@@ -3689,6 +3691,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
<!--property StartupAllowedMemoryNodes is not documented!-->
<!--property CPUSetPartition is not documented!-->
<!--property IOAccounting is not documented!-->
<!--property IOWeight is not documented!-->
@@ -4387,6 +4391,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
<variablelist class="dbus-property" generated="True" extra-ref="StartupAllowedMemoryNodes"/>
<variablelist class="dbus-property" generated="True" extra-ref="CPUSetPartition"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOAccounting"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOWeight"/>
@@ -5294,6 +5300,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly ay StartupAllowedMemoryNodes = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s CPUSetPartition = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b IOAccounting = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t IOWeight = ...;
@@ -5989,6 +5997,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
<!--property StartupAllowedMemoryNodes is not documented!-->
<!--property CPUSetPartition is not documented!-->
<!--property IOAccounting is not documented!-->
<!--property IOWeight is not documented!-->
@@ -6661,6 +6671,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
<variablelist class="dbus-property" generated="True" extra-ref="StartupAllowedMemoryNodes"/>
<variablelist class="dbus-property" generated="True" extra-ref="CPUSetPartition"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOAccounting"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOWeight"/>
@@ -7391,6 +7403,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly ay StartupAllowedMemoryNodes = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s CPUSetPartition = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b IOAccounting = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t IOWeight = ...;
@@ -8010,6 +8024,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
<!--property StartupAllowedMemoryNodes is not documented!-->
<!--property CPUSetPartition is not documented!-->
<!--property IOAccounting is not documented!-->
<!--property IOWeight is not documented!-->
@@ -8590,6 +8606,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
<variablelist class="dbus-property" generated="True" extra-ref="StartupAllowedMemoryNodes"/>
<variablelist class="dbus-property" generated="True" extra-ref="CPUSetPartition"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOAccounting"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOWeight"/>
@@ -9453,6 +9471,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly ay StartupAllowedMemoryNodes = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s CPUSetPartition = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b IOAccounting = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t IOWeight = ...;
@@ -10054,6 +10074,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
<!--property StartupAllowedMemoryNodes is not documented!-->
<!--property CPUSetPartition is not documented!-->
<!--property IOAccounting is not documented!-->
<!--property IOWeight is not documented!-->
@@ -10616,6 +10638,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
<variablelist class="dbus-property" generated="True" extra-ref="StartupAllowedMemoryNodes"/>
<variablelist class="dbus-property" generated="True" extra-ref="CPUSetPartition"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOAccounting"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOWeight"/>
@@ -11332,6 +11356,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly ay StartupAllowedMemoryNodes = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s CPUSetPartition = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b IOAccounting = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t IOWeight = ...;
@@ -11515,6 +11541,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
<!--property StartupAllowedMemoryNodes is not documented!-->
<!--property CPUSetPartition is not documented!-->
<!--property IOAccounting is not documented!-->
<!--property IOWeight is not documented!-->
@@ -11709,6 +11737,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
<variablelist class="dbus-property" generated="True" extra-ref="StartupAllowedMemoryNodes"/>
<variablelist class="dbus-property" generated="True" extra-ref="CPUSetPartition"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOAccounting"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOWeight"/>
@@ -11928,6 +11958,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly ay StartupAllowedMemoryNodes = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s CPUSetPartition = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b IOAccounting = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t IOWeight = ...;
@@ -12125,6 +12157,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
<!--property StartupAllowedMemoryNodes is not documented!-->
<!--property CPUSetPartition is not documented!-->
<!--property IOAccounting is not documented!-->
<!--property IOWeight is not documented!-->
@@ -12343,6 +12377,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
<variablelist class="dbus-property" generated="True" extra-ref="StartupAllowedMemoryNodes"/>
<variablelist class="dbus-property" generated="True" extra-ref="CPUSetPartition"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOAccounting"/>
<variablelist class="dbus-property" generated="True" extra-ref="IOWeight"/>
@@ -12750,8 +12786,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \
<varname>RefreshOnReload</varname>, and <varname>RootMStack</varname> were added in version 260.</para>
<para><varname>CPUPressureThresholdUSec</varname>,
<varname>CPUPressureWatch</varname>,
<varname>IOPressureThresholdUSec</varname>, and
<varname>IOPressureWatch</varname> were added in version 261.</para>
<varname>IOPressureThresholdUSec</varname>,
<varname>IOPressureWatch</varname>, and
<varname>CPUSetPartition</varname> were added in version 261.</para>
</refsect2>
<refsect2>
<title>Socket Unit Objects</title>
@@ -12824,8 +12861,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \
<varname>RootMStack</varname> were added in version 260.</para>
<para><varname>CPUPressureThresholdUSec</varname>,
<varname>CPUPressureWatch</varname>,
<varname>IOPressureThresholdUSec</varname>, and
<varname>IOPressureWatch</varname> were added in version 261.</para>
<varname>IOPressureThresholdUSec</varname>,
<varname>IOPressureWatch</varname>, and
<varname>CPUSetPartition</varname> were added in version 261.</para>
</refsect2>
<refsect2>
<title>Mount Unit Objects</title>
@@ -12893,8 +12931,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \
<varname>RootMStack</varname> were added in version 260.</para>
<para><varname>CPUPressureThresholdUSec</varname>,
<varname>CPUPressureWatch</varname>,
<varname>IOPressureThresholdUSec</varname>, and
<varname>IOPressureWatch</varname> were added in version 261.</para>
<varname>IOPressureThresholdUSec</varname>,
<varname>IOPressureWatch</varname>, and
<varname>CPUSetPartition</varname> were added in version 261.</para>
</refsect2>
<refsect2>
<title>Swap Unit Objects</title>
@@ -12960,8 +12999,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \
<varname>RootMStack</varname> were added in version 260.</para>
<para><varname>CPUPressureThresholdUSec</varname>,
<varname>CPUPressureWatch</varname>,
<varname>IOPressureThresholdUSec</varname>, and
<varname>IOPressureWatch</varname> were added in version 261.</para>
<varname>IOPressureThresholdUSec</varname>,
<varname>IOPressureWatch</varname>, and
<varname>CPUSetPartition</varname> were added in version 261.</para>
</refsect2>
<refsect2>
<title>Slice Unit Objects</title>
@@ -12997,8 +13037,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \
<para><varname>BindNetworkInterface</varname> was added in version 260.</para>
<para><varname>CPUPressureThresholdUSec</varname>,
<varname>CPUPressureWatch</varname>,
<varname>IOPressureThresholdUSec</varname>, and
<varname>IOPressureWatch</varname> were added in version 261.</para>
<varname>IOPressureThresholdUSec</varname>,
<varname>IOPressureWatch</varname>, and
<varname>CPUSetPartition</varname> were added in version 261.</para>
</refsect2>
<refsect2>
<title>Scope Unit Objects</title>
@@ -13032,8 +13073,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \
<para><varname>BindNetworkInterface</varname> was added in version 260.</para>
<para><varname>CPUPressureThresholdUSec</varname>,
<varname>CPUPressureWatch</varname>,
<varname>IOPressureThresholdUSec</varname>, and
<varname>IOPressureWatch</varname> were added in version 261.</para>
<varname>IOPressureThresholdUSec</varname>,
<varname>IOPressureWatch</varname>, and
<varname>CPUSetPartition</varname> were added in version 261.</para>
</refsect2>
<refsect2>
<title>Job Objects</title>
+22
View File
@@ -521,6 +521,28 @@ CPUWeight=20 DisableControllers=cpu / \
</listitem>
</varlistentry>
<varlistentry>
<term><varname>CPUSetPartition=</varname></term>
<listitem>
<para>Sets the <option>cpuset</option> partition type for the executed processes. Takes one
of <literal>member</literal>, <literal>root</literal>, or <literal>isolated</literal>. This setting
controls the <literal>cpuset.cpus.partition</literal> cgroup attribute.</para>
<para>When set to <literal>member</literal>, the cpuset operates in normal mode.
<literal>root</literal> creates a partition root, which can further divide CPUs among child cgroups.
<literal>isolated</literal> provides full CPU isolation, useful for real-time workloads that
require dedicated CPU resources without interference from other processes.
Defaults to the kernel default, which is <literal>member</literal>. For more details about this
control group attribute, see <ulink url="https://docs.kernel.org/admin-guide/cgroup-v2.html">
Control Groups v2</ulink>.</para>
<para>This setting requires <varname>AllowedCPUs=</varname> to also be set.</para>
<xi:include href="version-info.xml" xpointer="v261"/>
</listitem>
</varlistentry>
</variablelist>
</refsect2><refsect2><title>Process Accounting and Control</title>