udevd: use cpus_in_affinity_mask()

Let's make use of our own helpers. This has the benefit that we can deal
with arbitrarily sized affinity masks.
This commit is contained in:
Lennart Poettering 2020-06-09 15:39:51 +02:00
parent 57b611a5bf
commit fe56acd8e0
1 changed files with 6 additions and 5 deletions

View 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);