From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from zg8tmja5ljk3lje4ms43mwaa.icoremail.net (zg8tmja5ljk3lje4ms43mwaa.icoremail.net [209.97.181.73]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67A1C31AABF for ; Mon, 5 Jan 2026 02:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.97.181.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767580725; cv=none; b=htmR1McbTcZeRMuSqVY1sebV84rDsZYCbD3dnG4eOnPqz4j/KBd/Ghaqp8Tb0hcVDuggGVKUUi/lUd0Vjl4pt5WHA7Y0QZXrtiZ1PFAgGBd2eX3l2NEwqNQY/XVE8WBdGwp3McAM0u3Yv9lU3I8Mw1eQI6NFktKXE+pMLD50C2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767580725; c=relaxed/simple; bh=jKsGhgpFwF0yH03sJLPmlvaX5aXHNck8mlFfp7eDSf0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=js68VE/EaWu0dhNczER7fdFmAYvwW2GrtaG8TfQKDzudBjwkoWAYUhWZIMTXp6r9Ssy8q6uShjUYNkmtd1P0Rb3tttbg0GgwIFNlpIK4NzOJaGvqCywYQyhS93N0Ni/CQJyfyhHSk46SFbn6PwPrg9lb/a2Lm8STMqVeJ9u8CyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=phytium.com.cn; spf=pass smtp.mailfrom=phytium.com.cn; arc=none smtp.client-ip=209.97.181.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=phytium.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=phytium.com.cn Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-6 (Coremail) with SMTP id AQAAfwCHdVwsJFtpdVXeAg--.58396S2; Mon, 05 Jan 2026 10:38:36 +0800 (CST) Received: from [10.22.77.56] (unknown [123.150.8.50]) by mail (Coremail) with SMTP id AQAAfwCnAO4oJFtpVQIRAA--.30651S2; Mon, 05 Jan 2026 10:38:32 +0800 (CST) Message-ID: Date: Mon, 5 Jan 2026 10:38:30 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: numa_memblks: Identify the accurate NUMA ID of CFMW To: Mike Rapoport Cc: Andrew Morton , Joanthan Cameron , wangyinfeng@phytium.com.cn, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20251230092750.856060-1-cuichao1753@phytium.com.cn> From: Cui Chao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:AQAAfwCnAO4oJFtpVQIRAA--.30651S2 X-CM-SenderInfo: pfxlux1drrlkut6sx5pwlxzhxfrphubq/1tbiAQAFAGlZeBoChwAHsU Authentication-Results: hzbj-icmmx-6; spf=neutral smtp.mail=cuichao175 3@phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoW7Ww4rKw4fWF1UGrWDCF45Wrg_yoW8Kr1UpF 4aqFWrKFW8Jr1xGFs293WUtw1Ivana9F45WFWxCrnrZ3WFqr1DZrWSqr1ruF4ktrWfCF4F qF4Dt3Z0qw18uaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU Hi, Thank you for your review. On 12/30/2025 11:18 PM, Mike Rapoport wrote: > Hi, > > On Tue, Dec 30, 2025 at 05:27:50PM +0800, Cui Chao wrote: >> In some physical memory layout designs, the address space of CFMW >> resides between multiple segments of system memory belonging to >> the same NUMA node. In numa_cleanup_meminfo, these multiple segments >> of system memory are merged into a larger numa_memblk. When >> identifying which NUMA node the CFMW belongs to, it may be incorrectly >> assigned to the NUMA node of the merged system memory. To address this > Can you please provide an example of such memory layout? Example memory layout: Physical address space:     0x00000000 - 0x1FFFFFFF  System RAM (node0)     0x20000000 - 0x2FFFFFFF  CXL CFMW (node2)     0x40000000 - 0x5FFFFFFF  System RAM (node0)     0x60000000 - 0x7FFFFFFF  System RAM (node1) After numa_cleanup_meminfo, the two node0 segments are merged into one:     0x00000000 - 0x5FFFFFFF  System RAM (node0)  // CFMW is inside this range     0x60000000 - 0x7FFFFFFF  System RAM (node1) So the CFMW (0x20000000-0x2FFFFFFF) will be incorrectly assigned to node0. >> scenario, accurately identifying the correct NUMA node can be achieved >> by checking whether the region belongs to both numa_meminfo and >> numa_reserved_meminfo. >> >> Signed-off-by: Cui Chao >> --- >> mm/numa_memblks.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c >> index 5b009a9cd8b4..1ef037f0e0e0 100644 >> --- a/mm/numa_memblks.c >> +++ b/mm/numa_memblks.c >> @@ -573,7 +573,8 @@ int phys_to_target_node(u64 start) >> * Prefer online nodes, but if reserved memory might be >> * hot-added continue the search with reserved ranges. >> */ >> - if (nid != NUMA_NO_NODE) >> + if (nid != NUMA_NO_NODE && >> + meminfo_to_nid(&numa_reserved_meminfo, start) == NUMA_NO_NODE) > I'd suggest assigning the result of meminfo_to_nid(&numa_reserved_meminfo, > start) to a local variable and using that in if and return statements. I will use a local variable named reserved_nid. >> return nid; >> >> return meminfo_to_nid(&numa_reserved_meminfo, start); >> -- >> 2.33.0 >> >> -- Best regards, Cui Chao.