Re: [PATCH v2 04/13] sched/fair: Remove magic hardcoded margin in fits_capacity()
From: Zhan Xusheng
Date: Mon Oct 05 2026 - 10:31:53 EST
On Wed, Sep 23, 2026 at 07:34:37PM +0800, Chen, Yu C wrote:
> How about x * 5 < y * 4 ? The y * 4 is a left-shift which could be faster.
Works for me, and it is the smallest pair: 1280/256 = 5 and 1024/256 = 4,
so x * 5 < y * 4 is exactly the old comparison, same as x * 100 < y * 80.
Overflow is not a reason to pick either. nr_running_avg is u64, so the
left side is evaluated in 64 bits whichever multiplier is used. On the
right, get_sched_cache_scale() returns INT_MAX for llc_aggr_tolerance >=
100 and invalid_llc_nr() bails out on that, so scale is at most 99 and
scale * sd_llc_size * 1024 stays far below INT_MAX either way.
I will use your form when I post this, which I am holding until 04/13 is
queued -- before that the helper only moves an integer comparison out of
the fits_capacity() macro and fixes nothing.
Thanks,
Zhan Xusheng