From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: peterz@infradead.org, mingo@kernel.org,
tim.c.chen@linux.intel.com, qyousef@layalina.io,
yu.c.chen@intel.com, vincent.guittot@linaro.org,
juri.lelli@redhat.com, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, linux-kernel@vger.kernel.org,
zhanxusheng@xiaomi.com
Subject: Re: [PATCH v2] sched/cache: Don't use fits_capacity() to compare thread and CPU counts
Date: Wed, 4 Nov 2026 21:56:23 +0300 [thread overview]
Message-ID: <aut98iS5gqInpZ2-@scheduler.schedules> (raw)
In-Reply-To: <20261104020954.2388172-1-zhanxusheng1024@gmail.com>
Hi Zhan!
On Wed, Nov 04, 2026 at 10:09:54AM +0800, Zhan Xusheng wrote:
> From: Zhan Xusheng <zhanxusheng@xiaomi.com>
I said myself that I'll review this someday. But forgot when to :/.
Hope I'm not too late.
>
> invalid_llc_nr() checks that a process's running threads stay below 80%
> of the LLC's cores, scaled by llc_aggr_tolerance, with fits_capacity().
> fits_capacity() is meant for capacity values; here it only supplies the
> 20% margin.
>
> Give the check its own helper. x * 5 < y * 4 is the same comparison as
> x * 1280 < y * 1024, so there is no functional change.
Magic of 256.
>
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
> Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com>
> Reviewed-by: Qais Yousef <qyousef@layalina.io>
> ---
> Qais's series changes fits_capacity() to take a CPU number as its
> second argument [1]; this call would then pass the CPU count as a CPU
> number without a warning.
>
> v2: reword the comment (Tim); move the reason above out of the
> changelog; add the Reviewed-by tags.
> v1: https://lore.kernel.org/all/20261102021536.1026143-1-zhanxusheng1024@gmail.com/
>
> [1] https://lore.kernel.org/all/20260504020003.71306-5-qyousef@layalina.io/
>
> kernel/sched/fair.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index cfc982205b98..a7467fe425e6 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -1469,6 +1469,12 @@ static bool exceed_llc_capacity(struct sched_cache_group *grp, int cpu)
> return false;
> }
>
> +/* Number of running threads below 80% of LLC's cores for default setting */
> +static inline bool fits_llc_nr(u64 nr_threads, unsigned int nr_cpus)
> +{
> + return nr_threads * 5 < (u64)nr_cpus * 4;
> +}
> +
> static bool invalid_llc_nr(struct sched_cache_group *grp, struct task_struct *p,
> int cpu)
> {
> @@ -1485,8 +1491,8 @@ static bool invalid_llc_nr(struct sched_cache_group *grp, struct task_struct *p,
> if (scale == INT_MAX)
> return false;
>
> - return !fits_capacity((READ_ONCE(grp->nr_running_avg) * cpu_smt_num_threads),
> - (scale * per_cpu(sd_llc_size, cpu)));
> + return !fits_llc_nr(READ_ONCE(grp->nr_running_avg) * cpu_smt_num_threads,
> + scale * per_cpu(sd_llc_size, cpu));
> }
>
> /*
> --
> 2.43.0
>
Yeah well they behave the same.
Reviewed-by: Kayra Cizmeci <kayracizmeci@gmail.com>
I'll normally say Thanks, but I'll try 'cheers' for today.
Cheers,
Kayra
prev parent reply other threads:[~2026-11-04 18:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 2:09 Zhan Xusheng
2026-11-04 18:56 ` Kayra Cizmeci [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aut98iS5gqInpZ2-@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=qyousef@layalina.io \
--cc=rostedt@goodmis.org \
--cc=tim.c.chen@linux.intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yu.c.chen@intel.com \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®