]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevd: use cpus_in_affinity_mask()
authorLennart Poettering <lennart@poettering.net>
Tue, 9 Jun 2020 13:39:51 +0000 (15:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 9 Jun 2020 13:39:53 +0000 (15:39 +0200)
Let's make use of our own helpers. This has the benefit that we can deal
with arbitrarily sized affinity masks.

src/udev/udevd.c

index 6e0ce725534cac2859f03d0e346cf951f0cd78d5..b3fa83993e4dad1e8177c41e81350577ddd2aa04 100644 (file)
@@ -1841,12 +1841,13 @@ int run_udevd(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 cpu_limit, mem_limit, cpu_count = 1;
 
-                if (sched_getaffinity(0, sizeof(cpu_set), &cpu_set) == 0)
-                        cpu_count = CPU_COUNT(&cpu_set);
+                r = cpus_in_affinity_mask();
+                if (r < 0)
+                        log_warning_errno(r, "Failed to determine number of local CPUs, ignoring: %m");
+                else
+                        cpu_count = r;
 
                 cpu_limit = cpu_count * 2 + 16;
                 mem_limit = MAX(physical_memory() / (128UL*1024*1024), 10U);