]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/udev/udevd.c
udevd: change the default value of udev.children-max (again)
[thirdparty/systemd.git] / src / udev / udevd.c
index a6f7ee82bbfebf447d3251c073f6b4383a365bed..873d03bc5e51232d3cda5ea285465b8e6259fce5 100644 (file)
@@ -69,6 +69,8 @@
 #include "udev.h"
 #include "user-util.h"
 
+#define WORKER_NUM_MAX 2048U
+
 static bool arg_debug = false;
 static int arg_daemonize = false;
 static ResolveNameTiming arg_resolve_name_timing = RESOLVE_NAME_EARLY;
@@ -1745,16 +1747,18 @@ static int run(int argc, char *argv[]) {
                 return r;
 
         if (arg_children_max == 0) {
+                unsigned long cpu_limit, mem_limit;
+                unsigned long cpu_count = 1;
                 cpu_set_t cpu_set;
-                unsigned long mem_limit;
-
-                arg_children_max = 8;
 
                 if (sched_getaffinity(0, sizeof(cpu_set), &cpu_set) == 0)
-                        arg_children_max += CPU_COUNT(&cpu_set) * 8;
+                        cpu_count = CPU_COUNT(&cpu_set);
+
+                cpu_limit = cpu_count * 2 + 16;
+                mem_limit = MAX(physical_memory() / (128UL*1024*1024), 10U);
 
-                mem_limit = physical_memory() / (128LU*1024*1024);
-                arg_children_max = MAX(10U, MIN(arg_children_max, mem_limit));
+                arg_children_max = MIN(cpu_limit, mem_limit);
+                arg_children_max = MIN(WORKER_NUM_MAX, arg_children_max);
 
                 log_debug("Set children_max to %u", arg_children_max);
         }