From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A2AF846F for ; Thu, 2 Apr 2026 00:22:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775089342; cv=none; b=YVm4ppN8hkSo/+xSeItyDC+GMVIz2dliyHrErr8gqQKgi7IeCcLSd56BrBr0CKwRh3rm7FDvU7JMNyvFK3Qru0aquKnh6gHdXdrPhmdn9mMRhSopTKUMisl5vc4EYTqN+61vAzBnW8rxo68rIVktPMzAej9C8827pRNfXeYF9h0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775089342; c=relaxed/simple; bh=6AQsnG0JZdnHJ4ld9U9uqtPepg0X3Ro6biYSpZ6g2EQ=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=PbeOLSYKAIUqm+AibgzZ6nwjQeKbny9LTKRApPDMD39lDhVQ6TwDq1oQrkMeg4W05Zgfb38yvw3NOrlmIuju1z4sLyJtP4OScvfQM5TYPbWLFTtmMp7jHitxUG+D+DbGJssN5fydDqB3MNrJSNW2Zl5NUUcbGsiNF9/oPsw4cAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=KbJhuiDn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="KbJhuiDn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84C80C4CEF7; Thu, 2 Apr 2026 00:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1775089342; bh=6AQsnG0JZdnHJ4ld9U9uqtPepg0X3Ro6biYSpZ6g2EQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KbJhuiDnCBiM2FY/KxGIRstF6pSM88+XbZ8r/IihYwoqssckicdLwHVvC7YNutDv5 eUo5+W4iF3BF5+16Sji7MtRwm2NoLEugkfJ2J6BQZ+ZLa4qde0BEnfPcdW5Hd2fC0H nvnJIw4+2+22Vt0z5bcXJlgYhmeHa8g6D19qMV58= Date: Wed, 1 Apr 2026 17:22:20 -0700 From: Andrew Morton To: Donet Tom Cc: David Hildenbrand , Ingo Molnar , Peter Zijlstra , Ritesh Harjani , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Baolin Wang , Ying Huang , Juri Lelli , Mel Gorman , Rik van Riel , ying.huang@intel.com, ying.huang@linux.alibaba.com Subject: Re: [PATCH v2] memory tiering: Do not allow promotion if NUMA_BALANCING_MEMORY_TIERING is disabled Message-Id: <20260401172220.fff999a33e3ffcd0d1fa8929@linux-foundation.org> In-Reply-To: <20260323094849.3903-1-donettom@linux.ibm.com> References: <20260323094849.3903-1-donettom@linux.ibm.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 23 Mar 2026 04:48:49 -0500 Donet Tom 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! Rik, Mel? It's a bugfix. Thanks. From: Donet Tom 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@linux.ibm.com Fixes: 33024536bafd ("memory tiering: hot page selection with hint page fault latency") Signed-off-by: Donet Tom Cc: Baolin Wang Cc: Ben Segall Cc: David Hildenbrand Cc: Dietmar Eggemann Cc: "Huang, Ying" Cc: Ingo Molnar Cc: Juri Lelli Cc: Mel Gorman Cc: Peter Zijlstra Cc: "Ritesh Harjani (IBM)" Cc: Steven Rostedt Cc: Valentin Schneider Cc: Vincent Guittot Signed-off-by: Andrew Morton --- 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; /* _