From patchwork Tue Aug 8 01:21:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13345531 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 9ADACC001B0 for ; Tue, 8 Aug 2023 01:10:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 125856B0071; Mon, 7 Aug 2023 21:10:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D6346B0074; Mon, 7 Aug 2023 21:10:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDFC28D0001; Mon, 7 Aug 2023 21:10:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DC3946B0071 for ; Mon, 7 Aug 2023 21:10:00 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 89E89C0692 for ; Tue, 8 Aug 2023 01:10:00 +0000 (UTC) X-FDA: 81099155760.19.A3791B9 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf05.hostedemail.com (Postfix) with ESMTP id 2BFAE100014 for ; Tue, 8 Aug 2023 01:09:56 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1691456998; 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=uUSWxtMm6JLPUvEljMqYZMXGHi/vssl1nRwQIXsbUyE=; b=0SATKXsoxsxA3I6SVFVRrptu0DY0DkVAdTa+M6GOt6vmE2/3HMXaBW4f5eXn1ufBD1Q/kK y+0n11db1H2AofhjWvJYm+O77hTJQbGsb789lgAO8A9hTbOXum/6ltF1ueVVZOZdRWxjJy sxvzIdOxpqhTATEvwOajf1lnai3u8dw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691456998; a=rsa-sha256; cv=none; b=Wd4W1X4lmQ4yLymk5YDaVRP+a8tWRdyWA3fQXa6o4/H2hBRh3xj9fkouQeVNGBRoGEjoBM PPO/wBUBuItj8lJr2nsN0beSPhyQAvnJxd4nrBF1Gd57IeDu14XBYZyYh3YMQfQp5WVklv GiQr+o5YGnOi+K80Cyk814fo+0YtFG0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RKZlq6W3Hz1Z1TR; Tue, 8 Aug 2023 09:07:03 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 8 Aug 2023 09:09:52 +0800 From: Kefeng Wang To: Mike Rapoport , Andrew Morton CC: Tomas Mudrunka , , , Kefeng Wang Subject: [PATCH] mm: memtest: convert to memtest_report_meminfo() Date: Tue, 8 Aug 2023 09:21:56 +0800 Message-ID: <20230808012156.88924-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2BFAE100014 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 8q31r8uur4u8t61bbyupfdwfcbbixkpo X-HE-Tag: 1691456996-658080 X-HE-Meta: U2FsdGVkX19RosYFXg9/VRmnbajjqdLovVTaCN85hbg+D4UPo/eiGSgXW1+2g/pghDv2mnpddAAPaVawcAaURE4B24b2rvNFPO73IKRtFLQYWKt/DDxgEtSTXcuZJrcza7mL/7v1XtQKPH7bx5GN/t7U85RkUbUbyzLI20HKQ5o7TOqLnBOMp53ZBqLeoy6OEFhM3N23BidS13JrFd2g778BPls8MPSn0oAtZylRHTf7fuKqiQuRPAYfGJ5QjtLVKTaYqRggZcZW99RaEqUqTr4mHWxDGOPkkmfanhSz3YhRhhxm2ef/2scJSHGneqeDRWryzsfmblJhvQU9Jgt80HkOivXuw5UG1v++RbWqF9xXOZ1Aa6d6/AylWHH29570M9te5lwlvpOcAYOFmpzBr0M3ibiwAr5G3M7e/Lh/EHQ34XaXlU7i+1p352ZFRWH+TbqIYSp+EqIniM3kVswpXsNjMkaGzWDu8j8sTrGUvY9DpjqS6wv6HEd1ATAGyL5csjTw5OiNkYNR0xqWXcxZ7/OtZTBxP4pksXDVb4gx1L9jggF3lvQa1zNOGdkhMaIfapE07MpC8Fz7skkMiX8VJYA7iNc2C2Xogs/8KgOABOdqNFmrHBGHGcrkIeJIm4IJKaTc8fARsLz6NJkvf2IREDq3W9x7IXKglKCPhwul1/yLtkttYp34FCE6NWF2yYI3l+tqy7LnHG8wA4pys6pJdI7p9zndzBO5woz6c3V7GrUp6ZRJxjdBT4whTK4SHmjIugvlZDmzQUc7ltuDcO6nace5UTYW4h2o8ea4o2eq5zw+tt0mJPU1Pvw/e2iEK2u62/k3pK9oBfVAMebDMfllW5Uc8omHDPtGVMmbKrF9oFHq4ViYjZdK5vgX9NEFQjA+ojInF5nKGjOlrHWFrCS9uH3ZaIzHgrME0luoLtakEQnZbBtztzf7hmEor11gf3h0Hp80u5DvP7md9AzjeQo zBgL4VU7 adDPxUAl9HWCA34yYzg208hd1SCUNyQxUw6Ng4Xbh5ZVV7WPrAVab6aB13ulx33mnuOryX4onnamYoiwYwVhMe4j+2nol+IM4X/T3fu+6OkMbiPBi0oHXfVM37P4Uebp4A+486ZMh65laHUc886Ozna2sbVaSGidBGrLjeC6jEYRb/sbHWUs23CwJPOzNmhjY/x/qXopHh+SxbJvwPsU0GYSVT8qA1ZiNRTf6iSlGrzEQJ2AnnPWrK4QXjjug5WozI2BvGvSbVwZJY86RkCz5rR687aT/f63Jh/fKYXHRy5kwNMI= 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: It is better to not expose too many internal variables of memtest, add a helper memtest_report_meminfo() to show memtest results. Signed-off-by: Kefeng Wang --- fs/proc/meminfo.c | 12 +----------- include/linux/memblock.h | 10 ++++------ mm/memtest.c | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 74e3c3815696..45af9a989d40 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -133,17 +133,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) show_val_kb(m, "VmallocChunk: ", 0ul); show_val_kb(m, "Percpu: ", pcpu_nr_pages()); -#ifdef CONFIG_MEMTEST - if (early_memtest_done) { - unsigned long early_memtest_bad_size_kb; - - early_memtest_bad_size_kb = early_memtest_bad_size>>10; - if (early_memtest_bad_size && !early_memtest_bad_size_kb) - early_memtest_bad_size_kb = 1; - /* When 0 is reported, it means there actually was a successful test */ - seq_printf(m, "EarlyMemtestBad: %5lu kB\n", early_memtest_bad_size_kb); - } -#endif + memtest_report_meminfo(m); #ifdef CONFIG_MEMORY_FAILURE seq_printf(m, "HardwareCorrupted: %5lu kB\n", diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 0d031fbfea25..1c1072e3ca06 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -594,13 +594,11 @@ extern int hashdist; /* Distribute hashes across NUMA nodes? */ #endif #ifdef CONFIG_MEMTEST -extern phys_addr_t early_memtest_bad_size; /* Size of faulty ram found by memtest */ -extern bool early_memtest_done; /* Was early memtest done? */ -extern void early_memtest(phys_addr_t start, phys_addr_t end); +void early_memtest(phys_addr_t start, phys_addr_t end); +void memtest_report_meminfo(struct seq_file *m); #else -static inline void early_memtest(phys_addr_t start, phys_addr_t end) -{ -} +static inline void early_memtest(phys_addr_t start, phys_addr_t end) { } +static inline void memtest_report_meminfo(struct seq_file *m) { } #endif diff --git a/mm/memtest.c b/mm/memtest.c index 57149dfee438..3b9891431124 100644 --- a/mm/memtest.c +++ b/mm/memtest.c @@ -3,9 +3,10 @@ #include #include #include +#include -bool early_memtest_done; -phys_addr_t early_memtest_bad_size; +static bool early_memtest_done; +static phys_addr_t early_memtest_bad_size; static u64 patterns[] __initdata = { /* The first entry has to be 0 to leave memtest with zeroed memory */ @@ -117,3 +118,17 @@ void __init early_memtest(phys_addr_t start, phys_addr_t end) do_one_pass(patterns[idx], start, end); } } + +void memtest_report_meminfo(struct seq_file *m) +{ + unsigned long early_memtest_bad_size_kb; + + if (!early_memtest_done) + return; + + early_memtest_bad_size_kb = early_memtest_bad_size >> 10; + if (early_memtest_bad_size && !early_memtest_bad_size_kb) + early_memtest_bad_size_kb = 1; + /* When 0 is reported, it means there actually was a successful test */ + seq_printf(m, "EarlyMemtestBad: %5lu kB\n", early_memtest_bad_size_kb); +}