]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: always enable CPU accounting 37448/head
authorMike Yuan <me@yhndnzj.com>
Mon, 14 Apr 2025 12:07:59 +0000 (14:07 +0200)
committerMike Yuan <me@yhndnzj.com>
Thu, 15 May 2025 00:19:16 +0000 (02:19 +0200)
Our baseline is v5.4 and cgroup v2 is enforced now,
which means CPU accounting is cheap everywhere without
requiring any controller, hence just remove the directive.

26 files changed:
man/org.freedesktop.systemd1.xml
man/systemd-cgtop.xml
man/systemd-system.conf.xml
man/systemd.resource-control.xml
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/core/cgroup.c
src/core/cgroup.h
src/core/dbus-cgroup.c
src/core/dbus-manager.c
src/core/execute-serialize.c
src/core/load-fragment-gperf.gperf.in
src/core/main.c
src/core/manager-varlink.c
src/core/manager.c
src/core/manager.h
src/core/slice.c
src/core/system.conf.in
src/core/unit.c
src/shared/bus-get-properties.c
src/shared/bus-get-properties.h
src/shared/varlink-io.systemd.Manager.c
src/test/test-cgroup-mask.c
test/units/TEST-26-SYSTEMCTL.sh
test/units/TEST-55-OOMD-workload.slice
test/units/daughter.service

