public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: Andrea Righi <arighi@nvidia.com>
Cc: linux-kernel@vger.kernel.org,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Yicong Yang <yangyicong@hisilicon.com>, Tejun Heo <tj@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>
Subject: Re: [PATCH] topology: make for_each_node_with_cpus() O(N)
Date: Tue, 13 May 2025 11:38:49 -0400	[thread overview]
Message-ID: <aCNniZdk-8JPBZpb@yury> (raw)
In-Reply-To: <aB41j_3g4KHnoXaz@gpd3>

On Fri, May 09, 2025 at 07:04:15PM +0200, Andrea Righi wrote:
> Hi Yury,
> 
> On Fri, May 09, 2025 at 12:20:08PM -0400, Yury Norov wrote:
> > From: Yury Norov [NVIDIA] <yury.norov@gmail.com>
> > 
> > for_each_node_with_cpus() calls nr_cpus_node() at every iteration, which
> > makes it O(N^2). Kernel tracks such nodes with N_CPU record in node_states
> > array. Switching to it makes for_each_node_with_cpus() O(N).
> 
> Makes sense to me.
> 
> Maybe we should mention that previously we were only considering online
> nodes with CPUs assigned. Now, we can include also offline nodes with CPUs
> assigned (assuming it's possible)?
> 
> Semantically speaking, since the name doesn't include "online", it seems
> more logical to ignore the state of the node. And if checking the online
> state is required, the user can just use node_online() within the loop.

OK. I'll take your comment and move the patch with bitmap-for-next, if
no objections.

Thanks,
Yury

      reply	other threads:[~2025-05-13 15:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-09 16:20 [PATCH] topology: make for_each_node_with_cpus() O(N) Yury Norov
2025-05-09 17:04 ` Andrea Righi
2025-05-13 15:38   ` Yury Norov [this message]

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=aCNniZdk-8JPBZpb@yury \
    --to=yury.norov@gmail.com \
    --cc=arighi@nvidia.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=tj@kernel.org \
    --cc=yangyicong@hisilicon.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