Re: [PATCH v2] memory tiering: Do not allow promotion if NUMA_BALANCING_MEMORY_TIERING is disabled

From: Huang, Ying

Date: Wed Apr 01 2026 - 23:37:14 EST


Hi, Andrew,

Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> writes:

> On Mon, 23 Mar 2026 04:48:49 -0500 Donet Tom <donettom@xxxxxxxxxxxxx> wrote:
>
>> In the current implementation, if NUMA_BALANCING_MEMORY_TIERING is
>> disabled and the pages are on the lower tier, the pages may still be
>> promoted.
>>
>> This happens because task_numa_work() updates the last_cpupid field to
>> record the last access time only when NUMA_BALANCING_MEMORY_TIERING is
>> enabled and the folio is on the lower tier. If
>> NUMA_BALANCING_MEMORY_TIERING is disabled, the last_cpupid field
>> can retains a valid last CPU id.
>>
>> In should_numa_migrate_memory(), the decision checks whether
>> NUMA_BALANCING_MEMORY_TIERING is disabled, the folio is on the lower
>> tier, and last_cpupid is invalid. However, the last_cpupid can be
>> valid when NUMA_BALANCING_MEMORY_TIERING is disabled, the condition
>> evaluates to false and migration is allowed.
>>
>> This patch prevents promotion when NUMA_BALANCING_MEMORY_TIERING is
>> disabled and the folio is on the lower tier.
>>
>> Behavior before this change:
>> ============================
>> - If NUMA_BALANCING_NORMAL is enabled, migration occurs between
>> nodes within the same memory tier, and promotion from lower
>> tier to higher tier may also happen.
>>
>> - If NUMA_BALANCING_MEMORY_TIERING is enabled, promotion from
>> lower tier to higher tier nodes is allowed.
>>
>> Behavior after this change:
>> ===========================
>> - If NUMA_BALANCING_NORMAL is enabled, migration will occur only
>> between nodes within the same memory tier.
>>
>> - If NUMA_BALANCING_MEMORY_TIERING is enabled, promotion from lower
>> tier to higher tier nodes will be allowed.
>>
>> - If both NUMA_BALANCING_MEMORY_TIERING and NUMA_BALANCING_NORMAL are
>> enabled, both migration (same tier) and promotion (cross tier) are
>> allowed.
>
> There was no feedback on this, nor on your v1.
>
>> Fixes: 33024536bafd ("memory tiering: hot page selection with hint page fault latency")
>
> Ying Huang seems to have moved around a bit - let me add a couple more
> email addresses. Apologies if we have multiple Ying Huangs!

Thanks! I don't find other Ying Huang in mm community yet.

Now I use the following email address:

"Huang, Ying" <ying.huang@xxxxxxxxxxxxxxxxx>
Ying Huang <huang.ying.caritas@xxxxxxxxx>

and stop using the following email address:

ying.huang@xxxxxxxxx

> Rik, Mel? It's a bugfix.
>
> Thanks.
>
>
>
> From: Donet Tom <donettom@xxxxxxxxxxxxx>
> Subject: memory tiering: do not allow promotion if NUMA_BALANCING_MEMORY_TIERING is disabled
> Date: Mon, 23 Mar 2026 04:48:49 -0500
>
> In the current implementation, if NUMA_BALANCING_MEMORY_TIERING is
> disabled and the pages are on the lower tier, the pages may still be
> promoted.
>
> This happens because task_numa_work() updates the last_cpupid field to
> record the last access time only when NUMA_BALANCING_MEMORY_TIERING is
> enabled and the folio is on the lower tier. If
> NUMA_BALANCING_MEMORY_TIERING is disabled, the last_cpupid field can
> retains a valid last CPU id.
>
> In should_numa_migrate_memory(), the decision checks whether
> NUMA_BALANCING_MEMORY_TIERING is disabled, the folio is on the lower tier,
> and last_cpupid is invalid. However, the last_cpupid can be valid when
> NUMA_BALANCING_MEMORY_TIERING is disabled, the condition evaluates to
> false and migration is allowed.
>
> This patch prevents promotion when NUMA_BALANCING_MEMORY_TIERING is
> disabled and the folio is on the lower tier.
>
> Behavior before this change:
> ============================
> - If NUMA_BALANCING_NORMAL is enabled, migration occurs between
> nodes within the same memory tier, and promotion from lower
> tier to higher tier may also happen.
>
> - If NUMA_BALANCING_MEMORY_TIERING is enabled, promotion from
> lower tier to higher tier nodes is allowed.
>
> Behavior after this change:
> ===========================
> - If NUMA_BALANCING_NORMAL is enabled, migration will occur only
> between nodes within the same memory tier.
>
> - If NUMA_BALANCING_MEMORY_TIERING is enabled, promotion from lower
> tier to higher tier nodes will be allowed.
>
> - If both NUMA_BALANCING_MEMORY_TIERING and NUMA_BALANCING_NORMAL are
> enabled, both migration (same tier) and promotion (cross tier) are
> allowed.
>
> Link: https://lkml.kernel.org/r/20260323094849.3903-1-donettom@xxxxxxxxxxxxx
> Fixes: 33024536bafd ("memory tiering: hot page selection with hint page fault latency")
> Signed-off-by: Donet Tom <donettom@xxxxxxxxxxxxx>
> Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> Cc: Ben Segall <bsegall@xxxxxxxxxx>
> Cc: David Hildenbrand <david@xxxxxxxxxx>
> Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
> Cc: "Huang, Ying" <huang.ying.caritas@xxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
> Cc: Mel Gorman <mgorman@xxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: "Ritesh Harjani (IBM)" <ritesh.list@xxxxxxxxx>
> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
> Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
> Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> ---
>
> kernel/sched/fair.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> --- a/kernel/sched/fair.c~memory-tiering-do-not-allow-promotion-if-numa_balancing_memory_tiering-is-disabled
> +++ a/kernel/sched/fair.c
> @@ -2024,8 +2024,12 @@ bool should_numa_migrate_memory(struct t
> this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid);
> last_cpupid = folio_xchg_last_cpupid(folio, this_cpupid);
>
> + /*
> + * Do not allow promotion if NUMA_BALANCING_MEMORY_TIERING is disabled
> + * and the pages are on the lower tier.
> + */
> if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) &&
> - !node_is_toptier(src_nid) && !cpupid_valid(last_cpupid))
> + !node_is_toptier(src_nid))
> return false;
>
> /*
> _

---
Best Regards,
Huang, Ying