teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0435-cgroup-freezer-action-must-be-NOP-when-cgroup-v2-fre.patch

bd1529
From 45d093a37b6f8c2ceae9bfd090c5265f35413b46 Mon Sep 17 00:00:00 2001
bd1529
From: =?UTF-8?q?Michal=20Sekleta=CC=81r?= <msekleta@redhat.com>
bd1529
Date: Tue, 8 Sep 2020 14:51:39 +0200
bd1529
Subject: [PATCH] cgroup: freezer action must be NOP when cgroup v2 freezer is
bd1529
 not available
bd1529
bd1529
Low-level cgroup freezer state manipulation is invoked directly from the
bd1529
job engine when we are about to execute the job in order to make sure
bd1529
the unit is not frozen and job execution is not blocked because of
bd1529
that.
bd1529
bd1529
Currently with cgroup v1 we would needlessly do a bunch of work in the
bd1529
function and even falsely update the freezer state. Don't do any of this
bd1529
and skip the function silently when v2 freezer is not available.
bd1529
bd1529
Following bug is fixed by this commit,
bd1529
bd1529
$ systemd-run --unit foo.service /bin/sleep infinity
bd1529
$ systemctl restart foo.service
bd1529
$ systemctl show -p FreezerState foo.service
bd1529
bd1529
Before (cgroup v1, i.e. full "legacy" mode):
bd1529
FreezerState=thawing
bd1529
bd1529
After:
bd1529
FreezerState=running
bd1529
bd1529
(cherry picked from commit 9a1e90aee556b7a30d87553a891a4175ae77ed68)
bd1529
bd1529
Resolves: #1868831
bd1529
---
bd1529
 src/core/cgroup.c | 3 +++
bd1529
 1 file changed, 3 insertions(+)
bd1529
bd1529
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
bd1529
index e0eb184fd2..f1ce070f9a 100644
bd1529
--- a/src/core/cgroup.c
bd1529
+++ b/src/core/cgroup.c
bd1529
@@ -2936,6 +2936,9 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
bd1529
         assert(u);
bd1529
         assert(IN_SET(action, FREEZER_FREEZE, FREEZER_THAW));
bd1529
 
bd1529
+        if (!cg_freezer_supported())
bd1529
+                return 0;
bd1529
+
bd1529
         if (!u->cgroup_realized)
bd1529
                 return -EBUSY;
bd1529