Re: [PATCH v2] sched/fair: Replace random newidle_balance with Bresenham accumulator
From: Christian Loehle
Date: Tue Oct 27 2026 - 17:26:27 EST
On 10/27/26 09:31, Qing Wang wrote:
> Hi Peter,
> Gentle ping on this. I know you're busy, but I'd really appreciate your thoughts.
>
>> I took the most sensitive workload I have for newidle balance (tbench)
>> and took it for a spin with these changes. Following are the results:
>>
>> Clients: tip bresenham_accm
>> 1 321.65 (0.00 pct) 313.97 (-2.38 pct)
>> 2 641.92 (0.00 pct) 638.74 (-0.49 pct)
>> 4 1245.65 (0.00 pct) 1237.26 (-0.67 pct)
>> 8 2435.80 (0.00 pct) 2442.23 ( 0.26 pct)
>> 16 4717.66 (0.00 pct) 4688.19 (-0.62 pct)
>> 32 9303.53 (0.00 pct) 9390.71 ( 0.93 pct)
>> 64 18002.57 (0.00 pct) 17911.56 (-0.50 pct)
>> 128 27729.26 (0.00 pct) 27621.95 (-0.38 pct)
>> 256 47134.77 (0.00 pct) 46137.36 (-2.11 pct)
>> 512 43179.41 (0.00 pct) 43277.53 ( 0.22 pct)
>> 1024 40339.30 (0.00 pct) 40176.49 (-0.40 pct)
>>
>> The %diff is in noise range which is a good indication that there
>> shouldn't be any surprises. I'll queue a run overnight to see if
>> there are other benchmarks that like / dislike these changes.
>
> This benchmarks looks good from Prateek.
> Link: https://lore.kernel.org/all/da1896b3-6bec-4b56-bf6d-9ce775b00b8d@xxxxxxx/
> Cc: K Prateek Nayak <kprateek.nayak@xxxxxxx>
Might make sense to resubmit the patch as standalone.
Also minor suggestions inline:
+ * Base on accumulator of Bresenham's line algorithm
+ *
+ * Accumulate ratio each time and trigger balance
+ * when sum ≥ 1024.
>= Is more common I guess
+ *
+ * Ensures exactly ratio balances per 1024 calls
Ensures the same ratio balances per 1024 invocations
+ * and distributes ratio balance operations uniformly
+ * across every 1024 invocations.
across them.
*/