From: "Li Zhe" <lizhe.67@bytedance.com>
To: <akpm@linux-foundation.org>, <david@kernel.org>, <ljs@kernel.org>,
<gourry@gourry.net>, <joshua.hahnjy@gmail.com>, <ziy@nvidia.com>,
<mingo@redhat.com>, <peterz@infradead.org>, <mgorman@suse.de>,
<riel@redhat.com>, <juri.lelli@redhat.com>,
<vincent.guittot@linaro.org>, <dietmar.eggemann@arm.com>,
<rostedt@goodmis.org>, <bsegall@google.com>,
<vschneid@redhat.com>, <kprateek.nayak@amd.com>
Cc: <linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, "Li Zhe" <lizhe.67@bytedance.com>
Subject: [PATCH 6/6] sched/numa: ignore preferred nodes without normal balancing
Date: Wed, 14 Oct 2026 17:43:47 +0800 [thread overview]
Message-ID: <20261014094347.99157-7-lizhe.67@bytedance.com> (raw)
In-Reply-To: <20261014094347.99157-1-lizhe.67@bytedance.com>
numa_preferred_nid is normal AutoNUMA task-placement state.
Memory-tiering-only mode uses NUMA hint faults to drive page promotion,
not CPU placement.
Even after tiering-only faults stop updating normal placement statistics,
a task can still have a preferred NUMA node from earlier normal balancing
or from previously polluted state. Several scheduler paths consume that
stale state when the NUMA balancing static key is enabled, including
explicit NUMA task migration, sched-cache preferred LLC and scan CPU mask
selection, load-balance locality checks, fbq classification, and wakeup
group selection.
Add a small helper for normal NUMA placement being enabled and use it to
ignore numa_preferred_nid when NUMA_BALANCING_NORMAL is disabled. Keep
the preferred-node migration retry timestamp update before the normal-mode
check so accepted non-normal sysctl states do not leave stale retry state
behind.
Keep the rq nr_numa_running and nr_preferred_running accounting unchanged
so runtime mode changes do not make enqueue/dequeue accounting asymmetric;
the load balancer simply stops consuming those counters while normal
balancing is off.
This does not clear numa_preferred_nid and does not change memory-tiering
promotion decisions.
Signed-off-by: Li Zhe <lizhe.67@bytedance.com>
---
kernel/sched/fair.c | 55 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 44 insertions(+), 11 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ec08406d1364..11b54bb353ad 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1328,6 +1328,21 @@ static int select_idle_sibling(struct task_struct *p, int prev_cpu, int cpu);
static unsigned long task_h_load(struct task_struct *p);
static unsigned long capacity_of(int cpu);
+#ifdef CONFIG_NUMA_BALANCING
+static inline bool numa_balancing_normal_enabled(void)
+{
+ return sysctl_numa_balancing_mode & NUMA_BALANCING_NORMAL;
+}
+
+static inline int task_numa_preferred_nid(struct task_struct *p)
+{
+ if (!numa_balancing_normal_enabled())
+ return NUMA_NO_NODE;
+
+ return p->numa_preferred_nid;
+}
+#endif
+
/* Give new sched_entity start runnable values to heavy its load in infant time */
void init_entity_runnable_average(struct sched_entity *se)
{
@@ -1890,10 +1905,12 @@ static int get_pref_llc(struct task_struct *p, struct sched_cache_group *grp)
* than sched_setnuma() at least -- and thus the
* conflict only exists for a short period of time.
*/
- if (static_branch_likely(&sched_numa_balancing) &&
- p->numa_preferred_nid >= 0 &&
- cpu_to_node(mm_sched_cpu) != p->numa_preferred_nid)
- mm_sched_llc = -1;
+ if (static_branch_likely(&sched_numa_balancing)) {
+ int pref_nid = task_numa_preferred_nid(p);
+
+ if (pref_nid >= 0 && cpu_to_node(mm_sched_cpu) != pref_nid)
+ mm_sched_llc = -1;
+ }
#endif
}
@@ -2009,7 +2026,7 @@ static void get_scan_cpumasks(cpumask_var_t cpus, struct task_struct *p,
* current running node to mitigate the bouncing risk.
* TBD: numa_group should be considered during task aggregation.
*/
- pref_nid = p->numa_preferred_nid;
+ pref_nid = task_numa_preferred_nid(p);
/* honor the task's preferred node */
if (pref_nid == NUMA_NO_NODE)
goto out;
@@ -3649,6 +3666,9 @@ static void numa_migrate_preferred(struct task_struct *p)
interval = min(interval, msecs_to_jiffies(p->numa_scan_period) / 16);
p->numa_migrate_retry = jiffies + interval;
+ if (!numa_balancing_normal_enabled())
+ return;
+
/* Success if task is already running on preferred CPU */
if (task_node(p) == p->numa_preferred_nid)
return;
@@ -10740,6 +10760,9 @@ static long migrate_degrades_locality(struct task_struct *p, struct lb_env *env)
if (!static_branch_likely(&sched_numa_balancing))
return 0;
+ if (!numa_balancing_normal_enabled())
+ return 0;
+
if (!p->numa_faults || !(env->sd->flags & SD_NUMA))
return 0;
@@ -12533,6 +12556,9 @@ static bool update_sd_pick_busiest(struct lb_env *env,
#ifdef CONFIG_NUMA_BALANCING
static inline enum fbq_type fbq_classify_group(struct sg_lb_stats *sgs)
{
+ if (!numa_balancing_normal_enabled())
+ return all;
+
if (sgs->sum_h_nr_running > sgs->nr_numa_running)
return regular;
if (sgs->sum_h_nr_running > sgs->nr_preferred_running)
@@ -12542,6 +12568,9 @@ static inline enum fbq_type fbq_classify_group(struct sg_lb_stats *sgs)
static inline enum fbq_type fbq_classify_rq(struct rq *rq)
{
+ if (!numa_balancing_normal_enabled())
+ return regular;
+
if (rq->nr_running > rq->nr_numa_running)
return regular;
if (rq->nr_running > rq->nr_preferred_running)
@@ -12843,17 +12872,21 @@ sched_balance_find_dst_group(struct sched_domain *sd, struct task_struct *p, int
if (sd->flags & SD_NUMA) {
int imb_numa_nr = sd->imb_numa_nr;
#ifdef CONFIG_NUMA_BALANCING
- int idlest_cpu;
+ int pref_nid = task_numa_preferred_nid(p);
/*
* If there is spare capacity at NUMA, try to select
* the preferred node
*/
- if (cpu_to_node(this_cpu) == p->numa_preferred_nid)
- return NULL;
+ if (pref_nid != NUMA_NO_NODE) {
+ int idlest_cpu;
- idlest_cpu = cpumask_first(sched_group_span(idlest));
- if (cpu_to_node(idlest_cpu) == p->numa_preferred_nid)
- return idlest;
+ if (cpu_to_node(this_cpu) == pref_nid)
+ return NULL;
+
+ idlest_cpu = cpumask_first(sched_group_span(idlest));
+ if (cpu_to_node(idlest_cpu) == pref_nid)
+ return idlest;
+ }
#endif /* CONFIG_NUMA_BALANCING */
/*
* Otherwise, keep the task close to the wakeup source
--
2.20.1
next prev parent reply other threads:[~2026-10-14 9:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 9:43 [PATCH 0/6] sched/numa: fix several NUMA balancing issues Li Zhe
2026-10-14 9:43 ` [PATCH 1/6] sched/numa: clear fault locality state on execve Li Zhe
2026-10-14 13:02 ` Gregory Price
2026-10-15 3:41 ` Li Zhe
2026-10-14 9:43 ` [PATCH 2/6] sched/numa: fix scan-period ratio denominator checks Li Zhe
2026-10-14 12:56 ` Gregory Price
2026-10-15 3:49 ` Li Zhe
2026-10-14 9:43 ` [PATCH 3/6] sched/numa: fix scan-period adjustment for shared faults Li Zhe
2026-10-14 13:12 ` Gregory Price
2026-10-14 9:43 ` [PATCH 4/6] sched/numa: make free-space tiering promotion bypass configurable Li Zhe
2026-10-14 13:16 ` Gregory Price
2026-10-15 4:09 ` Li Zhe
2026-10-14 9:43 ` [PATCH 5/6] sched/numa: do not feed tiering promotions into task placement stats Li Zhe
2026-10-14 13:26 ` Gregory Price
2026-10-15 5:07 ` kernel test robot
2026-10-15 5:07 ` kernel test robot
2026-10-14 9:43 ` Li Zhe [this message]
2026-10-14 13:30 ` [PATCH 6/6] sched/numa: ignore preferred nodes without normal balancing Gregory Price
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=20261014094347.99157-7-lizhe.67@bytedance.com \
--to=lizhe.67@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=bsegall@google.com \
--cc=david@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=ziy@nvidia.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®