The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Valentin Schneider <vschneid@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>,
	K Prateek Nayak <kprateek.nayak@amd.com>
Cc: aubrey.li@linux.intel.com, efault@gmx.de, gautham.shenoy@amd.com,
	linux-kernel@vger.kernel.org, mgorman@techsingularity.net,
	mingo@kernel.org, song.bao.hua@hisilicon.com,
	srikar@linux.vnet.ibm.com, valentin.schneider@arm.com,
	vincent.guittot@linaro.org
Subject: Re: [PATCH v7] sched/fair: Consider cpu affinity when allowing NUMA imbalance in find_idlest_group
Date: Fri, 10 Jun 2022 11:55:37 +0100	[thread overview]
Message-ID: <xhsmhr13w7pp2.mognet@vschneid.remote.csb> (raw)
In-Reply-To: <YqHfdn9O81Ir1+bI@worktop.programming.kicks-ass.net>

On 09/06/22 13:54, Peter Zijlstra wrote:
> Now, I can (and have) fixed up the conflict, but it did make me look at
> this in a little more detail; and the thing I noticed is that your:
>
>   'p->nr_cpus_allowed != num_online_cpus()'
>
> test makes no sense. That's basically 'true'. The thing is,
> nr_cpus_allowed is initialized to NR_CPUS, and unless someone somewhere
> did set_cpus_allowed() on it, it'll still be NR_CPUS.
>
> Also, CPU hotplug doesn't change nr_cpus_allowed, so num_online_cpus()
> is just plain wrong.
>
> Now, something that might work is:
>
>   'p->nr_cpus_allowed < num_online_cpus()'
>
> And even that is no guarantee. You can construct a situation where this
> is still false even though you actually have a constrained set.
> Consider a machine with 8 CPUs. Then set the mask to: 0x55, which has 4
> CPUs set. Then offline the last 4 so that the online mask becomes 0x0f.
>
> Then the effective mask is 0x05, and the number we're looking for above
> is 2, but the suggested test would still be false, because
> nr_cpus_allowed would be 4, as would num_online_cpus().
>

IIUC we want to pay special attention when the task isn't allowed to run on
all online CPUs, wouldn't the below do that?

  !cpumask_subset(cpu_online_mask, p->cpus_ptr)

The task affinity can be a superset of the online mask, obvious case is
init_task's CPU_MASK_ALL, and the above test is still false if both masks
are equal.

(Additionnaly we could add a step in sched_init() to "properly" initialize
the init_task mask and remove the NR_CPUS faff).


  reply	other threads:[~2022-06-10 10:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07 11:12 [PATCH v7] sched/fair: Consider cpu affinity when allowing NUMA imbalance in find_idlest_group K Prateek Nayak
2022-05-12  6:11 ` K Prateek Nayak
2022-06-09 11:54 ` Peter Zijlstra
2022-06-10 10:55   ` Valentin Schneider [this message]
2022-06-10 14:15     ` Peter Zijlstra
2022-06-10 14:42       ` Vincent Guittot
2022-06-10 15:01         ` Peter Zijlstra
2022-06-10 16:25       ` Valentin Schneider
2022-06-13 12:05   ` K Prateek Nayak
2022-06-13  8:43 ` [tip: sched/core] sched/fair: Consider CPU affinity when allowing NUMA imbalance in find_idlest_group() tip-bot2 for 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=xhsmhr13w7pp2.mognet@vschneid.remote.csb \
    --to=vschneid@redhat.com \
    --cc=aubrey.li@linux.intel.com \
    --cc=efault@gmx.de \
    --cc=gautham.shenoy@amd.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=song.bao.hua@hisilicon.com \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.org \
    /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