]> git.ipfire.org Git - thirdparty/systemd.git/commit
oomd: calculate 'used' memory with MemAvailable instead of MemFree 22965/head
authorNick Rosbrook <nick.rosbrook@canonical.com>
Mon, 4 Apr 2022 19:06:07 +0000 (15:06 -0400)
committerNick Rosbrook <nick.rosbrook@canonical.com>
Tue, 5 Apr 2022 13:51:25 +0000 (09:51 -0400)
commit030bc91cb98385904b28a839d1e04bb4160a52d2
tree199eb4e79b045c7437ae59b667054f77fe07264d
parentc0da575a0e94e7ecae7f5f0c72dea0be853af352
oomd: calculate 'used' memory with MemAvailable instead of MemFree

The calculation for used memory in oomd_system_context_acquire is given
by MemTotal - MemFree from /proc/meminfo. This is too strict of a
calculation because it does not consider memory that is still available
for starting new applictions without swapping (MemAvailable). As a
result, systemd-oomd can start to kill processes before it is necessary.
This is more apparent on systems with low swap space.

Instead, compute 'used' memory as MemTotal - MemAvailable in
oomd_system_context_acquire and procfs_memory_get (which is used by
oomd_cgroup_context_acquire). And, rename oomd_mem_free_below to
oomd_mem_available_below for clarity.
src/basic/procfs-util.c
src/oom/oomd-manager.c
src/oom/oomd-util.c
src/oom/oomd-util.h
src/oom/test-oomd-util.c