From: Yu Watanabe Date: Tue, 8 Oct 2024 03:26:52 +0000 (+0900) Subject: oomd: update system context when oomctl is invoked X-Git-Tag: v257-rc1~290^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05314b18233a6f936915aa39c29aef85a402c483;p=thirdparty%2Fsystemd.git 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: ... ====== --- diff --git a/src/oom/oomd-manager.c b/src/oom/oomd-manager.c index 5e25daadcbd..6ff4d98c32d 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;