[PATCH] Add results of early memtest to /proc/meminfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <tomas.mudrunka@xxxxxxxxx>
---
 fs/proc/meminfo.c        | 13 +++++++++++++
 include/linux/memblock.h |  2 ++
 mm/memtest.c             |  5 +++++
 3 files changed, 20 insertions(+)

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 <linux/hugetlb.h>
 #include <linux/mman.h>
 #include <linux/mmzone.h>
+#include <linux/memblock.h>
 #include <linux/proc_fs.h>
 #include <linux/percpu.h>
 #include <linux/seq_file.h>
@@ -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 <linux/init.h>
 #include <linux/memblock.h>
 
+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);
 }
 
 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 */
--
2.40.0



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux