From patchwork Fri Mar 17 19:30:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Mudrunka X-Patchwork-Id: 13179389 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 F126DC74A5B for ; Fri, 17 Mar 2023 19:30:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44A976B0075; Fri, 17 Mar 2023 15:30:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FA636B0078; Fri, 17 Mar 2023 15:30:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29AD66B007B; Fri, 17 Mar 2023 15:30:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 175796B0075 for ; Fri, 17 Mar 2023 15:30:17 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B85911C5B28 for ; Fri, 17 Mar 2023 19:30:16 +0000 (UTC) X-FDA: 80579381232.13.981A6C0 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by imf13.hostedemail.com (Postfix) with ESMTP id D43F82000B for ; Fri, 17 Mar 2023 19:30:14 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UiT4RHEN; spf=pass (imf13.hostedemail.com: domain of tomas.mudrunka@gmail.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=tomas.mudrunka@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679081414; 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:in-reply-to: references:dkim-signature; bh=GErWS92rZzk3tVeOElqYBEQoZX78znw06d4v0nVRIWE=; b=ofTNkoL6GKt4AgQdGbRhn8n7x0KgUiBd+k/QRgpeFWAq5zXunRxtauAtaOSaT1mOnPxLl7 3F9z8xWYrVnxPpj3amverrZFR6SJZ2/U7pRsW8w9b6Eh85Zdx2CdgFE4Cuwz5yhyuxBNxv zYCgUu8HwNFMEZND7ZKvky6l+1l70qQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UiT4RHEN; spf=pass (imf13.hostedemail.com: domain of tomas.mudrunka@gmail.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=tomas.mudrunka@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679081414; a=rsa-sha256; cv=none; b=QYOpMhBIzMSQyi88DopvmbgsfiIW7F31Lr9K03FFPMf3Iy2Xf+pB2S7zlKMOTMpTtlW+rg ZtmKYNPFrNHp8D8Y2GcDNE8iKXnu2s6eBHaazhJKSyBaJpMp/+7aBQY7liE49z9ez1f0+3 Oz6B8G+fLyD4qAuqQ0ChwGRl0qxezVI= Received: by mail-wr1-f54.google.com with SMTP id j2so5386563wrh.9 for ; Fri, 17 Mar 2023 12:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679081413; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=GErWS92rZzk3tVeOElqYBEQoZX78znw06d4v0nVRIWE=; b=UiT4RHENoxNO8jPUs/vY4YfW+0I+WyHRG4ZcgI5qr7kJTm1/+ZA2kR/L5PVy+9qEKZ tedhclxYd89IDmTM0IOy53aFqC7Pri/kKy8PSWGb0Zhw2rMSCykAWNodKmQQK3Q78UUH T25n8XJ5ZMEIIeyiql/LotyS6j4f58E4M+Vk3x5Q5is2N6D84cbvSOQo4PQw3hRGMnRF gD1qzm2wEwc+8opbBcDmePnaIadfx1HN7H7EABE7S7cWhZAY+1+enIr/fvNntV33DuKc xPpvhcrppIIKYP3xRMA6o6ugOY4/JATUJvWIxD06XJu6Yyw0m0HytvE43nBP94n26iw1 lUyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679081413; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GErWS92rZzk3tVeOElqYBEQoZX78znw06d4v0nVRIWE=; b=L4uVr+ZSsmXkkbdd0rV3QkM2H1tOtrsJci9mmjDGz3fhswN5IdLCj+W12TMcd6FGQl PxFpkirN4CGn3OJkcEkCfydpcNHtL+yCHI1d+X94feBrPRY4cNOx4WlgNn2+phtxIA9y pDo1WBP9Y0qDtAACx+IqGbZBj/O8+2Btb0qQNK8uoSVcpTkKBzWb5a0LZSFNDbhRFKP4 3MS/MKrg6Oa6tolejWbSIcTVTpFYw8qMW9kpm4mK2VSEpa6g1JT1IrbH0jZ421TPoCgR 02GiY3wwYrdKXuGUh1VwCBaqb0NX60YCjFP4232NYrQr98iC9RHdsTnXrGUGyUT8S5Hc rznw== X-Gm-Message-State: AO0yUKWVAzC0Aa9sqUWpgqFUnq8WpJ871gd28MO03ir5tA+YpObHuvVM +GREfoeav/hYl9SIBQAWpXfn8vcIvaaQwgVTBQ== X-Google-Smtp-Source: AK7set8sXzdQYyiIpaXvLp/0zNCCQMY/NZPXHmIPG9woaDmTTIWg3oYpJPtoNAo32Ipi7vxN51zRE76wLfwxqYptJE0= X-Received: by 2002:a5d:4389:0:b0:2ca:ec13:e7a0 with SMTP id i9-20020a5d4389000000b002caec13e7a0mr2323479wrq.8.1679081412941; Fri, 17 Mar 2023 12:30:12 -0700 (PDT) MIME-Version: 1.0 From: =?utf-8?b?VG9tw6HFoSBNdWRydcWIa2E=?= Date: Fri, 17 Mar 2023 20:30:01 +0100 Message-ID: Subject: [PATCH] Add results of early memtest to /proc/meminfo To: Mike Rapoport , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D43F82000B X-Rspam-User: X-Stat-Signature: wq8undg1ynnjnnehij9x8aski34n77er X-HE-Tag: 1679081414-991250 X-HE-Meta: U2FsdGVkX18+xjiYqfyGrT5uN/QVZ+llDtdHz6FVWQOd3vPEz5E9ZcT4KS7uT/U2fujISPHUcIZbH0yeAwKZmGjx7pSvvGE6LcAT1fAYLQl04dzxo7VEtYnqpYAACh8kcIJXOztOr9L7DYAqBfPnMx8YdIq50Ino4kCLSiw7tllgzO4eMFff5ZNOJlQxqkd3zYNMSQjCfpzmKnmkKHVxznmN/J/WqMolTYJCz5O8HNunTF5EcHAGahYjdGEDh0CXCAkxDItG2N1ivK+fkWv9EyaiNq7MvDBjmS4F1tbCX8J0Mj8ySVFK+C53Mu3bCWSIqNwQwB2+Y3ExmsHJ99bJgjObso3Fpaw80oAjNDTAhL4ZkOmqDb3JNjiQbRiOFaU7IoRIKM96OjhA8wTJXwo6VzyBlPeVuoBOJYjacSPyNZaP3EN7njpcHJ3TVJ/nYuQ7c19jmqhhG7TDBVqM+nRlnHwN6LJ8eAj+ZMch1cg7RtlY0dWbPyhz81snCOVRNcBTxiEPc1ujxknriA+0LPLC6C3BYBJ+4XqHpO9gswjqaVzSY4B9G/0sYfH3kgtuPF7Cjvae6NWUPmS930e95Zr7NAMx3UcOjGUgQ4Q2pxhgIUEVcb4ZVfFqFvq55C4qq3+Yv+BfhteHqSeNK46CLM97VufUpF8IUUJTe4X8Jk37Md2LkUceVH0mxkeD9dpNd0y49XJqQL/3Y0iqF3vVZwO1q1QZRvvRA4+IGjUE8+CBljBMlua8Qs5YgGQP5qJkeDiUe4N7giijuekOBMZMldDKw4wSknSAq1v4CK8BfLXp03RugXee1BLE6ID5SXhADajSQEOOboVU4tG073Q5zZa0lHLlFQbPxi+ZYiI54wNtSiXpPxw1ge7APSiqz8qbFVkGBLeFQWB1q+YcPv1/k6Z/FUvbqQNz66Q+cnaeZvDMUZho5nP3bF2D1CxMdZLIkAHl4KeF8Gn8M/PXVa51ZqO 5Fh0UWWy YRqY6lKqqyHHPn7l0S6OB7LKnUm5G4GtXlM8eUn78j7DejAtEtlubmhQB9L2unyCuEKiWLhB6mXkhzuCWHAo+UNabLDCGzcPIpP60o37PaUGzFaXl5uaTWkqHPXD9XnFnO0feVth5LYMDLZuNflZ2S031XyTLiXO4Ue3fJ5Id4w2GQ0EaZNbZHX9hxV9x01sqM6ZHWC//RJxzsddp/oJOtt7nAj5NMsErHnlqJkjMLyGReIzugu36Im1U0Gq8fh6uTNkXl/1uX7RFmT7BRtK1enUL0qZGMSFw/OV4pn4j76PAlOMPFY7pkGEnGFURTQtKlAurOtRSNdjLMyEAsMtuvRaSpSD2eUSUh7GUvC/f1E8zmiKn11kerpua/Dr9K6BFei0OJ9BBuxG/83B23D3VNfLSMa/c4I65HrgrhhQFNmWjVaWuZKX/7PhUFOUnvo0ZE/Z+oDze1H8/YFFOCIhL0r+HPTB6gboync3hizxIC6BDYnO9F3L9JGc8BSrZghaNp7Y2aRPVD20qr0j5uk/sEwY1zpJydDFP6ImERm8/AY0lQ99JEXNOM20+Yey8Ynu5vc9J5i7kXVg2ADnL/tomega4ug== 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: Currently the memtest results were only presented in dmesg. This adds /proc/meminfo entry which can be easily used by scripts. Signed-off-by: Tomas Mudrunka --- fs/proc/meminfo.c | 13 +++++++++++++ include/linux/memblock.h | 2 ++ mm/memtest.c | 5 +++++ 3 files changed, 20 insertions(+) static void __init memtest(u64 pattern, phys_addr_t start_phys, phys_addr_t size) @@ -78,6 +82,7 @@ static void __init do_one_pass(u64 pattern, phys_addr_t start, phys_addr_t end) memtest(pattern, this_start, this_end - this_start); } } + early_memtest_done++; } /* default is disabled */ diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 440960110..844bb7e17 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -131,6 +132,18 @@ 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 + /* Only show 0 Bad memory when test was actually run. + * Make sure bad regions smaller than 1kB are not reported as 0. + * That way when 0 is reported we can be sure there actually was successful test */ + if (early_memtest_done) + seq_printf(m, "EarlyMemtestBad: %5lu kB\n", + (unsigned long) ( + ((early_memtest_bad_size>0) && (early_memtest_bad_size>>10 <= 0)) + ? 1 + : early_memtest_bad_size>>10)); +#endif + #ifdef CONFIG_MEMORY_FAILURE seq_printf(m, "HardwareCorrupted: %5lu kB\n", atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)); diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 50ad19662..b206b2d9d 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -597,6 +597,8 @@ 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 int early_memtest_done; /* How many memtest passes were done? */ extern void early_memtest(phys_addr_t start, phys_addr_t end); #else static inline void early_memtest(phys_addr_t start, phys_addr_t end) diff --git a/mm/memtest.c b/mm/memtest.c index f53ace709..f8e9edebf 100644 --- a/mm/memtest.c +++ b/mm/memtest.c @@ -4,6 +4,9 @@ #include #include +int early_memtest_done = 0; +phys_addr_t early_memtest_bad_size = 0; + static u64 patterns[] __initdata = { /* The first entry has to be 0 to leave memtest with zeroed memory */ 0, @@ -30,6 +33,7 @@ static void __init reserve_bad_mem(u64 pattern, phys_addr_t start_bad, phys_addr pr_info(" %016llx bad mem addr %pa - %pa reserved\n", cpu_to_be64(pattern), &start_bad, &end_bad); memblock_reserve(start_bad, end_bad - start_bad); + early_memtest_bad_size += (end_bad - start_bad); }