Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Cheng-Yang Chou <yphbchou0911@gmail.com>
To: sched-ext@lists.linux.dev, Tejun Heo <tj@kernel.org>,
	David Vernet <void@manifault.com>,
	Andrea Righi <arighi@nvidia.com>,
	Changwoo Min <changwoo@igalia.com>,
	linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	Mike Rapoport <rppt@kernel.org>
Cc: Ching-Chun Huang <jserv@ccns.ncku.edu.tw>,
	Chia-Ping Tsai <chia7712@gmail.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Arnd Bergmann <arnd@arndb.de>,
	linux-arch@vger.kernel.org, chengyang.chou@mediatek.com,
	Cheng-Yang Chou <yphbchou0911@gmail.com>
Subject: [PATCH v2 mm and sched_ext/for-7.5 2/2] sched_ext/idle: Skip nodes without CPUs
Date: Tue,  1 Dec 2026 17:18:03 +0800	[thread overview]
Message-ID: <20261201091829.16311-3-yphbchou0911@gmail.com> (raw)
In-Reply-To: <20261201091829.16311-1-yphbchou0911@gmail.com>

With SCX_OPS_BUILTIN_IDLE_PER_NODE, a CPU is tracked in the idle
cpumask of cpu_to_node(cpu). When the starting node has no idle CPU,
pick_idle_cpu_from_online_nodes() walks the other online nodes in
distance order. Nodes without CPUs, such as memory-only nodes, can't
have an idle one, but the walk still visits them.

Walk only the nodes that have CPUs.

On a Raspberry Pi 5, whose firmware adds numa=fake=8, the previous
patch leaves CPUs only in node 0. Five hackbench -p -g 10 -l 10000
runs under scx_simple, without and with both patches, gave these
means (ops.select_cpu() time per call, run time):

                  global idle cpumask   per-node idle cpumasks
  before          135ns, 7.39s          484ns, 7.49s
  after           139ns, 7.36s          141ns, 7.37s

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
 kernel/sched/ext/idle.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/ext/idle.c b/kernel/sched/ext/idle.c
index 922fbc3065cc..1e7b26869e8d 100644
--- a/kernel/sched/ext/idle.c
+++ b/kernel/sched/ext/idle.c
@@ -168,10 +168,10 @@ static s32 pick_idle_cpu_from_online_nodes(const struct cpumask *cpus_allowed, i
 	unvisited = this_cpu_ptr(&per_cpu_unvisited);
 
 	/*
-	 * Restrict the search to the online nodes (excluding the current
+	 * Restrict the search to the nodes with CPUs (excluding the current
 	 * node that has been visited already).
 	 */
-	nodes_copy(*unvisited, node_states[N_ONLINE]);
+	nodes_copy(*unvisited, node_states[N_CPU]);
 	node_clear(node, *unvisited);
 
 	/*
-- 
2.56.0



  parent reply	other threads:[~2026-12-01  9:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:18 [PATCH v2 mm and sched_ext/for-7.5 0/2] Skip nodes without CPUs in the sched_ext idle walk Cheng-Yang Chou
2026-12-01  9:18 ` [PATCH v2 mm and sched_ext/for-7.5 1/2] mm/fake-numa: map each CPU only to its own node Cheng-Yang Chou
2026-12-01  9:18 ` Cheng-Yang Chou [this message]
2026-12-01 15:45   ` [PATCH v2 mm and sched_ext/for-7.5 2/2] sched_ext/idle: Skip nodes without CPUs Tejun Heo

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=20261201091829.16311-3-yphbchou0911@gmail.com \
    --to=yphbchou0911@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arighi@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=changwoo@igalia.com \
    --cc=chengyang.chou@mediatek.com \
    --cc=chia7712@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rppt@kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tglx@kernel.org \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    --cc=x86@kernel.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