From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21F5BC3600C for ; Thu, 3 Apr 2025 12:16:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 910CF280003; Thu, 3 Apr 2025 08:16:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BD3C280001; Thu, 3 Apr 2025 08:16:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78591280003; Thu, 3 Apr 2025 08:16:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5EDE6280001 for ; Thu, 3 Apr 2025 08:16:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9688412056B for ; Thu, 3 Apr 2025 12:16:25 +0000 (UTC) X-FDA: 83292630330.29.E3DB0E5 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf22.hostedemail.com (Postfix) with ESMTP id 85532C0010 for ; Thu, 3 Apr 2025 12:16:23 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743682583; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lboQ47SUsFcMcyF8sO0Kh3363urSlhZidkZJJIrQduY=; b=g89PGz3aujuNQaVrqGCuaKO6dGxOzCQBDtsABhsITxccADhWiLNDPsKDKNU4H59r15e407 roGOKCYymLJPEgVFqm32B6gWAq4LvRUGDiZe2ZNnCXKwwCH0VXY/z74+gvDiT9WWdX0qMt pHa9DS5ihC6/bQ6wpw9vr5l3FsKxY+A= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743682583; a=rsa-sha256; cv=none; b=a2qe49cHh2AxJUrxtb0Yq8cpqIi1JCG8A1N7MhVu3b+W4m1xpgD30unCM+z6PioiKiNznB yR5LErjQUYO1Mf+eri271yKWru+GQZogvjz4oig5yCNujwE7o6nditrfW3aGNUxxVjGbQN 5Y9bjweoeWHKRwL7yLXczZDN3DGMZnE= Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4ZT10X3kPgz67D8Q; Thu, 3 Apr 2025 20:15:40 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 9FCBA140142; Thu, 3 Apr 2025 20:16:19 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 3 Apr 2025 14:16:18 +0200 Date: Thu, 3 Apr 2025 13:16:17 +0100 From: Jonathan Cameron To: Yuquan Wang CC: , , , , , , , , , , , , , , Subject: Re: [PATCH v2] mm: numa_memblks: introduce numa_add_reserved_memblk Message-ID: <20250403131617.000078fa@huawei.com> In-Reply-To: <20250328092132.2695299-1-wangyuquan1236@phytium.com.cn> References: <20250328092132.2695299-1-wangyuquan1236@phytium.com.cn> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To frapeml500008.china.huawei.com (7.182.85.71) X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 85532C0010 X-Stat-Signature: tf11hce3pqfu9bz9degcttqufjr1b53b X-Rspam-User: X-HE-Tag: 1743682583-491674 X-HE-Meta: U2FsdGVkX19OquEU4lKkLQ1dlHbnCV8X+dKQ+UfMz88g04K3V3pJjjl675Glht2U7AzDlymn4ZtFkd+g+DplnUZpfhLe0GmRUa0l0t8uxzrcbKySzmJhwH3beHKATGrX4/CgYjQrBABR/KipVHrT3kdmNtXTcoWmZ5GdNuXGglPcU7veCwjEOHJuDl0WJImOaw1vrbg2MckcCdGN4TdRCgeUUw/K1jA9fPzw5/Kd7d8eGwdtok5Wc3nIICYdGVamlKDKhnueer6PFeHnn0g1llEFmY+gCQDAh+VImvljtbUKj9coHYFXeE/mE/ng3ZzbK13f0Gn5RQWaTZ4T9ff+4mNbsx3GGeXTYKhPi9NbIUvL91WUPOpkdTaJJCDBVWQzRjtXqwIQwh5TfRLx5qhMqWbzQJIwGXQRHOEGvXQu9Aywtq4WupJCve9u7Uukkm9JbksNbtZJD9VodmH5beEVIC0dH6MJQFY9MfvqUMuKnKvH/vXszsMP8+vTpTMuZHcuduqTb65kuZ2ALKg4Ekweln6TtvFIl22BnMXBU+PjnNw3+6W9Of6mVBiI82GRK7cA0L/pUlLoqAPCA9IVMxMNttcC8kaOCxXxHoxNLTGYHamqVbzLp972dysn69NtIZyu/nKWjfM2SClnzzxI9MGI+jYCsmFRxVA1zAwmGMIs7EvJi09r46K2p5eXT2f+pNIFvkI/rY1MA6eO46OTVwi9WkSgnu0HxpflQIcNPoSYgagzQd2XP5M+Ib8hmkYB7bsYtN3lXxspHDqcgCSbb2skVZFCXN//EE9wJugIrfr9mM/FwZe0p2NIIBHvhleJwE66raAcd5qeCgflI9SgMsk2/f54/1/N7JoVtH4I3fZyOfUmXbpVB+rTPhHL2dliyfxZeq3lMJVSxvQ4qX1f87BpYRhQP4vOVSvKFXZQNNjs8yiObd8gkgh+JgLWVtY2dqm5DFkc1Bb1ueszNwM9fyn UrC8CnAc T/mKfUjb6xoLxp/K82bqy0AVeYk5RXl5lza1Dd9o0FXhJpt/xpxBS97cNfN/tSBS+0m4+tzlWFzaveNluaIzHixxSsX3q4Zno9+4T0/rFeepGZL1GD/TpO2b63HEF5zDG/pHLHr6JmjsXjPIqKqfkiskMaJj9A4kjkD/g+8bHFYUyDu0D4NRrd9H7qnp/59v3UWsolWrRQiCMFzqDBxzI/QmP6Dumf3Yr9tKmsGFsrZe86il+XeACMCfE+6z955ahpTIYGnr7zGeuwNWBHxNOt+zsmoXjYZHRJ5jpsn1p1H+epiti3flybMnFSA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, 28 Mar 2025 17:21:32 +0800 Yuquan Wang wrote: > With numa_add_reserved_memblk(), kernel could add numa_memblk into > numa_reserved_meminfo directly. > > acpi_parse_cfmws() currently adds empty CFMWS ranges to numa_meminfo > with the expectation that numa_cleanup_meminfo moves them to > numa_reserved_meminfo. There is no need for that indirection when it is > known in advance that these unpopulated ranges are meant for > numa_reserved_meminfo in suppot of future hotplug / CXL provisioning. > > Signed-off-by: Yuquan Wang Given CFMWS is a CXL thing, +cc linux-cxl Seems like a reasonable cleanup to me. Reviewed-by: Jonathan Cameron > --- > > Changes in v2 (Thanks to Dan): > - Use numa_add_reserved_memblk() to replace numa_add_memblk() in acpi_parse_cfmws() > - Add comments to describe the usage of numa_add_reserved_memblk() > - Provide a more explicit commit message > > drivers/acpi/numa/srat.c | 2 +- > include/linux/numa_memblks.h | 1 + > mm/numa_memblks.c | 22 ++++++++++++++++++++++ > 3 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c > index 00ac0d7bb8c9..70f1a7c6b54a 100644 > --- a/drivers/acpi/numa/srat.c > +++ b/drivers/acpi/numa/srat.c > @@ -458,7 +458,7 @@ 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); > 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..541a99c4071a 100644 > --- a/mm/numa_memblks.c > +++ b/mm/numa_memblks.c > @@ -200,6 +200,28 @@ 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. > + * > + * Usage Case: numa_cleanup_meminfo() reconciles all numa_memblk instances > + * against memblock_type information and moves any that intersect reserved > + * ranges to numa_reserved_meminfo. However, when that information is known > + * ahead of time, we use numa_add_reserved_memblk() to add the numa_memblk > + * to numa_reserved_meminfo directly. > + * > + * 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