Re: [RFC PATCH 5/6] sched/fair: Add task burst threshold for large-scale bursts
From: Peter Zijlstra
Date: Wed Oct 21 2026 - 08:59:06 EST
On Tue, Oct 20, 2026 at 04:37:45PM +0800, Li kunyu wrote:
> +#ifdef CONFIG_NO_HZ_COMMON
> + /*
> + * In practice, bursty tasks can lead to uneven task distribution.
> + * For example, some CPUs may have kernel-mode utilization above 50%,
> + * while more than 10% of CPUs in the system remain idle.
> + * Therefore, we define a task burst threshold:
> + *
> + * 1. For a task to be woken up, the scheduler first follows the
> + * original wake-up logic (such as wake-up on the current CPU or
> + * affinity wake-up) to return a CPU. If no CPU is returned, it
> + * then checks the task burst threshold of new_cpu.
> + * 2. Newly created child processes or threads have fewer
> + * considerations; only the task burst threshold needs to be checked.
> + */
> + if (sched_feat(SMT_BUDDY_ASSIST) && cpu_rq(new_cpu)->nr_running >=
> + sysctl_smt_buddy_balance_task)
> + for_each_cpu_wrap(nohz_idle_cpu, nohz.idle_cpus_mask, new_cpu + 1) {
> + if (!idle_cpu(nohz_idle_cpu))
> + continue;
> +
> + /*
> + * In general-purpose scenarios, the CPU can
> + * typically meet task requirements.
> + */
> + if (!cpumask_test_cpu(nohz_idle_cpu, p->cpus_ptr))
> + continue;
> +
> + /*
> + * Simply returning nohz_idle_cpu is sufficient, since the
> + * subsequent NOHZ kick will clear the corresponding bit in
> + * nohz.idle_cpus_mask.
> + */
> + return nohz_idle_cpu;
> + }
> +#endif
I don't understand why this depends on NO_HZ. I also don't understand
why this only considers idle CPUs.
Also, static thresholds are horrible.
Someone that burst wakes a ton of tasks, even on a non-idle system, will
cause an uneven task distribution. Irrespective of there being idle CPUs
in the system or NOHZ whatever.
So how about we track an average rq-depth in the periodic load-balance
pass, in say the root domain or so. And then, when the the local
rq-depth reaches some multiple (3 sounds like a good number?) of that,
we'll fall back and do something utterly dumb like:
cpu = cpumask_any_distribute(p->cpus_ptr);
Eg, simply start rotating new tasks around the system *and* reset the
periodic load balance period.