mm: memtest: convert to memtest_report_meminfo()
Subsystems (5)
PATCH v2 1/1 mm: memtest: convert to memtest_report_meminfo()
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 <[email protected]>
---
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(-)
fs/proc/meminfo.c +1 -11
@@ -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",
include/linux/memblock.h +4 -6
@@ -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
mm/memtest.c +20 -2
@@ -3,9 +3,10 @@#include <linux/types.h> #include <linux/init.h> #include <linux/memblock.h> +#include <linux/seq_file.h> -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); +}
Signature · 1 line
2.41.0
Quoted 4 lines · Kefeng Wang
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 <[email protected]>
Quoted 94 lines
---
v2: addCONFIG_PROC_FScheck, per Matthewfs/proc/meminfo.c | 12 +----------- include/linux/memblock.h | 10 ++++------ mm/memtest.c | 22 ++++++++++++++++++++-- 3 files changed, 25 insertions(+), 19 deletions(-)fs/proc/meminfo.c +1
-11@@ -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",include/linux/memblock.h +4
-6@@ -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 mm/memtest.c +20
-2@@ -3,9 +3,10 @@#include <linux/types.h> #include <linux/init.h> #include <linux/memblock.h> +#include <linux/seq_file.h> -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); +}Signature · 1 line
2.41.0
Signature · 2 lines
Sincerely yours, Mike.