index 4c6b1a54d1519a93bd7c788faf83d8f3bcdacd75..384d0aa3301a572f32801e8d6887005ccd673512 100644 (file)
@@ -469,8 +469,6 @@ node /org/freedesktop/systemd1 {
       @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
       readonly u DefaultStartLimitBurst = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
-      readonly b DefaultCPUAccounting = ...;
-      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
       readonly b DefaultIOAccounting = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
       readonly b DefaultIPAccounting = ...;
@@ -707,8 +705,6 @@ node /org/freedesktop/systemd1 {
 
     <!--property DefaultStartLimitBurst is not documented!-->
 
-    <!--property DefaultCPUAccounting is not documented!-->
-
     <!--property DefaultIOAccounting is not documented!-->
 
     <!--property DefaultIPAccounting is not documented!-->
@@ -1151,8 +1147,6 @@ node /org/freedesktop/systemd1 {
 
     <variablelist class="dbus-property" generated="True" extra-ref="DefaultStartLimitBurst"/>
 
-    <variablelist class="dbus-property" generated="True" extra-ref="DefaultCPUAccounting"/>
-
     <variablelist class="dbus-property" generated="True" extra-ref="DefaultIOAccounting"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="DefaultIPAccounting"/>
@@ -2884,8 +2878,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly s DelegateSubgroup = '...';
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
-      readonly b CPUAccounting = ...;
-      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t CPUWeight = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t StartupCPUWeight = ...;
@@ -3525,8 +3517,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
 
     <!--property DelegateControllers is not documented!-->
 
-    <!--property CPUAccounting is not documented!-->
-
     <!--property CPUWeight is not documented!-->
 
     <!--property StartupCPUWeight is not documented!-->
@@ -4179,8 +4169,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
 
     <variablelist class="dbus-property" generated="True" extra-ref="DelegateSubgroup"/>
 
-    <variablelist class="dbus-property" generated="True" extra-ref="CPUAccounting"/>
-
     <variablelist class="dbus-property" generated="True" extra-ref="CPUWeight"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="StartupCPUWeight"/>
@@ -5037,8 +5025,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly s DelegateSubgroup = '...';
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
-      readonly b CPUAccounting = ...;
-      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t CPUWeight = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t StartupCPUWeight = ...;
@@ -5690,8 +5676,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
 
     <!--property DelegateControllers is not documented!-->
 
-    <!--property CPUAccounting is not documented!-->
-
     <!--property CPUWeight is not documented!-->
 
     <!--property StartupCPUWeight is not documented!-->
@@ -6316,8 +6300,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
 
     <variablelist class="dbus-property" generated="True" extra-ref="DelegateSubgroup"/>
 
-    <variablelist class="dbus-property" generated="True" extra-ref="CPUAccounting"/>
-
     <variablelist class="dbus-property" generated="True" extra-ref="CPUWeight"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="StartupCPUWeight"/>
@@ -7006,8 +6988,6 @@ node /org/freedesktop/systemd1/unit/home_2emount {
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly s DelegateSubgroup = '...';
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
-      readonly b CPUAccounting = ...;
-      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t CPUWeight = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t StartupCPUWeight = ...;
@@ -7589,8 +7569,6 @@ node /org/freedesktop/systemd1/unit/home_2emount {
 
     <!--property DelegateControllers is not documented!-->
 
-    <!--property CPUAccounting is not documented!-->
-
     <!--property CPUWeight is not documented!-->
 
     <!--property StartupCPUWeight is not documented!-->
@@ -8131,8 +8109,6 @@ node /org/freedesktop/systemd1/unit/home_2emount {
 
     <variablelist class="dbus-property" generated="True" extra-ref="DelegateSubgroup"/>
 
-    <variablelist class="dbus-property" generated="True" extra-ref="CPUAccounting"/>
-
     <variablelist class="dbus-property" generated="True" extra-ref="CPUWeight"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="StartupCPUWeight"/>
@@ -8948,8 +8924,6 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly s DelegateSubgroup = '...';
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
-      readonly b CPUAccounting = ...;
-      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t CPUWeight = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t StartupCPUWeight = ...;
@@ -9513,8 +9487,6 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
 
     <!--property DelegateControllers is not documented!-->
 
-    <!--property CPUAccounting is not documented!-->
-
     <!--property CPUWeight is not documented!-->
 
     <!--property StartupCPUWeight is not documented!-->
@@ -10037,8 +10009,6 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
 
     <variablelist class="dbus-property" generated="True" extra-ref="DelegateSubgroup"/>
 
-    <variablelist class="dbus-property" generated="True" extra-ref="CPUAccounting"/>
-
     <variablelist class="dbus-property" generated="True" extra-ref="CPUWeight"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="StartupCPUWeight"/>
@@ -10713,8 +10683,6 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly s DelegateSubgroup = '...';
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
-      readonly b CPUAccounting = ...;
-      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t CPUWeight = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t StartupCPUWeight = ...;
@@ -10894,8 +10862,6 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
 
     <!--property DelegateControllers is not documented!-->
 
-    <!--property CPUAccounting is not documented!-->
-
     <!--property CPUWeight is not documented!-->
 
     <!--property StartupCPUWeight is not documented!-->
@@ -11082,8 +11048,6 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
 
     <variablelist class="dbus-property" generated="True" extra-ref="DelegateSubgroup"/>
 
-    <variablelist class="dbus-property" generated="True" extra-ref="CPUAccounting"/>
-
     <variablelist class="dbus-property" generated="True" extra-ref="CPUWeight"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="StartupCPUWeight"/>
@@ -11295,8 +11259,6 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly s DelegateSubgroup = '...';
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
-      readonly b CPUAccounting = ...;
-      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t CPUWeight = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t StartupCPUWeight = ...;
@@ -11490,8 +11452,6 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
 
     <!--property DelegateControllers is not documented!-->
 
-    <!--property CPUAccounting is not documented!-->
-
     <!--property CPUWeight is not documented!-->
 
     <!--property StartupCPUWeight is not documented!-->
@@ -11702,8 +11662,6 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
 
     <variablelist class="dbus-property" generated="True" extra-ref="DelegateSubgroup"/>
 
-    <variablelist class="dbus-property" generated="True" extra-ref="CPUAccounting"/>
-
     <variablelist class="dbus-property" generated="True" extra-ref="CPUWeight"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="StartupCPUWeight"/>
index 9ed60e2edc6adc06cae398d19cd77f158d705397..d734ccd283baa937f4ee0263d6518ae002ad75f7 100644 (file)
     given, is honored. This mode is suitable for scripting.</para>
 
     <para>Resource usage is only accounted for control groups with the appropriate controllers turned on:
-    <literal>cpu</literal> controller for CPU usage, <literal>memory</literal> controller for memory usage,
-    and <literal>io</literal> controller for disk I/O consumption. If resource monitoring for these resources
-    is required, it is recommended to add the <varname>CPUAccounting=1</varname>,
-    <varname>MemoryAccounting=1</varname> and <varname>IOAccounting=1</varname> settings in the unit files in
-    question. See
+    <literal>memory</literal> controller for memory usage and <literal>io</literal> controller for disk I/O consumption.
+    If resource monitoring for these resources is required, it is recommended to add the <varname>MemoryAccounting=1</varname>
+    and <varname>IOAccounting=1</varname> settings in the unit files in question. See
     <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
     for details.</para>
 
     the CPU load value is going to be between 0% and 800%. The number of
     processors can be found in <literal>/proc/cpuinfo</literal>.</para>
 
-    <para>To emphasize: unless <literal>CPUAccounting=1</literal>, <literal>MemoryAccounting=1</literal>, and
-    <literal>IOAccounting=1</literal> are enabled for the services in question, no resource accounting will
-    be available for system services and the data shown by <command>systemd-cgtop</command> will be
-    incomplete.</para>
+    <para>To emphasize: unless <literal>MemoryAccounting=1</literal> and <literal>IOAccounting=1</literal>
+    are enabled for the services in question, no resource accounting will be available for system services
+    and the data shown by <command>systemd-cgtop</command> will be incomplete.</para>
   </refsect1>
 
   <refsect1>
index b42a49f64360349c567d48ec6f51b80671164dc4..23c422df807257eda1c413a3ec30462136f60640 100644 (file)
       </varlistentry>
 
       <varlistentry>
-        <term><varname>DefaultCPUAccounting=</varname></term>
         <term><varname>DefaultMemoryAccounting=</varname></term>
         <term><varname>DefaultTasksAccounting=</varname></term>
         <term><varname>DefaultIOAccounting=</varname></term>
 
         <listitem>
         <para>Configure the default resource accounting settings, as configured per-unit by
-        <varname>CPUAccounting=</varname>, <varname>MemoryAccounting=</varname>,
-        <varname>TasksAccounting=</varname>, <varname>IOAccounting=</varname> and
-        <varname>IPAccounting=</varname>. See
+        <varname>MemoryAccounting=</varname>, <varname>TasksAccounting=</varname>, <varname>IOAccounting=</varname>,
+        and <varname>IPAccounting=</varname>. See
         <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
         for details on the per-unit settings.</para>
 
-        <para><varname>DefaultCPUAccounting=</varname> defaults to yes when running on kernel ≥4.15, and no on older versions.
-        <varname>DefaultMemoryAccounting=</varname> defaults to &MEMORY_ACCOUNTING_DEFAULT;.
+        <para><varname>DefaultMemoryAccounting=</varname> defaults to &MEMORY_ACCOUNTING_DEFAULT;.
         <varname>DefaultTasksAccounting=</varname> defaults to yes.
         The other settings default to no.</para>
 
           to the unified cgroup hierarchy.</para></listitem>
         </varlistentry>
       </variablelist>
+
+      <variablelist>
+        <varlistentry>
+          <term>systemd 258</term>
+
+          <listitem><para><varname>DefaultCPUAccounting=</varname> setting is deprecated, because CPU accounting
+          is always available on the unified cgroup hierarchy and such setting has no effect.</para></listitem>
+        </varlistentry>
+      </variablelist>
   </refsect1>
 
   <refsect1>
index aefee94cac577887562fe3fe73f59fb86e06b228..07c2f617ca63f53fc84228075d86dcbccedf87eb 100644 (file)
@@ -179,30 +179,10 @@ CPUWeight=20   DisableControllers=cpu              /          \
 
     <para>Units of the types listed above can have settings for resource control configuration:</para>
 
-    <refsect2><title>CPU Accounting and Control</title>
+    <refsect2><title>CPU Control</title>
 
     <variablelist class='unit-directives'>
 
-      <varlistentry>
-        <term><varname>CPUAccounting=</varname></term>
-
-        <listitem>
-          <para>Turn on CPU usage accounting for this unit. Takes a
-          boolean argument. Note that turning on CPU accounting for
-          one unit will also implicitly turn it on for all units
-          contained in the same slice and for all its parent slices
-          and the units contained therein. The system default for this
-          setting may be controlled with
-          <varname>DefaultCPUAccounting=</varname> in
-          <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
-
-          <para>Under the unified cgroup hierarchy, CPU accounting is available for all units and this
-          setting has no effect.</para>
-
-          <xi:include href="version-info.xml" xpointer="v208"/>
-        </listitem>
-      </varlistentry>
-
       <varlistentry>
         <term><varname>CPUWeight=<replaceable>weight</replaceable></varname></term>
         <term><varname>StartupCPUWeight=<replaceable>weight</replaceable></varname></term>
@@ -1707,6 +1687,15 @@ DeviceAllow=/dev/loop-control
           Please switch to the unified cgroup hierarchy.</para></listitem>
         </varlistentry>
       </variablelist>
+
+      <variablelist>
+        <varlistentry>
+          <term>systemd 258</term>
+
+          <listitem><para><varname>CPUAccounting=</varname> setting is deprecated, because it is always available
+          on the unified cgroup hierarchy and such setting has no effect.</para></listitem>
+        </varlistentry>
+      </variablelist>
   </refsect1>
 
   <refsect1>
index cd13b705195f076a9b5af7805a4f1c483562fcca..3287c11f7da25a5fcf5ec2ac6b5bb5dc42757d37 100644 (file)
@@ -2181,57 +2181,6 @@ static const char *const cgroup_controller_table[_CGROUP_CONTROLLER_MAX] = {
 
 DEFINE_STRING_TABLE_LOOKUP(cgroup_controller, CGroupController);
 
-CGroupMask get_cpu_accounting_mask(void) {
-        static CGroupMask needed_mask = (CGroupMask) -1;
-
-        /* On kernel ≥4.15 with unified hierarchy, cpu.stat's usage_usec is
-         * provided externally from the CPU controller, which means we don't
-         * need to enable the CPU controller just to get metrics. This is good,
-         * because enabling the CPU controller comes at a minor performance
-         * hit, especially when it's propagated deep into large hierarchies.
-         * There's also no separate CPU accounting controller available within
-         * a unified hierarchy.
-         *
-         * This combination of factors results in the desired cgroup mask to
-         * enable for CPU accounting varying as follows:
-         *
-         *                   ╔═════════════════════╤═════════════════════╗
-         *                   ║     Linux ≥4.15     │     Linux <4.15     ║
-         *   ╔═══════════════╬═════════════════════╪═════════════════════╣
-         *   ║ Unified       ║ nothing             │ CGROUP_MASK_CPU     ║
-         *   ╟───────────────╫─────────────────────┼─────────────────────╢
-         *   ║ Hybrid/Legacy ║ CGROUP_MASK_CPUACCT │ CGROUP_MASK_CPUACCT ║
-         *   ╚═══════════════╩═════════════════════╧═════════════════════╝
-         *
-         * We check kernel version here instead of manually checking whether
-         * cpu.stat is present for every cgroup, as that check in itself would
-         * already be fairly expensive.
-         *
-         * Kernels where this patch has been backported will therefore have the
-         * CPU controller enabled unnecessarily. This is more expensive than
-         * necessary, but harmless. ☺️
-         */
-
-        if (needed_mask == (CGroupMask) -1) {
-                if (cg_all_unified()) {
-                        struct utsname u;
-                        assert_se(uname(&u) >= 0);
-
-                        if (strverscmp_improved(u.release, "4.15") < 0)
-                                needed_mask = CGROUP_MASK_CPU;
-                        else
-                                needed_mask = 0;
-                } else
-                        needed_mask = CGROUP_MASK_CPUACCT;
-        }
-
-        return needed_mask;
-}
-
-bool cpu_accounting_is_cheap(void) {
-        return get_cpu_accounting_mask() == 0;
-}
-
 static const char* const managed_oom_mode_table[_MANAGED_OOM_MODE_MAX] = {
         [MANAGED_OOM_AUTO] = "auto",
         [MANAGED_OOM_KILL] = "kill",
index 24da02022fe3c03b5d2c2a316348dcbc3850e63f..5af7643b6f0c02d4173857944b8007712550c440 100644 (file)
@@ -86,9 +86,6 @@ static inline CGroupMask CGROUP_MASK_EXTEND_JOINED(CGroupMask mask) {
         return mask;
 }
 
-CGroupMask get_cpu_accounting_mask(void);
-bool cpu_accounting_is_cheap(void);
-
 /* Special values for all weight knobs on unified hierarchy */
 #define CGROUP_WEIGHT_INVALID UINT64_MAX
 #define CGROUP_WEIGHT_IDLE UINT64_C(0)
index dbab38c3c0811f2ab35991436fde793bf2327f9a..2050494a859f23acd0a6e3ddc1ad70fd4ecad7cf 100644 (file)
@@ -477,7 +477,6 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
         startup_cpuset_mems = cpu_set_to_range_string(&c->startup_cpuset_mems);
 
         fprintf(f,
-                "%sCPUAccounting: %s\n"
                 "%sIOAccounting: %s\n"
                 "%sMemoryAccounting: %s\n"
                 "%sTasksAccounting: %s\n"
@@ -516,7 +515,6 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
                 "%sManagedOOMPreference: %s\n"
                 "%sMemoryPressureWatch: %s\n"
                 "%sCoredumpReceive: %s\n",
-                prefix, yes_no(c->cpu_accounting),
                 prefix, yes_no(c->io_accounting),
                 prefix, yes_no(c->memory_accounting),
                 prefix, yes_no(c->tasks_accounting),
@@ -1698,9 +1696,6 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) {
 
         /* Figure out which controllers we need, based on the cgroup context object */
 
-        if (c->cpu_accounting)
-                mask |= get_cpu_accounting_mask();
-
         if (cgroup_context_has_cpu_weight(c) ||
             c->cpu_quota_per_sec_usec != USEC_INFINITY)
                 mask |= CGROUP_MASK_CPU;
@@ -3628,10 +3623,6 @@ static int unit_get_cpu_usage_raw(const Unit *u, const CGroupRuntime *crt, nsec_
         if (unit_has_host_root_cgroup(u))
                 return procfs_cpu_get_usage(ret);
 
-        /* Requisite controllers for CPU accounting are not enabled */
-        if ((get_cpu_accounting_mask() & ~crt->cgroup_realized_mask) != 0)
-                return -ENODATA;
-
         _cleanup_free_ char *val = NULL;
         uint64_t us;
 
@@ -3660,9 +3651,6 @@ int unit_get_cpu_usage(Unit *u, nsec_t *ret) {
          * started. If the cgroup has been removed already, returns the last cached value. To cache the value, simply
          * call this function with a NULL return value. */
 
-        if (!UNIT_CGROUP_BOOL(u, cpu_accounting))
-                return -ENODATA;
-
         CGroupRuntime *crt = unit_get_cgroup_runtime(u);
         if (!crt)
                 return -ENODATA;
index 88e908515243f2c4cc0dfe48660d8a24bbbca131..bdd4a2236bb12fbb8b29b75c5e70fa298a1617f7 100644 (file)
@@ -123,7 +123,6 @@ typedef enum CGroupPressureWatch {
  * manager is running (except for an occasional SetProperty() configuration change), outside of reload
  * cycles. */
 struct CGroupContext {
-        bool cpu_accounting;
         bool io_accounting;
         bool memory_accounting;
         bool tasks_accounting;
index 713bd30265c41348cde3ab80b1a6a266533f5c59..326c440cf9f6b38a2c3393dd4c149105387c8c36 100644 (file)
@@ -384,7 +384,6 @@ const sd_bus_vtable bus_cgroup_vtable[] = {
         SD_BUS_PROPERTY("Delegate", "b", bus_property_get_bool, offsetof(CGroupContext, delegate), 0),
         SD_BUS_PROPERTY("DelegateControllers", "as", property_get_delegate_controllers, 0, 0),
         SD_BUS_PROPERTY("DelegateSubgroup", "s", NULL, offsetof(CGroupContext, delegate_subgroup), 0),
-        SD_BUS_PROPERTY("CPUAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpu_accounting), 0),
         SD_BUS_PROPERTY("CPUWeight", "t", NULL, offsetof(CGroupContext, cpu_weight), 0),
         SD_BUS_PROPERTY("StartupCPUWeight", "t", NULL, offsetof(CGroupContext, startup_cpu_weight), 0),
         SD_BUS_PROPERTY("CPUQuotaPerSecUSec", "t", bus_property_get_usec, offsetof(CGroupContext, cpu_quota_per_sec_usec), 0),
@@ -441,6 +440,7 @@ const sd_bus_vtable bus_cgroup_vtable[] = {
         SD_BUS_PROPERTY("MemoryPressureThresholdUSec", "t", bus_property_get_usec, offsetof(CGroupContext, memory_pressure_threshold_usec), 0),
         SD_BUS_PROPERTY("NFTSet", "a(iiss)", property_get_cgroup_nft_set, 0, 0),
         SD_BUS_PROPERTY("CoredumpReceive", "b", bus_property_get_bool, offsetof(CGroupContext, coredump_receive), 0),
+
         /* deprecated cgroup v1 properties */
         SD_BUS_PROPERTY("MemoryLimit", "t", bus_property_get_uint64_max, 0, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_HIDDEN),
         SD_BUS_PROPERTY("CPUShares", "t", bus_property_get_uint64_max, 0, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_HIDDEN),
@@ -451,6 +451,9 @@ const sd_bus_vtable bus_cgroup_vtable[] = {
         SD_BUS_PROPERTY("BlockIODeviceWeight", "a(st)", property_get_blockio_ast, 0, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_HIDDEN),
         SD_BUS_PROPERTY("BlockIOReadBandwidth", "a(st)", property_get_blockio_ast, 0, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_HIDDEN),
         SD_BUS_PROPERTY("BlockIOWriteBandwidth", "a(st)", property_get_blockio_ast, 0, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_HIDDEN),
+        /* since kernel v4.15 CPU accounting requires no controller, i.e. is available everywhere */
+        SD_BUS_PROPERTY("CPUAccounting", "b", bus_property_get_bool_true, 0, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_HIDDEN),
+
         SD_BUS_VTABLE_END
 };
 
@@ -1038,9 +1041,6 @@ int bus_cgroup_set_property(
 
         flags |= UNIT_PRIVATE;
 
-        if (streq(name, "CPUAccounting"))
-                return bus_cgroup_set_boolean(u, name, &c->cpu_accounting, get_cpu_accounting_mask(), message, flags, error);
-
         if (streq(name, "CPUWeight"))
                 return bus_cgroup_set_cpu_weight(u, name, &c->cpu_weight, message, flags, error);
 
@@ -2038,7 +2038,8 @@ int bus_cgroup_set_property(
                        "StartupBlockIOWeight",
                        "BlockIODeviceWeight",
                        "BlockIOReadBandwidth",
-                       "BlockIOWriteBandwidth")) {
+                       "BlockIOWriteBandwidth",
+                       "CPUAccounting")) { /* see comment in bus_cgroup_vtable */
 
                 r = sd_bus_message_skip(message, NULL);
                 if (r < 0)
index b2705e04ce5ec15030a6fbd387af491863f3e75c..24b08b1a5d3c4236b38cbc0f0ce71248949d3db9 100644 (file)
@@ -2887,7 +2887,6 @@ const sd_bus_vtable bus_manager_vtable[] = {
         SD_BUS_PROPERTY("DefaultStartLimitIntervalSec", "t", bus_property_get_usec, offsetof(Manager, defaults.start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
         SD_BUS_PROPERTY("DefaultStartLimitInterval", "t", bus_property_get_usec, offsetof(Manager, defaults.start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
         SD_BUS_PROPERTY("DefaultStartLimitBurst", "u", bus_property_get_unsigned, offsetof(Manager, defaults.start_limit.burst), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("DefaultCPUAccounting", "b", bus_property_get_bool, offsetof(Manager, defaults.cpu_accounting), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("DefaultIOAccounting", "b", bus_property_get_bool, offsetof(Manager, defaults.io_accounting), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("DefaultIPAccounting", "b", bus_property_get_bool, offsetof(Manager, defaults.ip_accounting), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("DefaultMemoryAccounting", "b", bus_property_get_bool, offsetof(Manager, defaults.memory_accounting), SD_BUS_VTABLE_PROPERTY_CONST),
@@ -2932,8 +2931,11 @@ const sd_bus_vtable bus_manager_vtable[] = {
         SD_BUS_PROPERTY("DefaultOOMScoreAdjust", "i", property_get_oom_score_adjust, 0, SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("CtrlAltDelBurstAction", "s", bus_property_get_emergency_action, offsetof(Manager, cad_burst_action), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("SoftRebootsCount", "u", bus_property_get_unsigned, offsetof(Manager, soft_reboots_count), SD_BUS_VTABLE_PROPERTY_CONST),
+
         /* deprecated cgroup v1 property */
         SD_BUS_PROPERTY("DefaultBlockIOAccounting", "b", bus_property_get_bool_false, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_HIDDEN),
+        /* see comment in bus_cgroup_vtable */
+        SD_BUS_PROPERTY("DefaultCPUAccounting", "b", bus_property_get_bool_true, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_HIDDEN),
 
         SD_BUS_METHOD_WITH_ARGS("GetUnit",
                                 SD_BUS_ARGS("s", name),
index 18ec06b6a49f8c8f7635a0fa634fb0835502cca6..2a91a6fadb19cf6e7a7337b5397deb292dd20caa 100644 (file)
@@ -34,10 +34,6 @@ static int exec_cgroup_context_serialize(const CGroupContext *c, FILE *f) {
         if (!c)
                 return 0;
 
-        r = serialize_bool_elide(f, "exec-cgroup-context-cpu-accounting", c->cpu_accounting);
-        if (r < 0)
-                return r;
-
         r = serialize_bool_elide(f, "exec-cgroup-context-io-accounting", c->io_accounting);
         if (r < 0)
                 return r;
@@ -445,12 +441,7 @@ static int exec_cgroup_context_deserialize(CGroupContext *c, FILE *f) {
                 if (r == 0) /* eof or end marker */
                         break;
 
-                if ((val = startswith(l, "exec-cgroup-context-cpu-accounting="))) {
-                        r = parse_boolean(val);
-                        if (r < 0)
-                                return r;
-                        c->cpu_accounting = r;
-                } else if ((val = startswith(l, "exec-cgroup-context-io-accounting="))) {
+                if ((val = startswith(l, "exec-cgroup-context-io-accounting="))) {
                         r = parse_boolean(val);
                         if (r < 0)
                                 return r;
index 2c0a0b629aa62df6024c85eecd11b8e221270b34..aeccf07d55b12451a6ab5c15493fd2e6475663d6 100644 (file)
 {{type}}.StartupAllowedCPUs,                  config_parse_allowed_cpuset,                        0,                                  offsetof({{type}}, cgroup_context.startup_cpuset_cpus)
 {{type}}.AllowedMemoryNodes,                  config_parse_allowed_cpuset,                        0,                                  offsetof({{type}}, cgroup_context.cpuset_mems)
 {{type}}.StartupAllowedMemoryNodes,           config_parse_allowed_cpuset,                        0,                                  offsetof({{type}}, cgroup_context.startup_cpuset_mems)
-{{type}}.CPUAccounting,                       config_parse_bool,                                  0,                                  offsetof({{type}}, cgroup_context.cpu_accounting)
+{{type}}.CPUAccounting,                       config_parse_warn_compat,                           DISABLED_LEGACY,                    0
 {{type}}.CPUWeight,                           config_parse_cg_cpu_weight,                         0,                                  offsetof({{type}}, cgroup_context.cpu_weight)
 {{type}}.StartupCPUWeight,                    config_parse_cg_cpu_weight,                         0,                                  offsetof({{type}}, cgroup_context.startup_cpu_weight)
 {{type}}.CPUShares,                           config_parse_warn_compat,                           DISABLED_LEGACY,                    0
index 3ffacc8ccc62c3a7a5edd1fe8e27d1c02a5957b3..cb846367c2f91faccd620c34a11c2b96e9af5a93 100644 (file)
@@ -791,7 +791,7 @@ static int parse_config_file(void) {
                 { "Manager", "DefaultLimitNICE",             config_parse_rlimit,                RLIMIT_NICE,              arg_defaults.rlimit               },
                 { "Manager", "DefaultLimitRTPRIO",           config_parse_rlimit,                RLIMIT_RTPRIO,            arg_defaults.rlimit               },
                 { "Manager", "DefaultLimitRTTIME",           config_parse_rlimit,                RLIMIT_RTTIME,            arg_defaults.rlimit               },
-                { "Manager", "DefaultCPUAccounting",         config_parse_bool,                  0,                        &arg_defaults.cpu_accounting      },
+                { "Manager", "DefaultCPUAccounting",         config_parse_warn_compat,           DISABLED_LEGACY,          NULL                              },
                 { "Manager", "DefaultIOAccounting",          config_parse_bool,                  0,                        &arg_defaults.io_accounting       },
                 { "Manager", "DefaultIPAccounting",          config_parse_bool,                  0,                        &arg_defaults.ip_accounting       },
                 { "Manager", "DefaultBlockIOAccounting",     config_parse_warn_compat,           DISABLED_LEGACY,          NULL                              },
index bbf2368d56dcc95e8c3525f05da164469dc852b5..f53af0998c2c512694259f45ee549c76970444b8 100644 (file)
@@ -58,7 +58,6 @@ static int manager_context_build_json(sd_json_variant **ret, const char *name, v
                         JSON_BUILD_PAIR_FINITE_USEC("DefaultDeviceTimeoutUSec", m->defaults.device_timeout_usec),
                         JSON_BUILD_PAIR_FINITE_USEC("DefaultRestartUSec", m->defaults.restart_usec),
                         JSON_BUILD_PAIR_RATELIMIT("DefaultStartLimit", &m->defaults.start_limit),
-                        SD_JSON_BUILD_PAIR_BOOLEAN("DefaultCPUAccounting", m->defaults.cpu_accounting),
                         SD_JSON_BUILD_PAIR_BOOLEAN("DefaultIOAccounting", m->defaults.io_accounting),
                         SD_JSON_BUILD_PAIR_BOOLEAN("DefaultIPAccounting", m->defaults.ip_accounting),
                         SD_JSON_BUILD_PAIR_BOOLEAN("DefaultMemoryAccounting", m->defaults.memory_accounting),
index 8e75727bfddb22b77d2ac57b01b8d818ebbf5c0b..4f6232e8ad82ceb9f3a354dd3efc82161b669b7a 100644 (file)
@@ -4197,7 +4197,6 @@ int manager_set_unit_defaults(Manager *m, const UnitDefaults *defaults) {
 
         m->defaults.start_limit = defaults->start_limit;
 
-        m->defaults.cpu_accounting = defaults->cpu_accounting;
         m->defaults.memory_accounting = defaults->memory_accounting;
         m->defaults.io_accounting = defaults->io_accounting;
         m->defaults.tasks_accounting = defaults->tasks_accounting;
@@ -5095,9 +5094,6 @@ void unit_defaults_init(UnitDefaults *defaults, RuntimeScope scope) {
                 .device_timeout_usec = manager_default_timeout(scope),
                 .start_limit = { DEFAULT_START_LIMIT_INTERVAL, DEFAULT_START_LIMIT_BURST },
 
-                /* On 4.15+ with unified hierarchy, CPU accounting is essentially free as it doesn't require the CPU
-                 * controller to be enabled, so the default is to enable it unless we got told otherwise. */
-                .cpu_accounting = cpu_accounting_is_cheap(),
                 .memory_accounting = MEMORY_ACCOUNTING_DEFAULT,
                 .io_accounting = false,
                 .tasks_accounting = true,
index 1c3eefd141dbeb86fac6a0a84ea408b796c9553a..31b4b59c0bc5e434aebf666f3baf1d94b3172648 100644 (file)
@@ -149,7 +149,6 @@ typedef struct UnitDefaults {
 
         RateLimit start_limit;
 
-        bool cpu_accounting;
         bool memory_accounting;
         bool io_accounting;
         bool tasks_accounting;
index a4a82118ddfab0a213645dc3f01294ad47528d25..361ef84a38be89227061850a04c513562440e0de 100644 (file)
@@ -334,7 +334,6 @@ static void slice_enumerate_perpetual(Manager *m) {
                  * means the kernel will track CPU/tasks/memory for us anyway, and it is all available in /proc. Let's
                  * hence turn accounting on here, so that our APIs to query this data are available. */
 
-                s->cgroup_context.cpu_accounting = true;
                 s->cgroup_context.tasks_accounting = true;
                 s->cgroup_context.memory_accounting = true;
         }
index 1c08aa4d22da745bc398327d601354bf8338085b..051a18bd21c41b44851eae9f2b1aa9c4d496b6cf 100644 (file)
@@ -54,7 +54,6 @@
 #DefaultStartLimitIntervalSec=10s
 #DefaultStartLimitBurst=5
 #DefaultEnvironment=
-#DefaultCPUAccounting=yes
 #DefaultIOAccounting=no
 #DefaultIPAccounting=no
 #DefaultMemoryAccounting={{ 'yes' if MEMORY_ACCOUNTING_DEFAULT else 'no' }}
index 7e3eaa4c92f5545d90af73c3bc79da75f1660faf..6b19947df0680ae54dec10c922c44bc2133e5191 100644 (file)
@@ -173,7 +173,6 @@ static void unit_init(Unit *u) {
                  * context, _before_ the rest of the settings have
                  * been initialized */
 
-                cc->cpu_accounting = u->manager->defaults.cpu_accounting;
                 cc->io_accounting = u->manager->defaults.io_accounting;
                 cc->memory_accounting = u->manager->defaults.memory_accounting;
                 cc->tasks_accounting = u->manager->defaults.tasks_accounting;
index de23611ac47ebf5a5d8d2c0c626c7df72011a864..5be6bbc90678ed246f630918a79ce4b30ba08409 100644 (file)
@@ -8,6 +8,7 @@
 #include "string-util.h"
 
 BUS_DEFINE_PROPERTY_GET_GLOBAL(bus_property_get_bool_false, "b", 0);
+BUS_DEFINE_PROPERTY_GET_GLOBAL(bus_property_get_bool_true, "b", 1);
 BUS_DEFINE_PROPERTY_GET_GLOBAL(bus_property_get_uint64_max, "t", UINT64_MAX);
 
 int bus_property_get_bool(
index 73e85cd2c8602edff762596ed2a3aa2649101f8e..95eab4a4bf17e3a126e8d1b659303f1158863c75 100644 (file)
@@ -5,10 +5,6 @@
 
 #include "macro.h"
 
-/* For deprecated properties. */
-int bus_property_get_bool_false(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
-int bus_property_get_uint64_max(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
-
 int bus_property_get_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
 int bus_property_set_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *error);
 int bus_property_get_tristate(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
@@ -105,3 +101,8 @@ int bus_property_get_string_set(sd_bus *bus, const char *path, const char *inter
 #define BUS_PROPERTY_DUAL_TIMESTAMP(name, offset, flags) \
         SD_BUS_PROPERTY(name, "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, realtime), (flags)), \
         SD_BUS_PROPERTY(name "Monotonic", "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, monotonic), (flags))
+
+/* For deprecated properties. */
+int bus_property_get_bool_false(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
+int bus_property_get_bool_true(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
+int bus_property_get_uint64_max(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
index 513ccb68f8c5a8667288f0f3aede762148aa3dd4..c27eff6e21b6f9d02e6a23185c5b4921845e1fe2 100644 (file)
@@ -53,8 +53,6 @@ static SD_VARLINK_DEFINE_STRUCT_TYPE(
                 SD_VARLINK_DEFINE_FIELD(DefaultRestartUSec, SD_VARLINK_INT, 0),
                 SD_VARLINK_FIELD_COMMENT("https://www.freedesktop.org/software/systemd/man/"PROJECT_VERSION_STR"/systemd-system.conf.html#DefaultStartLimit="),
                 SD_VARLINK_DEFINE_FIELD_BY_TYPE(DefaultStartLimit, RateLimit, SD_VARLINK_NULLABLE),
-                SD_VARLINK_FIELD_COMMENT("https://www.freedesktop.org/software/systemd/man/"PROJECT_VERSION_STR"/systemd-system.conf.html#DefaultCPUAccounting="),
-                SD_VARLINK_DEFINE_FIELD(DefaultCPUAccounting, SD_VARLINK_BOOL, 0),
                 SD_VARLINK_FIELD_COMMENT("https://www.freedesktop.org/software/systemd/man/"PROJECT_VERSION_STR"/systemd-system.conf.html#DefaultIOAccounting="),
                 SD_VARLINK_DEFINE_FIELD(DefaultIOAccounting, SD_VARLINK_BOOL, 0),
                 SD_VARLINK_FIELD_COMMENT("https://www.freedesktop.org/software/systemd/man/"PROJECT_VERSION_STR"/systemd-system.conf.html#DefaultIPAccounting="),
index ac70bad8ba623a849785807ce02427d6d910ce0e..f73372d6314ca8a63081ba12e512f2c849ef5d8b 100644 (file)
@@ -31,7 +31,6 @@ TEST_RET(cgroup_mask, .sd_booted = true) {
         _cleanup_(manager_freep) Manager *m = NULL;
         Unit *son, *daughter, *parent, *root, *grandchild, *parent_deep, *nomem_parent, *nomem_leaf;
         int r;
-        CGroupMask cpu_accounting_mask = get_cpu_accounting_mask();
 
         r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
@@ -53,8 +52,7 @@ TEST_RET(cgroup_mask, .sd_booted = true) {
         /* Turn off all kinds of default accounting, so that we can
          * verify the masks resulting of our configuration and nothing
          * else. */
-        m->defaults.cpu_accounting =
-                m->defaults.memory_accounting =
+        m->defaults.memory_accounting =
                 m->defaults.io_accounting =
                 m->defaults.tasks_accounting = false;
         m->defaults.tasks_max = CGROUP_TASKS_MAX_UNSET;
@@ -79,7 +77,6 @@ TEST_RET(cgroup_mask, .sd_booted = true) {
 
         /* Verify per-unit cgroups settings. */
         ASSERT_CGROUP_MASK_JOINED(unit_get_own_mask(son), CGROUP_MASK_CPU);
-        ASSERT_CGROUP_MASK_JOINED(unit_get_own_mask(daughter), cpu_accounting_mask);
         ASSERT_CGROUP_MASK_JOINED(unit_get_own_mask(grandchild), 0);
         ASSERT_CGROUP_MASK_JOINED(unit_get_own_mask(parent_deep), CGROUP_MASK_MEMORY);
         ASSERT_CGROUP_MASK_JOINED(unit_get_own_mask(parent), (CGROUP_MASK_IO | CGROUP_MASK_BLKIO));
@@ -92,40 +89,40 @@ TEST_RET(cgroup_mask, .sd_booted = true) {
         ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(daughter), 0);
         ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(grandchild), 0);
         ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(parent_deep), 0);
-        ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(parent), (CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_MEMORY));
+        ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(parent), (CGROUP_MASK_CPU | CGROUP_MASK_MEMORY));
         ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(nomem_parent), (CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
         ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(nomem_leaf), 0);
-        ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(root), (CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
+        ASSERT_CGROUP_MASK_JOINED(unit_get_members_mask(root), (CGROUP_MASK_CPU | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
 
         /* Verify aggregation of sibling masks. */
-        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(son), (CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_MEMORY));
-        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(daughter), (CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_MEMORY));
+        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(son), (CGROUP_MASK_CPU | CGROUP_MASK_MEMORY));
+        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(daughter), (CGROUP_MASK_CPU | CGROUP_MASK_MEMORY));
         ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(grandchild), 0);
-        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(parent_deep), (CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_MEMORY));
-        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(parent), (CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
+        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(parent_deep), (CGROUP_MASK_CPU | CGROUP_MASK_MEMORY));
+        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(parent), (CGROUP_MASK_CPU | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
         ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(nomem_parent), (CGROUP_MASK_CPU | CGROUP_MASK_CPUACCT | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
         ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(nomem_leaf), (CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
-        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(root), (CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
+        ASSERT_CGROUP_MASK_JOINED(unit_get_siblings_mask(root), (CGROUP_MASK_CPU | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY));
 
         /* Verify aggregation of target masks. */
-        ASSERT_CGROUP_MASK(unit_get_target_mask(son), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_MEMORY) & m->cgroup_supported));
-        ASSERT_CGROUP_MASK(unit_get_target_mask(daughter), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_MEMORY) & m->cgroup_supported));
+        ASSERT_CGROUP_MASK(unit_get_target_mask(son), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | CGROUP_MASK_MEMORY) & m->cgroup_supported));
+        ASSERT_CGROUP_MASK(unit_get_target_mask(daughter), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | CGROUP_MASK_MEMORY) & m->cgroup_supported));
         ASSERT_CGROUP_MASK(unit_get_target_mask(grandchild), 0);
-        ASSERT_CGROUP_MASK(unit_get_target_mask(parent_deep), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_MEMORY) & m->cgroup_supported));
-        ASSERT_CGROUP_MASK(unit_get_target_mask(parent), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY) & m->cgroup_supported));
+        ASSERT_CGROUP_MASK(unit_get_target_mask(parent_deep), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | CGROUP_MASK_MEMORY) & m->cgroup_supported));
+        ASSERT_CGROUP_MASK(unit_get_target_mask(parent), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY) & m->cgroup_supported));
         ASSERT_CGROUP_MASK(unit_get_target_mask(nomem_parent), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | CGROUP_MASK_CPUACCT | CGROUP_MASK_IO | CGROUP_MASK_BLKIO) & m->cgroup_supported));
         ASSERT_CGROUP_MASK(unit_get_target_mask(nomem_leaf), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_IO | CGROUP_MASK_BLKIO) & m->cgroup_supported));
-        ASSERT_CGROUP_MASK(unit_get_target_mask(root), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY) & m->cgroup_supported));
+        ASSERT_CGROUP_MASK(unit_get_target_mask(root), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY) & m->cgroup_supported));
 
         /* Verify aggregation of enable masks. */
         ASSERT_CGROUP_MASK(unit_get_enable_mask(son), 0);
         ASSERT_CGROUP_MASK(unit_get_enable_mask(daughter), 0);
         ASSERT_CGROUP_MASK(unit_get_enable_mask(grandchild), 0);
         ASSERT_CGROUP_MASK(unit_get_enable_mask(parent_deep), 0);
-        ASSERT_CGROUP_MASK(unit_get_enable_mask(parent), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_MEMORY) & m->cgroup_supported));
+        ASSERT_CGROUP_MASK(unit_get_enable_mask(parent), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | CGROUP_MASK_MEMORY) & m->cgroup_supported));
         ASSERT_CGROUP_MASK(unit_get_enable_mask(nomem_parent), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_IO | CGROUP_MASK_BLKIO) & m->cgroup_supported));
         ASSERT_CGROUP_MASK(unit_get_enable_mask(nomem_leaf), 0);
-        ASSERT_CGROUP_MASK(unit_get_enable_mask(root), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | cpu_accounting_mask | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY) & m->cgroup_supported));
+        ASSERT_CGROUP_MASK(unit_get_enable_mask(root), (CGROUP_MASK_EXTEND_JOINED(CGROUP_MASK_CPU | CGROUP_MASK_IO | CGROUP_MASK_BLKIO | CGROUP_MASK_MEMORY) & m->cgroup_supported));
 
         return 0;
 }
index 8e895aa9ae8a8413010e618755275b1d97af4a59..cc6b84498957da35cb9e7be9d09fce856266f4b7 100755 (executable)
@@ -249,12 +249,12 @@ systemctl revert "$UNIT_NAME"
 (! grep -r "IPAccounting=" "/etc/systemd/system.control/${UNIT_NAME}.d/")
 (! grep -r "MemoryMax=" "/etc/systemd/system.control/${UNIT_NAME}.d/")
 # Same stuff, but with --runtime, which should use /run
-systemctl set-property --runtime "$UNIT_NAME" CPUAccounting=no CPUQuota=10%
+systemctl set-property --runtime "$UNIT_NAME" IOAccounting=no CPUQuota=10%
 systemctl cat "$UNIT_NAME"
-grep -r "CPUAccounting=no" "/run/systemd/system.control/${UNIT_NAME}.d/"
+grep -r "IOAccounting=no" "/run/systemd/system.control/${UNIT_NAME}.d/"
 grep -r "CPUQuota=10.00%" "/run/systemd/system.control/${UNIT_NAME}.d/"
 systemctl revert "$UNIT_NAME"
-(! grep -r "CPUAccounting=" "/run/systemd/system.control/${UNIT_NAME}.d/")
+(! grep -r "IOAccounting=" "/run/systemd/system.control/${UNIT_NAME}.d/")
 (! grep -r "CPUQuota=" "/run/systemd/system.control/${UNIT_NAME}.d/")
 
 # Failed-unit related tests
index 155807360445c7f8398c98adfd51aab6498ae0a3..dae4e6ce668e29e69401dbf13fa7b38bef07b881 100644 (file)
@@ -3,7 +3,6 @@
 Description=Test slice for memory pressure kills
 
 [Slice]
-CPUAccounting=true
 MemoryAccounting=true
 IOAccounting=true
 TasksAccounting=true
index 0ee4f24a4e96b3dc4c20e98c33c60facc73d5708..bf02f8e9f69ff6431323255f34f72fc23a3f3323 100644 (file)
@@ -6,4 +6,3 @@ Description=Daughter Service
 Slice=parent.slice
 Type=oneshot
 ExecStart=true
-CPUAccounting=true