From: Lennart Poettering Date: Wed, 8 Jun 2016 18:45:32 +0000 (+0200) Subject: util: introduce physical_memory_scale() to unify how we scale by physical memory X-Git-Tag: v231.3~107 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=2027bfc6205de5f5313609fe0ca7e0649640219b util: introduce physical_memory_scale() to unify how we scale by physical memory The various bits of code did the scaling all different, let's unify this, given that the code is not trivial. --- diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 7ffad3ac9..f8b896552 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -896,7 +896,7 @@ int config_parse_tmpfs_size( /* First, try to parse as percentage */ r = parse_percent(rvalue); if (r > 0 && r < 100) - *sz = PAGE_ALIGN((size_t) ((physical_memory() * (uint64_t) r) / 100U)); + *sz = physical_memory_scale(r, 100U); else { uint64_t k; diff --git a/src/login/logind.c b/src/login/logind.c index 4006bf138..45fe8a922 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -78,7 +78,7 @@ static void manager_reset_config(Manager *m) { m->idle_action_usec = 30 * USEC_PER_MINUTE; m->idle_action = HANDLE_IGNORE; - m->runtime_dir_size = PAGE_ALIGN((size_t) (physical_memory() / 10)); /* 10% */ + m->runtime_dir_size = physical_memory_scale(10U, 100U); /* 10% */ m->user_tasks_max = 12288; m->sessions_max = 8192; m->inhibitors_max = 8192;