From: Valentin Schneider <vschneid@redhat.com>
To: Tariq Toukan <ttoukan.linux@gmail.com>,
Tariq Toukan <tariqt@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Saeed Mahameed <saeedm@nvidia.com>,
Jakub Kicinski <kuba@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>
Cc: Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, Gal Pressman <gal@nvidia.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next V4 1/3] sched/topology: Add NUMA-based CPUs spread API
Date: Tue, 09 Aug 2022 11:02:07 +0100 [thread overview]
Message-ID: <xhsmh35e5d9b4.mognet@vschneid.remote.csb> (raw)
In-Reply-To: <df8b684d-ede6-7412-423d-51d57365e065@gmail.com>
On 08/08/22 17:39, Tariq Toukan wrote:
> On 8/4/2022 8:28 PM, Valentin Schneider wrote:
>> On 28/07/22 22:12, Tariq Toukan wrote:
>>> +static bool sched_cpus_spread_by_distance(int node, u16 *cpus, int ncpus)
>> ^^^^^^^^^
>> That should be a struct *cpumask.
>
> With cpumask, we'll lose the order.
>
Right, I didn't get that from the changelog.
>>
>>> +{
>>> + cpumask_var_t cpumask;
>>> + int first, i;
>>> +
>>> + if (!zalloc_cpumask_var(&cpumask, GFP_KERNEL))
>>> + return false;
>>> +
>>> + cpumask_copy(cpumask, cpu_online_mask);
>>> +
>>> + first = cpumask_first(cpumask_of_node(node));
>>> +
>>> + for (i = 0; i < ncpus; i++) {
>>> + int cpu;
>>> +
>>> + cpu = sched_numa_find_closest(cpumask, first);
>>> + if (cpu >= nr_cpu_ids) {
>>> + free_cpumask_var(cpumask);
>>> + return false;
>>> + }
>>> + cpus[i] = cpu;
>>> + __cpumask_clear_cpu(cpu, cpumask);
>>> + }
>>> +
>>> + free_cpumask_var(cpumask);
>>> + return true;
>>> +}
>>
>> This will fail if ncpus > nr_cpu_ids, which shouldn't be a problem. It
>> would make more sense to set *up to* ncpus, the calling code can then
>> decide if getting fewer than requested is OK or not.
>>
>> I also don't get the fallback to cpumask_local_spread(), is that if the
>> NUMA topology hasn't been initialized yet? It feels like most users of this
>> would invoke it late enough (i.e. anything after early initcalls) to have
>> the backing data available.
>
> I don't expect this to fail, as we invoke it late enough. Fallback is
> there just in case, to preserve the old behavior instead of getting
> totally broken.
>
Then there shouldn't be a fallback method - the main method is expected to
work.
>>
>> Finally, I think iterating only once per NUMA level would make more sense.
>
> Agree, although it's just a setup stage.
> I'll check if it can work for me, based on the reference code below.
>
>>
>> I've scribbled something together from those thoughts, see below. This has
>> just the mlx5 bits touched to show what I mean, but that's just compile
>> tested.
>
> My function returns a *sorted* list of the N closest cpus.
> That is important. In many cases, drivers do not need all N irqs, but
> only a portion of it, so it wants to use the closest subset of cpus.
>
Are there cases where we can't figure this out in advance? From what I grok
out of the two callsites you patched, all vectors will be used unless some
error happens, so compressing the CPUs in a single cpumask seemed
sufficient.
next prev parent reply other threads:[~2022-08-09 10:02 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 19:12 [PATCH net-next V4 0/3] Introduce and use NUMA distance metrics Tariq Toukan
2022-07-28 19:12 ` [PATCH net-next V4 1/3] sched/topology: Add NUMA-based CPUs spread API Tariq Toukan
2022-07-30 17:29 ` Tariq Toukan
2022-08-02 6:40 ` Tariq Toukan
2022-08-02 9:38 ` Valentin Schneider
2022-08-02 16:05 ` Jakub Kicinski
2022-08-04 17:28 ` Valentin Schneider
2022-08-08 14:39 ` Tariq Toukan
2022-08-09 10:02 ` Valentin Schneider [this message]
2022-08-09 10:18 ` Tariq Toukan
2022-08-09 12:52 ` Valentin Schneider
2022-08-09 14:04 ` Tariq Toukan
2022-08-09 17:36 ` Valentin Schneider
2022-08-10 10:46 ` Valentin Schneider
2022-08-10 10:51 ` [PATCH 1/2] sched/topology: Introduce sched_numa_hop_mask() Valentin Schneider
2022-08-10 10:51 ` [PATCH 2/2] net/mlx5e: Leverage sched_numa_hop_mask() Valentin Schneider
2022-08-10 12:57 ` Tariq Toukan
2022-08-10 17:42 ` Jakub Kicinski
2022-08-11 14:26 ` Valentin Schneider
2022-08-10 12:42 ` [PATCH 1/2] sched/topology: Introduce sched_numa_hop_mask() Tariq Toukan
2022-08-10 12:57 ` Tariq Toukan
2022-08-11 14:26 ` Valentin Schneider
2022-08-14 8:19 ` Tariq Toukan
2022-08-14 8:26 ` Tariq Toukan
2022-08-15 14:20 ` Valentin Schneider
2022-07-28 19:12 ` [PATCH net-next V4 2/3] net/mlx5e: Improve remote NUMA preferences used for the IRQ affinity hints Tariq Toukan
2022-07-28 19:12 ` [PATCH net-next V4 3/3] enic: Use NUMA distances logic when setting " Tariq Toukan
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=xhsmh35e5d9b4.mognet@vschneid.remote.csb \
--to=vschneid@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=juri.lelli@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peterz@infradead.org \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=ttoukan.linux@gmail.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
all inboxes | Powered by JetHome®