mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chuyi Zhou <zhouchuyi@bytedance.com>
To: K Prateek Nayak <kprateek.nayak@amd.com>,
	mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com
Cc: chengming.zhou@linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] sched/fair: Ensure select housekeeping cpus in task_numa_find_cpu
Date: Mon, 23 Dec 2024 20:58:07 +0800	[thread overview]
Message-ID: <ea776560-2d80-40e6-b788-9d67fad20add@bytedance.com> (raw)
In-Reply-To: <cf36ae81-c9a4-4a79-bd68-47ed1e6adab4@amd.com>



在 2024/12/18 14:21, K Prateek Nayak 写道:
> Hello Chuyi,
> 
> On 12/16/2024 5:53 PM, Chuyi Zhou wrote:
>> [..snip..]
>> @@ -2081,6 +2081,12 @@ numa_type numa_classify(unsigned int 
>> imbalance_pct,
>>       return node_fully_busy;
>>   }
>> +static inline bool numa_migrate_test_cpu(struct task_struct *p, int cpu)
>> +{
>> +    return cpumask_test_cpu(cpu, p->cpus_ptr) &&
>> +            housekeeping_cpu(cpu, HK_TYPE_DOMAIN);
>> +}
>> +
>>   #ifdef CONFIG_SCHED_SMT
>>   /* Forward declarations of select_idle_sibling helpers */
>>   static inline bool test_idle_cores(int cpu);
>> @@ -2168,7 +2174,7 @@ static void task_numa_assign(struct 
>> task_numa_env *env,
>>           /* Find alternative idle CPU. */
>>           for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start 
>> + 1) {
> 
> Can we just do:
> 
>      for_each_cpu_and(cpu, cpumask_of_node(env->dst_nid), 
> housekeeping_cpumask(HK_TYPE_DOMAIN)) {
>          ...
>      }
> 
> and avoid adding numa_migrate_test_cpu(). Thoughts?

Make sense, but now there doesn't seem to be an API like 
for_each_cpu_wrap_and().

Do you think the following is better?

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 855df103f4dd..4792ef672738 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2167,9 +2167,9 @@ static void task_numa_assign(struct task_numa_env 
*env,
                 int start = env->dst_cpu;

                 /* Find alternative idle CPU. */
-               for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), 
start + 1) {
+               for_each_cpu_and(cpu, cpumask_of_node(env->dst_nid), 
housekeeping_cpumask(HK_TYPE_DOMAIN)) {
                         if (cpu == env->best_cpu || !idle_cpu(cpu) ||
-                           !cpumask_test_cpu(cpu, env->p->cpus_ptr)) {
+                               cpu == start || !cpumask_test_cpu(cpu, 
env->p->cpus_ptr)) {
                                 continue;
                         }


Thanks.


> 
>>               if (cpu == env->best_cpu || !idle_cpu(cpu) ||
>> -                !cpumask_test_cpu(cpu, env->p->cpus_ptr)) {
>> +                !numa_migrate_test_cpu(env->p, cpu)) {
>>                   continue;
>>               }
>> @@ -2480,7 +2486,7 @@ static void task_numa_find_cpu(struct 
>> task_numa_env *env,
>>       for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) {
> 
> Same modifications can be made for this outer loop.
> 


  reply	other threads:[~2024-12-23 12:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-16 12:23 [PATCH 0/3] Take the scheduling domain into account in numa balancing Chuyi Zhou
2024-12-16 12:23 ` [PATCH 1/3] sched/fair: Remove unused task_numa_migrate return value Chuyi Zhou
2024-12-18  6:29   ` K Prateek Nayak
2024-12-23 12:34     ` Chuyi Zhou
2024-12-16 12:23 ` [PATCH 2/3] sched/fair: Ignore isolated cpus in update_numa_stat Chuyi Zhou
2024-12-18  6:26   ` K Prateek Nayak
2024-12-18  7:19     ` [External] " Chuyi Zhou
2024-12-16 12:23 ` [PATCH 3/3] sched/fair: Ensure select housekeeping cpus in task_numa_find_cpu Chuyi Zhou
2024-12-18  6:21   ` K Prateek Nayak
2024-12-23 12:58     ` Chuyi Zhou [this message]
2024-12-27  4:40       ` K Prateek Nayak
2024-12-27  7:59         ` Chuyi Zhou
2025-01-02  5:49           ` K Prateek Nayak

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=ea776560-2d80-40e6-b788-9d67fad20add@bytedance.com \
    --to=zhouchuyi@bytedance.com \
    --cc=bsegall@google.com \
    --cc=chengming.zhou@linux.dev \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --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

all inboxes | Powered by JetHome®