summaryrefslogtreecommitdiff
path: root/src/oom/oomd-util.c
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@canonical.com>2021-05-14 08:08:33 -0400
committerDan Streetman <ddstreet@canonical.com>2021-05-20 15:40:29 -0400
commit135400276c2b8262d2946bfa1369ae46055d664b (patch)
treeca04cd9c774803ccd4fcc4c8149018331df08e94 /src/oom/oomd-util.c
parent0de2fd18705caa49fc1179e241cd2fbb22bd42e3 (diff)
downloadsystemd-135400276c2b8262d2946bfa1369ae46055d664b.tar.gz
oom: log one-time warning if kernel doesn't provide memory.swap.current
The kernel can be compiled without support for any memory.swap.* files, or it can be disabled at boot time with the 'swapaccount=0' boot parameter, so if the file doesn't exist log warning indicating the kernel doesn't support the file and the user may need to try using the 'swapaccount=1' boot param. Note that the actual error from the call to fopen() is ENOENT, but that is translated into ENODATA in cg_get_attribute_as_uint64()
Diffstat (limited to 'src/oom/oomd-util.c')
-rw-r--r--src/oom/oomd-util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c
index 5bf81479c9..0550ac6c74 100644
--- a/src/oom/oomd-util.c
+++ b/src/oom/oomd-util.c
@@ -333,7 +333,11 @@ int oomd_cgroup_context_acquire(const char *path, OomdCGroupContext **ret) {
return log_debug_errno(r, "Error getting memory.low from %s: %m", path);
r = cg_get_attribute_as_uint64(SYSTEMD_CGROUP_CONTROLLER, path, "memory.swap.current", &ctx->swap_usage);
- if (r < 0)
+ if (r == -ENODATA)
+ /* The kernel can be compiled without support for memory.swap.* files,
+ * or it can be disabled with boot param 'swapaccount=0' */
+ log_once(LOG_WARNING, "No kernel support for memory.swap.current from %s (try boot param swapaccount=1), ignoring.", path);
+ else if (r < 0)
return log_debug_errno(r, "Error getting memory.swap.current from %s: %m", path);
r = cg_get_keyed_attribute(SYSTEMD_CGROUP_CONTROLLER, path, "memory.stat", STRV_MAKE("pgscan"), &val);