From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (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 0789D374183 for ; Thu, 2 Apr 2026 06:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775111058; cv=none; b=EfE8o1QDlxO4RoVouopQYUPOOHNmpxEcLyP3h3HWlNxrJK9w0B9h3Ev/nFsixEOU3TW7ylt7S9plbjmwVjMV+h25lApETGnbONVLIIOe62VEJ3Da4hyRcmqn3Gq9Vygk/aDX/SwPdqeCnP9fkafoZQbkhwA+tUg0AWTdKT2RiAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775111058; c=relaxed/simple; bh=Nw4xonnZMVYz3fPWPRGUunDSmj6gJ/iLHRuqUDKlLDo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=kDcsf0S+/G+fFO2yUtomPjP6pLf3J7lVap20mtSA/TEpgrC/57CJ+mgjwVZGf/S+ReDE4NUuMTiqb7+gX1YAr+URr1bV0BIM5PiEvK9zzgwaJgJN/FRFO1M7EwHYO9PSeRfGewaVEepyfNL7WMQTbkTYdhaPpDJlpQ3OFbnvkjY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=aiWV8iIP; arc=none smtp.client-ip=115.124.30.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="aiWV8iIP" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1775111052; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=YMbp+sYgjyqgg8Rmn7tnpa9mpV75dW1kYsbpBQmfGWo=; b=aiWV8iIPf+un6mrBrqQFSroikJgvnL06r417vwRRtOv+bMTymPLGwXa5LTqn/mr1gtihbdBLuBwcrCfFecdUjCS5PSuEDboIlrX+mECtfOxPKXMkIhhy7yDRHijHocEDlPy+GjIui2wxpnx0NRCZsMPyFKsohv7gNvatiGll7Tg= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032089153;MF=ying.huang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0X0GC4RJ_1775111051; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0X0GC4RJ_1775111051 cluster:ay36) by smtp.aliyun-inc.com; Thu, 02 Apr 2026 14:24:11 +0800 From: "Huang, Ying" To: Donet Tom Cc: David Hildenbrand , Andrew Morton , Ingo Molnar , Peter Zijlstra , Ritesh Harjani , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Baolin Wang , Ying Huang , Juri Lelli , Mel Gorman Subject: Re: [PATCH v2] memory tiering: Do not allow promotion if NUMA_BALANCING_MEMORY_TIERING is disabled In-Reply-To: (Donet Tom's message of "Thu, 2 Apr 2026 10:29:39 +0530") References: <20260323094849.3903-1-donettom@linux.ibm.com> <87wlyqt52m.fsf@DESKTOP-5N7EMDA> Date: Thu, 02 Apr 2026 14:24:11 +0800 Message-ID: <87o6k1ubg4.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) 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=ascii Donet Tom writes: > Hi Hi, Donet, > On 4/2/26 8:57 AM, Huang, Ying wrote: >> Donet Tom writes: >> >>> 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. >>> >>> Fixes: 33024536bafd ("memory tiering: hot page selection with hint page fault latency") >>> Signed-off-by: Donet Tom >>> --- >>> v1 -> v2 >>> ======== >>> 1. Dropped changes in task_numa_fault() since the original changes >>> already handle runtime disabling of NUMA_BALANCING_MEMORY_TIERING. >>> >>> v1 -> https://lore.kernel.org/all/20260320092251.1290207-1-donettom@linux.ibm.com/ >>> --- >>> kernel/sched/fair.c | 6 +++++- >>> 1 file changed, 5 insertions(+), 1 deletion(-) >>> >>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >>> index bf948db905ed..4b43809a3fb1 100644 >>> --- a/kernel/sched/fair.c >>> +++ b/kernel/sched/fair.c >>> @@ -2024,8 +2024,12 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, >>> 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; >>> /* >> No. Even if NUMA_BALANCING_MEMORY_TIERING is disabled, we should still >> allow migrate pages from lower tier to higher tier via >> NUMA_BALANCING_NORMAL. If we have precious DDR, why waste it? This >> follows the semantics of NUMA_BALANCING_NORMAL before introducing >> NUMA_BALANCING_MEMORY_TIERING. > > Thank you for the review comments. > > One thing I am trying to understand is that page promotion > appears to happen regardless of whether > NUMA_BALANCING_MEMORY_TIERING is enabled or disabled. In that > case, what is the specific role of > NUMA_BALANCING_MEMORY_TIERING? Do we get better performance > when it is enabled? You can search NUMA_BALANCING_MEMORY_TIERING to find out what it does. We can get better performance as the original commit message says. When NUMA_BALANCING_MEMORY_TIERING is introduced, we didn't change the original behavior of NUMA_BALANCING_MEMORY_NORMAL because we had no good reason to do that. In fact, you change its behavior, so you should provide some supporting data or bug report to justify the change. > My initial understanding was that disabling > NUMA_BALANCING_MEMORY_TIERING could be used to turn off > promotion. However, it seems that currently we cannot control > promotion independently. If NUMA_BALANCING_NORMAL is disabled, > neither migration nor promotion happens, and if it is enabled, > both migration and promotion can occur. > > I was under the impression that: > - NUMA_BALANCING_NORMAL would handle migration within the same tier, > - NUMA_BALANCING_MEMORY_TIERING would handle promotion across tiers, > - and enabling both would allow both migration and promotion. > > This would provide more fine-grained control. Is my > understanding correct, or am I missing something here? You can change this, if you have some supporting data or bug report. --- Best Regards, Huang, Ying