From: Peter Zijlstra <peterz@infradead.org>
To: I Hsin Cheng <richard120310@gmail.com>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] sched/fair: Refactor can_migrate_task() to elimate looping
Date: Thu, 9 Jan 2025 10:46:27 +0100 [thread overview]
Message-ID: <20250109094627.GP20870@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20250108172948.452158-1-richard120310@gmail.com>
On Thu, Jan 09, 2025 at 01:29:47AM +0800, I Hsin Cheng wrote:
> kernel/sched/fair.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 2d16c8545..ce46f61da 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9404,12 +9404,16 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
> return 0;
>
> /* Prevent to re-select dst_cpu via env's CPUs: */
> - for_each_cpu_and(cpu, env->dst_grpmask, env->cpus) {
> - if (cpumask_test_cpu(cpu, p->cpus_ptr)) {
> - env->flags |= LBF_DST_PINNED;
> - env->new_dst_cpu = cpu;
> - break;
> - }
> + struct cpumask dst_mask;
Except you cannot put cpumask on-stack...
> +
> + cpumask_and(&dst_mask, env->dst_grpmask, env->cpus);
> + cpumask_and(&dst_mask, &dst_mask, p->cpus_ptr);
> +
> + cpu = cpumask_first(&dst_mask);
> +
> + if (cpu < nr_cpu_ids) {
> + env->flags |= LBF_DST_PINNED;
> + env->new_dst_cpu = cpu;
> }
>
> return 0;
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-01-09 9:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 17:29 [RFC PATCH] sched/fair: Refactor can_migrate_task() to elimate looping I Hsin Cheng
2025-01-09 8:58 ` Nysal Jan K.A.
2025-01-09 10:19 ` I Hsin Cheng
2025-01-09 9:46 ` Peter Zijlstra [this message]
2025-01-09 10:12 ` I Hsin Cheng
2025-01-09 10:21 ` Peter Zijlstra
2025-01-09 15:23 ` I Hsin Cheng
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=20250109094627.GP20870@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--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@redhat.com \
--cc=richard120310@gmail.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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