From: Yury Norov <yury.norov@gmail.com>
To: Andrea Righi <arighi@nvidia.com>
Cc: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched_ext: idle: small CPU iteration refactoring
Date: Sat, 4 Jan 2025 20:00:10 -0800 [thread overview]
Message-ID: <Z3oDyqZK5pcPZ7y4@yury-ThinkPad> (raw)
In-Reply-To: <20250104090009.331193-1-arighi@nvidia.com>
On Sat, Jan 04, 2025 at 10:00:09AM +0100, Andrea Righi wrote:
> loop to check if all SMT CPUs are idle with
> cpumask_subset(). This simplifies the code and slightly improves
> efficiency, while preserving the original behavior.
In my experience, replacing iterator with a dedicated function makes
you 400-500 times faster. So 'slightly' sounds like an understatement
here.
> Note that idle_masks.smt handling remains racy, which is acceptable as
> it serves as an optimization and is self-correcting.
>
> Suggested-by: Yury Norov <yury.norov@gmail.com>
> Signed-off-by: Andrea Righi <arighi@nvidia.com>
Reviewed-by: Yury Norov <yury.norov@gmail.com>
> ---
> kernel/sched/ext.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 926579624c41..0ce116e0f67c 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -3671,10 +3671,8 @@ void __scx_update_idle(struct rq *rq, bool idle)
> * idle_masks.smt handling is racy but that's fine as
> * it's only for optimization and self-correcting.
> */
> - for_each_cpu(cpu, smt) {
> - if (!cpumask_test_cpu(cpu, idle_masks.cpu))
> - return;
> - }
> + if (!cpumask_subset(smt, idle_masks.cpu))
> + return;
> cpumask_or(idle_masks.smt, idle_masks.smt, smt);
> } else {
> cpumask_andnot(idle_masks.smt, idle_masks.smt, smt);
> --
> 2.47.1
>
> From yury
next prev parent reply other threads:[~2025-01-05 4:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-04 9:00 Andrea Righi
2025-01-05 4:00 ` Yury Norov [this message]
2025-01-05 7:08 ` Andrea Righi
2025-01-06 18:49 ` Tejun Heo
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=Z3oDyqZK5pcPZ7y4@yury-ThinkPad \
--to=yury.norov@gmail.com \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.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®