From: Lennart Poettering Date: Tue, 20 Nov 2018 19:18:07 +0000 (+0100) Subject: cgroup: add a new macro for determining log level for cgroup attr write failures X-Git-Tag: v240~225^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39b9fefb2e9b281e6c7d7fe44927700db2601140;p=thirdparty%2Fsystemd.git cgroup: add a new macro for determining log level for cgroup attr write failures For now, let's use it only at one place, but a follow-up commit will make more use of it. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 8f63f4ba5a1..952c9a9f2db 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -26,6 +26,11 @@ #define CGROUP_CPU_QUOTA_PERIOD_USEC ((usec_t) 100 * USEC_PER_MSEC) +/* Returns the log level to use when cgroup attribute writes fail. When an attribute is missing or we have access + * problems we downgrade to LOG_DEBUG. This is supposed to be nice to container managers and kernels which want to mask + * out specific attributes from us. */ +#define LOG_LEVEL_CGROUP_WRITE(r) (IN_SET(abs(r), ENOENT, EROFS, EACCES, EPERM) ? LOG_DEBUG : LOG_WARNING) + bool manager_owns_root_cgroup(Manager *m) { assert(m); @@ -1156,7 +1161,7 @@ static void cgroup_context_apply( r = 0; if (r < 0) - log_unit_full(u, IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, + log_unit_full(u, LOG_LEVEL_CGROUP_WRITE(r), r, "Failed to write to tasks limit sysctls: %m"); } else {