From patchwork Thu May 25 11:57:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13255104 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 91190C77B7A for ; Thu, 25 May 2023 11:41:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18FFB6B0075; Thu, 25 May 2023 07:41:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13FFA6B0078; Thu, 25 May 2023 07:41:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02EE46B007B; Thu, 25 May 2023 07:41:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E7BB16B0075 for ; Thu, 25 May 2023 07:41:34 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B9D4BAE6FC for ; Thu, 25 May 2023 11:41:34 +0000 (UTC) X-FDA: 80828587308.04.1ED141E Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf27.hostedemail.com (Postfix) with ESMTP id E16B140012 for ; Thu, 25 May 2023 11:41:30 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1685014893; 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=wHBmFzkejVkOidrnLk9ea/0guhsoNnZafqruDFsYVEIw+V1vDvuSb4KGCfASWZ8To0ows5 kKXxtacgs+3yTIef+2PByfePcDCaO1OZIXQYtCYqsml3LrNFg28UYoQCYm9oo5DbsA5r5Q isTL4ku4M7vLqOGx/VBpcrET/+VAHGU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685014893; a=rsa-sha256; cv=none; b=4kVAn2y7H132eUWFkxYyeMHgTiBu98/9JEOJYTOKuH5a2oq/xMnwzZ4NVnRgTwxDi74k0z IbqfJNliGLSCGdM/uiz14kgyOEYI6rg1b6doWAM5QMBNj0Sk7x1EQzEosgf/Ww3MljtniZ J1gQwbK/rpziNLaGfyw7wraeC7F2QAc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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.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 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 X-Rspamd-Queue-Id: E16B140012 X-Rspam-User: X-Stat-Signature: 8obmzsydxirh8dbaenymabka6dydwgc4 X-Rspamd-Server: rspam03 X-HE-Tag: 1685014890-544862 X-HE-Meta: U2FsdGVkX19C6FNtbT3DQoCI4ejlKyVOQtvyXBQM9X7Jp4ptXPkgNa06kr2ACEOSUc6QeKl5+Urlf/44BAdII3Y8RuJZHgkE8CaXCWvnQLxTYMKDG3aKAIx6v2FkLMGxFuhMnlBR85Vz1qQX5wXAyQOkXjMr0E03KOAXZ2hzxP1Qe1AYoH58QzkVzZ6cWy/p69qyMyFjoT8KPVCpKS+0VTNYgCRhL15WO0XgJa2GIjklLd1tDpmi9tf512ZBr27v5WKmCGgr4Vz9CI8IKRD0Utpz1sfw7fifX5bkzO2GqF5jvsljeHMS9KeefPL/u3uT3zbAwmWGDNtOi4CI5sW5ZTpz9lUhAINyuJWVJKoG4PGEl9JKDufaLriJgMd/5emHs83xMH0ILYg/qTX+3t2efMiNHRx6rqwCfMmGhlgJa69PWE+qfEi9IFmxqTt2CZq5dwFS9AY40D16Omwh230T7OkIX5s0DHr8hLOsz6PGsL/twSvdUD3QBBc03xFY+PV3uoqLZwr7Bl5dK5xSv2PKvsLgBOuOT67R/qMzP0v/zuNPwTz8ejC/lUXEkLuYAt0QLSKvKMgvK/uDNZXCp+L03+9lOdXDwdBAjjvtA99H+ZQ/Zsv2eSqE+UdYE3vi/TepgwzG7ymNr7vM3HLh0ifOrBcJicYfsCiLujEaVVg8kOWuIUzGehEM3TCeIfQ9NHCnFeYndAT44L9iKXFfTBb8DRgbn2e6cxarQ3FdQYhvWISZBc02A04rjclo2MNfMO/fVH4jOxKxduJRpKWQePLV9iHjsUw8fX2WvlDQyvqfcTxEGG6B+9JwryS0+mWF8RfvbByBHLNa9La1BgyIwarCAnSCGLTnXhQlE0eSQhPzOSLGfkGtDMmrCo1WhoY1YlLzRdb7SEFuG/yrPWpttQr57m1zjrM6ZAjNCOZ+Iy0dIsofXPmmkfdGNo3eiAt2ZkKe2BnB+8lV7rqHM+SkZMP 0APP1gdZ 0lKPm1/nbfz6lzERHQA3ob6r9Fjwx18LSIkR37qbjphGlHR//PTUZBFUz5AJdao91S/T7F4xf6TtbJW5ru4i3yCFRHempGzp92PCrw/8w0eokKGRvv2k7rm98Rsh2rYouegYwsBiAehBnBbcKUD7LTnz9/g== 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; }