From nobody Sun Feb 8 18:32:59 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3649DC77B7A for ; Thu, 25 May 2023 11:41:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbjEYLlv (ORCPT ); Thu, 25 May 2023 07:41:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239475AbjEYLls (ORCPT ); Thu, 25 May 2023 07:41:48 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 742541BB for ; Thu, 25 May 2023 04:41:26 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QRmKv5czFzYsmC; Thu, 25 May 2023 19:39:15 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 25 May 2023 19:41:23 +0800 From: Kefeng Wang To: Mike Rapoport , Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2] memblock: update numa node of memblk reserved type Date: Thu, 25 May 2023 19:57:42 +0800 Message-ID: <20230525115742.124190-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The numa node of memblk reserved type is always wrong when check memblock_dump_all() or sysfs file (/sys/kernel/debug/memblock/reserved), no one use reserved type's node except the two debug interfaces, but uncorrect value is bad as the above interfaces are visible for user. Let's fix it according to the numa node information from memblk memory type by adding a memblock_reserved_update_node(), note, it will be called twice since memblock_reserve could still be called after memblock_dump_all(), or the sysfs file read may get some wrong value. Signed-off-by: Kefeng Wang --- v2:=20 - update changelog, explain why update reserved node info twice - move memblock_reserved_update_node() from sysfs read into memblock_init_debugfs() mm/memblock.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mm/memblock.c b/mm/memblock.c index c5c80d9bcea3..50dd12958e60 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1899,6 +1899,28 @@ phys_addr_t __init_memblock memblock_get_current_lim= it(void) return memblock.current_limit; } =20 +static void __init_memblock memblock_reserved_update_node(void) +{ + struct memblock_region *rgn; + phys_addr_t base, end, size; + int ret; + + if (!IS_ENABLED(CONFIG_NUMA)) + return; + + for_each_mem_region(rgn) { + base =3D rgn->base; + size =3D rgn->size; + end =3D base + size - 1; + + ret =3D memblock_set_node(base, size, &memblock.reserved, + memblock_get_region_node(rgn)); + if (ret) + pr_err("memblock: Failed to update reserved [%pa-%pa] node", + &base, &end); + } +} + static void __init_memblock memblock_dump(struct memblock_type *type) { phys_addr_t base, end, size; @@ -1932,6 +1954,7 @@ static void __init_memblock __memblock_dump_all(void) &memblock.memory.total_size, &memblock.reserved.total_size); =20 + memblock_reserved_update_node(); memblock_dump(&memblock.memory); memblock_dump(&memblock.reserved); #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP @@ -2209,6 +2232,7 @@ static int __init memblock_init_debugfs(void) debugfs_create_file("physmem", 0444, root, &physmem, &memblock_debug_fops); #endif + memblock_reserved_update_node(); =20 return 0; } --=20 2.35.3