Re: [PATCH 2/2] sched/fair: Randomize equally shallow slow-path candidates
From: Shubhang
Date: Wed Sep 16 2026 - 15:43:44 EST
Hi Christian,
On Wed, 16 Sep 2026, Christian Loehle wrote:
+ } else if (!idle || idle->exit_latency == min_exit_latency) {
+ nr_candidates++;
+ if (nr_candidates == 1 ||
+ !reciprocal_scale(sched_rng(), nr_candidates))
+ shallowest_idle_cpu = i;
available_idle_cpu(i) ensures that this is an idle CPU, but !idle means that no active cpuidle state, meaning no exit latency is available for comparison.
[PATCH 1/2] treats such a CPU as a fallback i.e. it is selected only when no idle candidate has been found yet. Here it becomes an equal reservoir candidate, even after selecting a CPU with the minimum known exit latency. That is, it is added to the random selection pool and can replace shallowest_idle_cpu.
Is that intentional ? If not, should reservoir sampling be limited to
candidates with `idle->exit_latency == min_exit_latency`, while retaining the first !idle CPU only as the fallback?
Regards,
Shubhang Kaushik