[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241121045504.2233544-1-misono.tomohiro@fujitsu.com>
Date: Thu, 21 Nov 2024 04:55:04 +0000
From: Tomohiro Misono <misono.tomohiro@...itsu.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Miaohe Lin <linmiaohe@...wei.com>,
Naoya Horiguchi <nao.horiguchi@...il.com>
Cc: jiaqiyan@...gle.com,
misono.tomohiro@...itsu.com,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH] mm: memory-failure: add soft-offline stat in mf_stats
commit 44b8f8bf2438 ("mm: memory-failure: add memory failure stats
to sysfs") introduces per NUMA memory error stats which show
breakdown of HardwareCorrupted of /proc/meminfo in
/sys/devices/system/node/nodeX/memory_failure.
However, HardwareCorrupted also counts soft-offline pages. So, add
soft-offline stats in mf_stats too to represent more accurate status.
This updates total count as:
total = recovered + ignored + failed + delayed + soft_offline
Test example:
1) # grep HardwareCorrupted /proc/meminfo
HardwareCorrupted: 0 kB
2) soft-offline 1 page by madvise(MADV_SOFT_OFFLINE)
3) # grep HardwareCorrupted /proc/meminfo
HardwareCorrupted: 4 kB
# grep -r "" /sys/devices/system/node/node0/memory_failure
/sys/devices/system/node/node0/memory_failure/total:1
/sys/devices/system/node/node0/memory_failure/soft_offline:1
/sys/devices/system/node/node0/memory_failure/recovered:0
/sys/devices/system/node/node0/memory_failure/ignored:0
/sys/devices/system/node/node0/memory_failure/failed:0
/sys/devices/system/node/node0/memory_failure/delayed:0
Signed-off-by: Tomohiro Misono <misono.tomohiro@...itsu.com>
---
Hello
This is RFC because I'm not sure adding SOFT_OFFLINE in enum
mf_result is a right approach. Also, maybe is it better to move
update_per_node_mf_stats() into num_poisoned_pages_inc()?
I omitted some cleanups and sysfs doc update in this version to
highlight changes. I'd appreciate any suggestions.
Regards,
Tomohiro Misono
include/linux/mm.h | 2 ++
include/linux/mmzone.h | 4 +++-
mm/memory-failure.c | 9 +++++++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5d6cd523c7c0..7f93f6883760 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3991,6 +3991,8 @@ enum mf_result {
MF_FAILED, /* Error: handling failed */
MF_DELAYED, /* Will be handled later */
MF_RECOVERED, /* Successfully recovered */
+
+ MF_RES_SOFT_OFFLINE, /* Soft-offline */
};
enum mf_action_page_type {
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index b36124145a16..6a030610cba3 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1282,13 +1282,15 @@ struct memory_failure_stats {
/*
* Recovery results of poisoned raw pages handled by memory_failure,
* in sync with mf_result.
- * total = ignored + failed + delayed + recovered.
+ * total = ignored + failed + delayed + recovered + soft_offline.
* total * PAGE_SIZE * #nodes = /proc/meminfo/HardwareCorrupted.
*/
unsigned long ignored;
unsigned long failed;
unsigned long delayed;
unsigned long recovered;
+
+ unsigned long soft_offline;
};
#endif
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index a7b8ccd29b6f..02f845a222cc 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -109,6 +109,7 @@ MF_ATTR_RO(ignored);
MF_ATTR_RO(failed);
MF_ATTR_RO(delayed);
MF_ATTR_RO(recovered);
+MF_ATTR_RO(soft_offline);
static struct attribute *memory_failure_attr[] = {
&dev_attr_total.attr,
@@ -116,6 +117,7 @@ static struct attribute *memory_failure_attr[] = {
&dev_attr_failed.attr,
&dev_attr_delayed.attr,
&dev_attr_recovered.attr,
+ &dev_attr_soft_offline.attr,
NULL,
};
@@ -185,6 +187,9 @@ static int __page_handle_poison(struct page *page)
return ret;
}
+static void update_per_node_mf_stats(unsigned long pfn,
+ enum mf_result result);
+
static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, bool release)
{
if (hugepage_or_freepage) {
@@ -208,6 +213,7 @@ static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, boo
put_page(page);
page_ref_inc(page);
num_poisoned_pages_inc(page_to_pfn(page));
+ update_per_node_mf_stats(page_to_pfn(page), MF_RES_SOFT_OFFLINE);
return true;
}
@@ -1314,6 +1320,9 @@ static void update_per_node_mf_stats(unsigned long pfn,
case MF_RECOVERED:
++mf_stats->recovered;
break;
+ case MF_RES_SOFT_OFFLINE:
+ ++mf_stats->soft_offline;
+ break;
default:
WARN_ONCE(1, "Memory failure: mf_result=%d is not properly handled", result);
break;
--
2.34.1
Powered by blists - more mailing lists