summaryrefslogtreecommitdiffstats
path: root/src/oom/oomd-manager.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-10-08 05:26:52 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-10-08 22:36:11 +0200
commit05314b18233a6f936915aa39c29aef85a402c483 (patch)
tree4dbfaa5e96de6cb18dbfa9b51d680e0ddcf09c04 /src/oom/oomd-manager.c
parentoomd: drop unused usec_now (diff)
downloadsystemd-05314b18233a6f936915aa39c29aef85a402c483.tar.xz
systemd-05314b18233a6f936915aa39c29aef85a402c483.zip
oomd: update system context when oomctl is invoked
Otherwise, oomctl shows 0 memory and swap usage when swap monitoring is not enabled. ======= $ oomctl Dry Run: no Swap Used Limit: 90.00% Default Memory Pressure Limit: 60.00% Default Memory Pressure Duration: 20s System Context: Memory: Used: 0B Total: 0B Swap: Used: 0B Total: 0B Swap Monitored CGroups: Memory Pressure Monitored CGroups: ... ======
Diffstat (limited to '')
-rw-r--r--src/oom/oomd-manager.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/oom/oomd-manager.c b/src/oom/oomd-manager.c
index 5e25daadcb..6ff4d98c32 100644
--- a/src/oom/oomd-manager.c
+++ b/src/oom/oomd-manager.c
@@ -799,10 +799,17 @@ int manager_get_dump_string(Manager *m, char **ret) {
_cleanup_(memstream_done) MemStream ms = {};
OomdCGroupContext *c;
FILE *f;
+ int r;
assert(m);
assert(ret);
+ /* Always reread memory/swap info here. Otherwise it may be outdated if swap monitoring is off.
+ * Let's make sure to always report up-to-date data. */
+ r = oomd_system_context_acquire("/proc/meminfo", &m->system_context);
+ if (r < 0)
+ log_debug_errno(r, "Failed to acquire system context, ignoring: %m");
+
f = memstream_init(&ms);
if (!f)
return -ENOMEM;