chiark / gitweb /
util: introduce physical_memory_scale() to unify how we scale by physical memory
authorLennart Poettering <lennart@poettering.net>
Wed, 8 Jun 2016 18:45:32 +0000 (20:45 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:59 +0000 (10:12 +0200)
The various bits of code did the scaling all different, let's unify this,
given that the code is not trivial.

src/login/logind-user.c
src/login/logind.c

index 7ffad3ac927f9acd0185a94d15062c77d5757511..f8b896552a34dba7983e6a019563d302a32adb90 100644 (file)
@@ -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;
 
index 4006bf1385616fde7b4995fb6f2a32c6e895eed0..45fe8a9221dc70eeefb05c9b0cde9cb85bcb41c4 100644 (file)
@@ -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;