From patchwork Mon Mar 17 10:15:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuquan Wang X-Patchwork-Id: 14019025 Received: from sgoci-sdnproxy-4.icoremail.net (sgoci-sdnproxy-4.icoremail.net [129.150.39.64]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A930233727; Mon, 17 Mar 2025 10:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=129.150.39.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742206584; cv=none; b=Iwt6h5Fp4bmedQ3ztgTh/vveg9ORvTYeGc4yuDPhmW8Auqgexrs1GMls4a4U8oOhBsNFJ9TuysXcm/JidXwWsCXzDfw1/cVefR1aNCvjrB3HgHihcS7zok7F9SfmEAsfelCqezzlIQ/KJVr2c0DnrM3unT1lkvp9knPXIpr6B3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742206584; c=relaxed/simple; bh=bSSPfp5wQHv84WQnZjxG+HqfSddAKKTcsknWCc99ZRI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l8Xxa8ueUTH4Q5vLgLYvSkPhjcj6q/dcTZBKYiMlSB6JVTeU/4G0HaNAkXHIgkWV28jPy75lOIwHV8+vHXgRR8taAb+5ltLyJfizH0vLF8NriXdtlMHAPNkqJqGvcP3VV5MENpRzJ1CmDBfuoZ7eLznt4F4QPP0eAMYT3vTdFaw= 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=129.150.39.64 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-7 (Coremail) with SMTP id AQAAfwAXH69o9tdnVnzGCg--.46584S2; Mon, 17 Mar 2025 18:16:09 +0800 (CST) Received: from phytium.com.cn (unknown [123.150.8.50]) by mail (Coremail) with SMTP id AQAAfwDX2oZU9tdncdJLAA--.4190S4; Mon, 17 Mar 2025 18:15:58 +0800 (CST) From: Yuquan Wang To: Jonathan.Cameron@huawei.com, dan.j.williams@intel.com, rppt@kernel.org, akpm@linux-foundation.org, david@redhat.com, bfaccini@nvidia.com, rafael@kernel.org, lenb@kernel.org, dave@stgolabs.net, dave.jiang@intel.com, alison.schofield@intel.com, vishal.l.verma@intel.com, ira.weiny@intel.com, rrichter@amd.com, haibo1.xu@intel.com Cc: linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, chenbaozi@phytium.com.cn, Yuquan Wang Subject: [PATCH v3 1/2] mm: numa_memblks: introduce numa_add_reserved_memblk Date: Mon, 17 Mar 2025 18:15:32 +0800 Message-Id: <20250317101533.2582624-2-wangyuquan1236@phytium.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250317101533.2582624-1-wangyuquan1236@phytium.com.cn> References: <20250317101533.2582624-1-wangyuquan1236@phytium.com.cn> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: AQAAfwDX2oZU9tdncdJLAA--.4190S4 X-CM-SenderInfo: 5zdqw5pxtxt0arstlqxsk13x1xpou0fpof0/1tbiAQAMAWfXLewE-wAAsG Authentication-Results: hzbj-icmmx-7; spf=neutral smtp.mail=wangyuquan 1236@phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoW7ZF1xXFyfZw48Jw15ZF1kZrb_yoW8CF1Dpa 1DG3W5Wa18Gw4xWw1xury0kw1Sg3WFkFyDJry7Gr43Zr1Fqry2vr4UAFs3Zrn0yrW2kr1r Gr4vyr15uw1rGFUanT9S1TB71UUUUjUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU With numa_add_reserved_memblk(), kernel could add numa_memblk into numa_reserved_meminfo directly. In previous, such process relies on numa_add_memblk() adding to numa_meminfo list first and then uses numa_move_tail_memblk() to move one from numa_meminfo to numa_reserved_meminfo. Signed-off-by: Yuquan Wang --- include/linux/numa_memblks.h | 1 + mm/numa_memblks.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h index dd85613cdd86..991076cba7c5 100644 --- a/include/linux/numa_memblks.h +++ b/include/linux/numa_memblks.h @@ -22,6 +22,7 @@ struct numa_meminfo { }; int __init numa_add_memblk(int nodeid, u64 start, u64 end); +int __init numa_add_reserved_memblk(int nid, u64 start, u64 end); void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi); int __init numa_cleanup_meminfo(struct numa_meminfo *mi); diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index ff4054f4334d..e70c76cc46dd 100644 --- a/mm/numa_memblks.c +++ b/mm/numa_memblks.c @@ -200,6 +200,22 @@ int __init numa_add_memblk(int nid, u64 start, u64 end) return numa_add_memblk_to(nid, start, end, &numa_meminfo); } +/** + * numa_add_reserved_memblk - Add one numa_memblk to numa_reserved_meminfo + * @nid: NUMA node ID of the new memblk + * @start: Start address of the new memblk + * @end: End address of the new memblk + * + * Add a new memblk to the numa_reserved_meminfo. + * + * RETURNS: + * 0 on success, -errno on failure. + */ +int __init numa_add_reserved_memblk(int nid, u64 start, u64 end) +{ + return numa_add_memblk_to(nid, start, end, &numa_reserved_meminfo); +} + /** * numa_cleanup_meminfo - Cleanup a numa_meminfo * @mi: numa_meminfo to clean up From patchwork Mon Mar 17 10:15:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuquan Wang X-Patchwork-Id: 14019023 Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net (zg8tmtyylji0my4xnjqumte4.icoremail.net [162.243.164.118]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FD1AEED6; Mon, 17 Mar 2025 10:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.164.118 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742206576; cv=none; b=KUzR4bB5rSg4XqycAmYsIECAkkUuqNmOIzLvfhJwDcskGjE+Hckpy6sFoWLU/CMtw5+Dj4uMj2br75VUR2lXpahN9wlDEbTlYtPgb4IxI9uep/MOgYIxzQzAF/k2bEqyjZLxxhXow9V+IjHwbVgiqGE23zJsAVbO/8Nwd1gYB3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742206576; c=relaxed/simple; bh=gNa9WH3CbpnyjD0jwvZJ/5xvl2hPG86rsEve7RWuBlo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U/8wUo3V+zDY6/8oDrbVn0o4J+Es2gBNU166Vkx4Jjrn3EsdszLXaGGBP0cnfW5Us5204Ki6KCikscF1CCURAnuwzC6Nszo3XgqqqwRw2rPX3szZj3CxJ44wdQrI1xz+KdjmngWN18pCkIaMLJL53QbQVvzodTQI5ZJ4lPgqEcA= 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=162.243.164.118 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-7 (Coremail) with SMTP id AQAAfwBnb09r9tdnwnzGCg--.38785S2; Mon, 17 Mar 2025 18:16:11 +0800 (CST) Received: from phytium.com.cn (unknown [123.150.8.50]) by mail (Coremail) with SMTP id AQAAfwDX2oZU9tdncdJLAA--.4190S5; Mon, 17 Mar 2025 18:16:05 +0800 (CST) From: Yuquan Wang To: Jonathan.Cameron@huawei.com, dan.j.williams@intel.com, rppt@kernel.org, akpm@linux-foundation.org, david@redhat.com, bfaccini@nvidia.com, rafael@kernel.org, lenb@kernel.org, dave@stgolabs.net, dave.jiang@intel.com, alison.schofield@intel.com, vishal.l.verma@intel.com, ira.weiny@intel.com, rrichter@amd.com, haibo1.xu@intel.com Cc: linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, chenbaozi@phytium.com.cn, Yuquan Wang Subject: [PATCH v3 2/2] ACPI: NUMA: debug invalid unused PXM value for CFMWs Date: Mon, 17 Mar 2025 18:15:33 +0800 Message-Id: <20250317101533.2582624-3-wangyuquan1236@phytium.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250317101533.2582624-1-wangyuquan1236@phytium.com.cn> References: <20250317101533.2582624-1-wangyuquan1236@phytium.com.cn> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: AQAAfwDX2oZU9tdncdJLAA--.4190S5 X-CM-SenderInfo: 5zdqw5pxtxt0arstlqxsk13x1xpou0fpof0/1tbiAQAMAWfXLewFAQAAs5 Authentication-Results: hzbj-icmmx-7; spf=neutral smtp.mail=wangyuquan 1236@phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoW7Kry7JrWxXFW5Zw43ZrWfAFb_yoW5JFWxpF WIkF95JryxGrWxCa4Ivr4jv34fC3WxCFZ8KF9rCry3ZanxWry3Zr47JF9IvFyjy3y8ur10 vr4vvF15ua48ZFDanT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU The absence of SRAT would cause the fake_pxm to be -1 and increment to 0, then send to acpi_parse_cfmws(). If there exists CXL memory ranges that are defined in the CFMWS and not already defined in the SRAT, the new node (node0) for the CXL memory would be invalid, as node0 is already in "used", and all CXL memory might be online on node0. This utilizes node_set(0, nodes_found_map) to set pxm&node map. With this setting, acpi_map_pxm_to_node() could return the expected node value even if no SRAT. If SRAT is valid, the numa_memblks_init() would then utilize numa_move_tail_memblk() to move the numa_memblk from numa_meminfo to numa_reserved_meminfo in CFMWs fake node situation. If SRAT is missing or bad, the numa_memblks_init() would fail since init_func() would fail. And it causes that no numa_memblk in numa_reserved_meminfo list and the following dax_cxl driver could find the expected fake node. Use numa_add_reserved_memblk() to replace numa_add_memblk(), since the cxl numa_memblk added by numa_add_memblk() would finally be moved to numa_reserved_meminfo, and numa_add_reserved_memblk() here could add cxl numa_memblk into reserved list directly. Hence, no matter SRAT is good or not, cxl numa_memblk could be allocated to reserved list. Signed-off-by: Yuquan Wang --- drivers/acpi/numa/srat.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 00ac0d7bb8c9..50bfecfb9c16 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -458,11 +458,12 @@ static int __init acpi_parse_cfmws(union acpi_subtable_headers *header, return -EINVAL; } - if (numa_add_memblk(node, start, end) < 0) { + if (numa_add_reserved_memblk(node, start, end) < 0) { /* CXL driver must handle the NUMA_NO_NODE case */ pr_warn("ACPI NUMA: Failed to add memblk for CFMWS node %d [mem %#llx-%#llx]\n", node, start, end); } + node_set(node, numa_nodes_parsed); /* Set the next available fake_pxm value */ @@ -646,8 +647,12 @@ int __init acpi_numa_init(void) if (node_to_pxm_map[i] > fake_pxm) fake_pxm = node_to_pxm_map[i]; } - last_real_pxm = fake_pxm; - fake_pxm++; + + /* Make sure CFMWs fake node >= 1 */ + fake_pxm = max(fake_pxm, 0); + last_real_pxm = fake_pxm++; + node_set(0, nodes_found_map); + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CFMWS, acpi_parse_cfmws, &fake_pxm);