From f585cec7dc4ff8477c7463484752f6300ab5aa3b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 9 Mar 2021 20:08:25 -0800 Subject: [PATCH] libct/cg/v2: always enable TasksAccounting This unconditionally enables TasksAccounting for systemd unified (v2) cgroup driver, making it work the same way as the legacy (v1) driver. Practically, it is probably a no-op since DefaultTasksAccounting is usually true. Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/systemd/v1.go | 3 ++- libcontainer/cgroups/systemd/v2.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libcontainer/cgroups/systemd/v1.go b/libcontainer/cgroups/systemd/v1.go index 59a8b1e72..17df7cca3 100644 --- a/libcontainer/cgroups/systemd/v1.go +++ b/libcontainer/cgroups/systemd/v1.go @@ -158,7 +158,8 @@ func (m *legacyManager) Apply(pid int) error { newProp("MemoryAccounting", true), newProp("CPUAccounting", true), newProp("BlockIOAccounting", true), - newProp("TasksAccounting", true)) + newProp("TasksAccounting", true), + ) // Assume DefaultDependencies= will always work (the check for it was previously broken.) properties = append(properties, diff --git a/libcontainer/cgroups/systemd/v2.go b/libcontainer/cgroups/systemd/v2.go index 65abc0592..a4ec752ed 100644 --- a/libcontainer/cgroups/systemd/v2.go +++ b/libcontainer/cgroups/systemd/v2.go @@ -141,7 +141,6 @@ func unifiedResToSystemdProps(conn *systemdDbus.Conn, res map[string]string) (pr } } props = append(props, - newProp("TasksAccounting", true), newProp("TasksMax", num)) case "memory.oom.group": @@ -272,7 +271,9 @@ func (m *unifiedManager) Apply(pid int) error { properties = append(properties, newProp("MemoryAccounting", true), newProp("CPUAccounting", true), - newProp("IOAccounting", true)) + newProp("IOAccounting", true), + newProp("TasksAccounting", true), + ) // Assume DefaultDependencies= will always work (the check for it was previously broken.) properties = append(properties,