diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-11 09:51:33 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-21 10:57:23 +0200 |
commit | 21c491e106feb7d4caa7f4b9503b7e9de6e8af23 (patch) | |
tree | 215be95bb8eab85867904a46f51fe5b86d69915a /src/journal/journald-context.c | |
parent | 77599f06e121943b09ca730168a6cbe7f202c782 (diff) | |
download | systemd-21c491e106feb7d4caa7f4b9503b7e9de6e8af23.tar.gz |
Introduce sc_arg_max() helper
Just a cast and an assert.
Diffstat (limited to 'src/journal/journald-context.c')
-rw-r--r-- | src/journal/journald-context.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c index e6aeb03b77..e41e4fc5a7 100644 --- a/src/journal/journald-context.c +++ b/src/journal/journald-context.c @@ -7,6 +7,7 @@ #include "alloc-util.h" #include "audit-util.h" #include "cgroup-util.h" +#include "env-util.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" @@ -76,18 +77,14 @@ static size_t cache_max(void) { if (r < 0) { log_warning_errno(r, "Cannot query /proc/meminfo for MemTotal: %m"); cached = CACHE_MAX_FALLBACK; - } else { + } else /* Cache entries are usually a few kB, but the process cmdline is controlled by the * user and can be up to _SC_ARG_MAX, usually 2MB. Let's say that approximately up to * 1/8th of memory may be used by the cache. * * In the common case, this formula gives 64 cache entries for each GB of RAM. */ - long l = sysconf(_SC_ARG_MAX); - assert(l > 0); - - cached = CLAMP(mem_total / 8 / (uint64_t) l, CACHE_MAX_MIN, CACHE_MAX_MAX); - } + cached = CLAMP(mem_total / 8 / sc_arg_max(), CACHE_MAX_MIN, CACHE_MAX_MAX); } return cached; |