diff options
author | Nick Rosbrook <nick.rosbrook@canonical.com> | 2022-04-04 15:06:07 -0400 |
---|---|---|
committer | Nick Rosbrook <nick.rosbrook@canonical.com> | 2022-04-05 09:51:25 -0400 |
commit | 030bc91cb98385904b28a839d1e04bb4160a52d2 (patch) | |
tree | 199eb4e79b045c7437ae59b667054f77fe07264d /src/oom/oomd-util.h | |
parent | c0da575a0e94e7ecae7f5f0c72dea0be853af352 (diff) | |
download | systemd-030bc91cb98385904b28a839d1e04bb4160a52d2.tar.gz |
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.
Diffstat (limited to 'src/oom/oomd-util.h')
-rw-r--r-- | src/oom/oomd-util.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/oom/oomd-util.h b/src/oom/oomd-util.h index 6aada90344..de2298f3c9 100644 --- a/src/oom/oomd-util.h +++ b/src/oom/oomd-util.h @@ -60,8 +60,8 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(OomdCGroupContext*, oomd_cgroup_context_free); * Returns -ENOMEM for allocation errors. */ int oomd_pressure_above(Hashmap *h, usec_t duration, Set **ret); -/* Returns true if the amount of memory free is below the permyriad of memory specified by `threshold_permyriad`. */ -bool oomd_mem_free_below(const OomdSystemContext *ctx, int threshold_permyriad); +/* Returns true if the amount of memory available (see proc(5)) is below the permyriad of memory specified by `threshold_permyriad`. */ +bool oomd_mem_available_below(const OomdSystemContext *ctx, int threshold_permyriad); /* Returns true if the amount of swap free is below the permyriad of swap specified by `threshold_permyriad`. */ bool oomd_swap_free_below(const OomdSystemContext *ctx, int threshold_permyriad); |