From patchwork Tue Aug 8 03:33:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13345665 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 3301CEB64DD for ; Tue, 8 Aug 2023 03:22:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A12E86B0071; Mon, 7 Aug 2023 23:22:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C2486B0074; Mon, 7 Aug 2023 23:22:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88BAE6B0075; Mon, 7 Aug 2023 23:22:07 -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 783E86B0071 for ; Mon, 7 Aug 2023 23:22:07 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 423CE16052C for ; Tue, 8 Aug 2023 03:22:07 +0000 (UTC) X-FDA: 81099488694.30.8AC24C8 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id CDCAB20002 for ; Tue, 8 Aug 2023 03:22:04 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691464925; 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=g3LLFRqWUmqnyirF6kiNK3rwp7r6tRV6GG2hE3sdNqg=; b=Hh/c3iCeQlEKd5P0qvRHrVsFfCTTGkWu55aSqL2kdggT1o6xm7FyU1BmSnMe494+pfD4W1 9QU8W3/2nzXoyBnL1YUVVaR+DcFnTkzxmEFXePJ+HqcFkfcnqkgvBeeQpvgbKQHLSemGUG OqGd6ezIAYetb4enguB1fdSs8+lVikI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691464925; a=rsa-sha256; cv=none; b=K9xAjWCf9TTzKkeRC71p5wZzszThBj49a7m6avufK9N/aDk0U69r5dCninRsE5xMs86LEb pecuzmI2/xTVJAvqTILaFv+OZlG95SvIJWtRIq4getPwbgIwxDT+qkOg0guXvvVyVr/Ut8 rO0qLdWz9x6ZueszcJD29lqvSquy0Zg= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RKdk96d2GzrSLG; Tue, 8 Aug 2023 11:20:49 +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 11:21:55 +0800 From: Kefeng Wang To: Mike Rapoport , Andrew Morton CC: Tomas Mudrunka , , , , Kefeng Wang Subject: [PATCH v2] mm: memtest: convert to memtest_report_meminfo() Date: Tue, 8 Aug 2023 11:33:59 +0800 Message-ID: <20230808033359.174986-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: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CDCAB20002 X-Stat-Signature: 9egut1h789tgu1br8xjjgben9pn3tngg X-HE-Tag: 1691464924-76851 X-HE-Meta: U2FsdGVkX19Fg0LsW5VAhAQeDLGy16Q10y1ebjhrMB+fz0Nd3pe7DrkuzfhM6/mnM8jFv7tYNGwvNAn7fy3OpLYQ+72AnPcdZkXQQtpkaizIlWkC8pLoUlYAwV/L7RPEkjUddXgdGqUSYmX0wXyoQG324p7NI3M296aukNXX6gD6Zp4ZSABoo9PSj/cUFrxGutkGGCFMU0Ka/56NrNtYgERtt+LvgDIWY47JPVSFDWxS0uBRI92qbqNkwjB7vET4jH23mqUuCegYchmvaq9euwRm+pD1PR4TNjnpjFE+6iED/jDHxi2OoQU6wyRF6E6T5nlZh1ak08ljgvN4/w5aD0gxfp44V9EgAi+PZV/CL2ZXy3IOeDiVBfgs7WSLqzJ7kGsFoCZCA5tuSdpnO15/tOVXF+1iH+LqHisPasksUFyC2iGQXq32gRc3gSZNYoFkeyuX947YWOcxXMlukQB7s7sNdBwjqqcDiLr0kuRG9fPJNqEZ138aLwMRc8bpmsQvrtGYYW/SX5K4fiZ7Yk8hyW9gZttB3D7wF05X39QVEdHp6fDDShOZ8SBJy3Xmv4wacgakusFTnJNfq1Rwd0h/oFuAbfcSdB//EqTtIG42QyL2T1ZBvZyx7dNi0ZPISIi9AX7Gkb6JLW06q0dL+OIal6aAOJVUl/ivkwo+7LDzRLtwiFbJ2nMbVADs/4pX/Xy0gXQQnpBGsfp/UAr4/G+/Nk2sU26twtQTn64pZhyR4CuJcH2y3qX1CoBb6tmL6BZIWTRvOHTUt8GxSD5BFXt84Sq/P+4SFbigynulF2wWqVUkmZrK50eiyRpluPPgWqwHRKiw6XZ4qUim7AvdtnqBFibmrzQfKFEAqiYl63JQImOKQvKwJ8k6x2z3lAJBvMhzPA84KdUT7s1nVZ8EOy78OCtgHuY9JcklWssfgwB6gcJGfkqH8xF/f5RgC2wk8hdiBsmag28MSNcAaJlOsID JIlmT8NW nYQCgs81nQV+IGTPU1bRH1NN9dQnIGfXeD7bviFogtQPYSJV4z7xaTGPTpquzjxcbBXcFkLKwbR+vqfJaFJ6R2Nenf5CVWNd+T2tvZSjIaB3YKfpVgYLUWZATUAAexYbd7k4KSctj9iK4WetW/fC3HPl6LbY8knycPGpfYGPivN2Dui+xUoaken71XBdNvPYa03lW0yJv+GX8hrbrB7q+0VhfVrbx5Gbnh4cW9iP5sdGi6RO94/0SUX37nCi9+A1xHes7e3tSJy32OOwNrVb8+/qMKUBLv4PrGsMeDoiJip1Im0Q= 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 Acked-by: Mike Rapoport (IBM) --- v2: add CONFIG_PROC_FS check, per Matthew fs/proc/meminfo.c | 12 +----------- include/linux/memblock.h | 10 ++++------ mm/memtest.c | 22 ++++++++++++++++++++-- 3 files changed, 25 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..32f3e9dda837 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,20 @@ 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 (!IS_ENABLED(CONFIG_PROC_FS)) + return; + + 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); +}