Re: [PATCH 4/4] sched/fair: Proportional newidle balance
From: Qing Wang
Date: Wed Apr 29 2026 - 04:52:05 EST
On Sat, 08 Nov 2025 at 00:06, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> if (sd->flags & SD_BALANCE_NEWIDLE) {
> + unsigned int weight = 1;
> +
> + if (sched_feat(NI_RANDOM)) {
> + /*
> + * Throw a 1k sided dice; and only run
> + * newidle_balance according to the success
> + * rate.
> + */
> + u32 d1k = sched_rng() % 1024;
> + weight = 1 + sd->newidle_ratio;
> + if (d1k > weight) {
> + update_newidle_stats(sd, 0);
> + continue;
> + }
> + weight = (1024 + weight/2) / weight;
> + }
Hi Peter,
I think this optimization approach is excellent. However, there is a small
idea for discussion: would using a count-based window (e.g., if the current
success rate is 50%, then within every window of 100 attempts, exactly 50
are allowed to do balancing) be more stable than using a random number to
trigger balancing?
This is just an idea for discussion. I haven’t implemented and validated
it yet
--
Best regards,
Qing