]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: change TasksMax= value for user logins to 33%
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Jul 2016 15:19:58 +0000 (17:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Jul 2016 13:33:13 +0000 (15:33 +0200)
Let's change from a fixed value of 12288 tasks per user to a relative value of
33%, which with the kernel's default of 32768 translates to 10813. This is a
slight decrease of the limit, for no other reason than "33%" sounding like a nice
round number that is close enough to 12288 (which would translate to 37.5%).
(Well, it also has the nice effect of still leaving a bit of room in the PID
space if there are 3 cooperating evil users that try to consume all PIDs...
Also, I like my bikesheds blue).

Since the new value is taken relative, and machined's TasksMax= setting
defaults to 16384, 33% inside of containers is usually equivalent to 5406,
which should still be ample space.

To summarize:

               | on the host | in the container
   old default |       12288 |            12288
   new default |       10813 |             5406

man/logind.conf.xml
src/login/logind-gperf.gperf
src/login/logind-user.c
src/login/logind.c
src/login/logind.conf.in
src/login/logind.h

index fe92277a1f88cc6d7a1868bdbc28e1b303999978..adba5a41314c9412d6fae45f61e7310dbe1aa8ea 100644 (file)
       <varlistentry>
         <term><varname>UserTasksMax=</varname></term>
 
-        <listitem><para>Sets the maximum number of OS tasks each user
-        may run concurrently. This controls the
-        <varname>TasksMax=</varname> setting of the per-user slice
-        unit, see
+        <listitem><para>Sets the maximum number of OS tasks each user may run concurrently. This controls the
+        <varname>TasksMax=</varname> setting of the per-user slice unit, see
         <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-        for details. Defaults to 12288 (12K).</para></listitem>
+        for details. Defaults to 33%, which equals 10813 with the kernel's defaults on the host, but might be smaller
+        in OS containers.</para></listitem>
       </varlistentry>
 
       <varlistentry>
index 6bd08adc055776a564033067104f7a9a2fe4a2e8..0b6a5f3cf4b72b34635bf5db2c4ad3b198566483 100644 (file)
@@ -36,4 +36,4 @@ Login.RuntimeDirectorySize,        config_parse_tmpfs_size,    0, offsetof(Manag
 Login.RemoveIPC,                   config_parse_bool,          0, offsetof(Manager, remove_ipc)
 Login.InhibitorsMax,               config_parse_uint64,        0, offsetof(Manager, inhibitors_max)
 Login.SessionsMax,                 config_parse_uint64,        0, offsetof(Manager, sessions_max)
-Login.UserTasksMax,                config_parse_uint64,        0, offsetof(Manager, user_tasks_max)
+Login.UserTasksMax,                config_parse_user_tasks_max,0, offsetof(Manager, user_tasks_max)
index de44d369cf6118cf3bd67da53a9f68f8cffd9121..f7d83909a0dc843676e5d99ff9460df1a1f7e5d8 100644 (file)
@@ -870,3 +870,48 @@ int config_parse_tmpfs_size(
 
         return 0;
 }
+
+int config_parse_user_tasks_max(
+                const char* unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        uint64_t *m = data;
+        uint64_t k;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        /* First, try to parse as percentage */
+        r = parse_percent(rvalue);
+        if (r > 0 && r < 100)
+                k = system_tasks_max_scale(r, 100U);
+        else {
+
+                /* If the passed argument was not a percentage, or out of range, parse as byte size */
+
+                r = safe_atou64(rvalue, &k);
+                if (r < 0) {
+                        log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse tasks maximum, ignoring: %s", rvalue);
+                        return 0;
+                }
+        }
+
+        if (k <= 0 || k >= UINT64_MAX) {
+                log_syntax(unit, LOG_ERR, filename, line, 0, "Tasks maximum out of range, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        *m = k;
+        return 0;
+}
index d01dd110ea98e0f691b77ea31570eed1a6d0bea8..5ce36d28c7d18b27e717faebd0b19b03ecd41208 100644 (file)
@@ -62,7 +62,7 @@ static void manager_reset_config(Manager *m) {
         m->idle_action = HANDLE_IGNORE;
 
         m->runtime_dir_size = physical_memory_scale(10U, 100U); /* 10% */
-        m->user_tasks_max = 12288;
+        m->user_tasks_max = system_tasks_max_scale(33U, 100U); /* 33% */
         m->sessions_max = 8192;
         m->inhibitors_max = 8192;
 
index 32c0844cb65d60eb1f2e06533f1e1a179fafc9aa..6f720b77087142237a9666d07b3465b7b03e78e4 100644 (file)
@@ -34,4 +34,4 @@
 #RemoveIPC=yes
 #InhibitorsMax=8192
 #SessionsMax=8192
-#UserTasksMax=12288
+#UserTasksMax=33%
index 90431eb4b0830bf16fbccf0b76357f17c937b0ea..086fa1eeb5bee685314b580751f61a925e14b7c4 100644 (file)
@@ -187,6 +187,7 @@ const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned lengt
 int manager_set_lid_switch_ignore(Manager *m, usec_t until);
 
 int config_parse_tmpfs_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_user_tasks_max(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 
 int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret);
 int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);