diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-02-17 17:56:26 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-02-18 22:40:47 +0100 |
commit | d06e7fb53233bac014d1c3c9899ee291dcda1f71 (patch) | |
tree | 480cafc30a86f5374adb85dbdefab6bf0101fa39 /src/oom/oomd-util.c | |
parent | d9d3f05def0057cc064a05f8cbfb5f398779cd8c (diff) | |
download | systemd-d06e7fb53233bac014d1c3c9899ee291dcda1f71.tar.gz |
oomd: increase accuracy of SwapUsedLimit= to permyriads too
oomd.conf has two parameters with fractionals: SwapUsedLimit= and
DefaultMemoryPressureLimit=, but one accepts permyriads, the other only
percentages, for no apparent reason. One carries the "Percent" in the
name, the other doesn't.
Let's clean this up: always accept permyriads, and drop the suffix,
given that it is misleading.
I figure we should internally try to focus on scaling everything
relative to UINT32_MAX, and if that isn't in the cards at least 10000,
but never permille nor percent unless there's a really really good
reason for it (e.g. interface defined by someone else).
Diffstat (limited to 'src/oom/oomd-util.c')
-rw-r--r-- | src/oom/oomd-util.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c index 9dd9b17c6d..b054ccacc4 100644 --- a/src/oom/oomd-util.c +++ b/src/oom/oomd-util.c @@ -134,13 +134,13 @@ bool oomd_memory_reclaim(Hashmap *h) { return pgscan_of > last_pgscan_of; } -bool oomd_swap_free_below(const OomdSystemContext *ctx, uint64_t threshold_percent) { +bool oomd_swap_free_below(const OomdSystemContext *ctx, int threshold_permyriad) { uint64_t swap_threshold; assert(ctx); - assert(threshold_percent <= 100); + assert(threshold_permyriad <= 10000); - swap_threshold = ctx->swap_total * threshold_percent / ((uint64_t) 100); + swap_threshold = ctx->swap_total * threshold_permyriad / (uint64_t) 10000; return (ctx->swap_total - ctx->swap_used) < swap_threshold; } |