From patchwork Wed May 24 11:09:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13253754 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 4C354C7EE23 for ; Wed, 24 May 2023 10:52:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C479F900003; Wed, 24 May 2023 06:52:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF747900002; Wed, 24 May 2023 06:52:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE593900003; Wed, 24 May 2023 06:52:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9CB07900002 for ; Wed, 24 May 2023 06:52:50 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6D95BC0925 for ; Wed, 24 May 2023 10:52:50 +0000 (UTC) X-FDA: 80824835700.20.B16F660 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf18.hostedemail.com (Postfix) with ESMTP id 55FCA1C0016 for ; Wed, 24 May 2023 10:52:46 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@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=1684925568; 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: references; bh=cVotRP1QSIf6uHlQhY3XMbtoxtfahPJ9pXPvNkyhTMs=; b=q1Wwgn9lRy2P3jfecNvURp9MB24xHqhcV0hpCkUDn+wq1VztBGAkITMk6jia7TatiZPOL9 /iuwPGqv6p3/mcJSr7K6fi4I6l6Rfxl7I9IHq5fnac/sosvS0M75BPH9F1lT4/P5/fFqND WsEkCpgLiLhVYEVnbEmY496hCEVT8Ng= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684925568; a=rsa-sha256; cv=none; b=8EQ8HivKhbE37DFfux+l1a5bD9PVdWJJymki328uxu509cuHDOmAJbo3/C/moUYJ/X3SkH PQvU0JgEBVMPxbyk407rZLr8RjM8mWymDCz/nRuGTJBcsZO3sQfmBvbSPGANKAwiBb0NU0 cGs41xKR4NvGAEgiRnua5lVMO8kDhpI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QR7FT1GPQz18LWZ; Wed, 24 May 2023 18:48:13 +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; Wed, 24 May 2023 18:52:42 +0800 From: Kefeng Wang To: Mike Rapoport , Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2] memblock: update numa node of memblk reserved type Date: Wed, 24 May 2023 19:09:04 +0800 Message-ID: <20230524110904.106792-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Stat-Signature: saiqirfj6akjpyjphtk8s6ksw9c3bkrw X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 55FCA1C0016 X-Rspam-User: X-HE-Tag: 1684925566-195221 X-HE-Meta: U2FsdGVkX1/pgR2f4uj7xM2LwywwLFsoAslzImnDNWL/apB6VAZX9/PPJAShrnB78FkjOXayuXQdjYDaV1l29VNsjxNtgkmVO0BfuWukRh6AOQ4dysoCIAGBeJsfkqf6TW3lqTBGJf/S4t2UIRyZ87GnlCeJzviTmBis9MrhaIfU8G22GRrD0WIBOJz8eplZbukmyvUcktMQo0HvEL+SaipE7AHnSkqOA9Za41kax/IlHG4whBiw+BIytNHPtslAlHo7PEZ373Y/I6+H8BTHFO6+218pp1sdrleJqMmtwegVoZyEsNRE07D2SEc7OGOnITGjmUboviAIPChZM+DrVvW671G6mgHjJtV2GGYV5oejAP98iTSQtPEpEcpDnrGg+ABSNBjOPqHz1YYoiAzsr6zpde092b8zWkF4NqN5cygPpIkFmzsEnas26bBKqGcm+NUZqJ3EMVFAu/5Z4XKSIYzm+K2tOqX6snBYkh48BKTx83+4utQzrPmiw6KpxPMYHatGi6gUlWwkW7JLsR9hNj8NE6vQqPI6r3BUGpUrZczREoNqxxr2UUoWZDDGmXy/Rs7nQrfp3hbdHUSQLo0cyYztfOl9BNCjKA/lrXG2gjKd6w7M6IA84yN8RqrJLMQiqG0uW1SdTKnz918BGNCorXdtBeYxaFypc6IsfpBBPffwa28ZGepZPyMLGDb+iY//SxWuHJFPk/Kzd523LeBrdgs8JOrd4cWhVTcqpV9lCdJKm9U+SXTWGHbG4VDCqHe4uwz8cKvEejk1eJcmwITyErQty4LDKfeOiMHOJ3h8jHebdN5JQ1UeV+mVxbu4i/fJwg67FMw2OKvvVjIe1oiqeLWFAKNBcGHwHEGZ47oj22JtuFY7i1m3SPV57UO8Cc7wO0PIOz8j+7AKSjI1tiaWB9HMGj7xG/eUGUqa02hjEsd1rlaNvdtn1WcpUG3ZdqI/XNLABZIcJMrR+geemYx hmO++H3v 7OtpqnLs8OsNS+5goKgJ05eQvNUnjJBCItm01chudNexcSs4Ge7bm05hx8eo6JOfO5MqvIY54y2aPxrLWmTGogF7zJBSjiTl7cvLAYcllKgJyguQNIPtVeGk6UyXCFxV6Qz2eLzduX6IBBM8= 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: 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: - 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_limit(void) return memblock.current_limit; } +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 = rgn->base; + size = rgn->size; + end = base + size - 1; + + ret = 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); + 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(); return 0; }