Skip to contentSkip to conversation

vmcoreinfo: Expose hardware error recovery statistics via sysfs

PATCH In review Breno Leitao 4 participants 10 messages Feb 2 – Jul 13

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover vmcoreinfo: Expose hardware error recovery statistics via sysfs

The kernel already tracks recoverable hardware errors (CPU, memory, PCI, CXL, etc.) in the hwerr_data array for vmcoreinfo crash dump analysis. However, this data is only accessible after a crash.

This series adds a sysfs directory at /sys/kernel/hwerr_recovery_stats/ to expose these statistics at runtime, allowing monitoring tools to track hardware health without requiring a kernel crash.

The directory contains one file per error subsystem:
/sys/kernel/hwerr_recovery_stats/{cpu, memory, pci, cxl, others}

Each file contains a single integer representing the error count.

This is useful for:
- Proactive detection of failing hardware components
- Time-series tracking of recoverable errors
- System health monitoring in cloud environments

To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Changes in v2:
- Renamed vmcore_stats to hwerr_stats
- Separate each subsystem in multiple sysfs entries, one per file
- Link to v1: https://patch.msgid.link/[email protected]

---
Breno Leitao (2):
vmcoreinfo: expose hardware error recovery statistics via sysfs
docs: add ABI documentation for /sys/kernel/hwerr_recovery_stats/

 .../ABI/testing/sysfs-kernel-hwerr_recovery_stats  | 47 ++++++++++++++++++
 Documentation/driver-api/hw-recoverable-errors.rst |  3 +-
 kernel/vmcore_info.c                               | 55 ++++++++++++++++++++++
 3 files changed, 104 insertions(+), 1 deletion(-)

---
base-commit: 4d310797262f0ddf129e76c2aad2b950adaf1fda
change-id: 20260129-vmcoreinfo_sysfs-ff4687979cd5

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
#1 lore raw

PATCH v2 1/2 vmcoreinfo: expose hardware error recovery statistics via sysfs

Add a sysfs directory at /sys/kernel/hwerr_recovery_stats/ to expose hardware error recovery statistics that are already tracked by the kernel. This allows userspace monitoring tools to track recovered hardware errors without requiring kernel crashes.

This is useful to track recoverable hardware errors in a time series, even if the host doesn't crash.

The sysfs directory contains one file per error subsystem:

  /sys/kernel/hwerr_recovery_stats/cpu     - CPU-related errors (MCE, ARM errors)
  /sys/kernel/hwerr_recovery_stats/memory  - Memory-related errors
  /sys/kernel/hwerr_recovery_stats/pci     - PCI/PCIe AER non-fatal errors
  /sys/kernel/hwerr_recovery_stats/cxl     - CXL errors
  /sys/kernel/hwerr_recovery_stats/others  - Other hardware errors

Each file contains a single integer representing the count of recovered errors for that subsystem.

These statistics provide visibility into the health of the system's hardware and can be used by system administrators to proactively detect failing components before they cause system crashes.

---
 kernel/vmcore_info.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
kernel/vmcore_info.c +55 -0
index e2784038bbed7..b7fcd21be7c59 100644
@@ -6,6 +6,8 @@
 
 #include <linux/buildid.h>
 #include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
 #include <linux/utsname.h>
 #include <linux/vmalloc.h>
 #include <linux/sizes.h>
@@ -139,6 +141,56 @@ void hwerr_log_error_type(enum hwerr_error_type src)
 }
 EXPORT_SYMBOL_GPL(hwerr_log_error_type);
 
+/* sysfs interface for hardware error recovery statistics */
+#define HWERR_ATTR_RO(_name, _type)					\
+static ssize_t _name##_show(struct kobject *kobj,			\
+			    struct kobj_attribute *attr, char *buf)	\
+{									\
+	return sysfs_emit(buf, "%d\n",					\
+			  atomic_read(&hwerr_data[_type].count));	\
+}									\
+static struct kobj_attribute hwerr_##_name##_attr = __ATTR_RO(_name)
+
+HWERR_ATTR_RO(cpu, HWERR_RECOV_CPU);
+HWERR_ATTR_RO(memory, HWERR_RECOV_MEMORY);
+HWERR_ATTR_RO(pci, HWERR_RECOV_PCI);
+HWERR_ATTR_RO(cxl, HWERR_RECOV_CXL);
+HWERR_ATTR_RO(others, HWERR_RECOV_OTHERS);
+
+static struct attribute *hwerr_recovery_stats_attrs[] = {
+	&hwerr_cpu_attr.attr,
+	&hwerr_memory_attr.attr,
+	&hwerr_pci_attr.attr,
+	&hwerr_cxl_attr.attr,
+	&hwerr_others_attr.attr,
+	NULL,
+};
+
+static const struct attribute_group hwerr_recovery_stats_group = {
+	.attrs = hwerr_recovery_stats_attrs,
+};
+
+static struct kobject *hwerr_recovery_stats_kobj;
+
+static int __init hwerr_recovery_stats_init(void)
+{
+	hwerr_recovery_stats_kobj = kobject_create_and_add("hwerr_recovery_stats",
+							   kernel_kobj);
+	if (!hwerr_recovery_stats_kobj) {
+		pr_warn("Failed to create hwerr_recovery_stats kobject\n");
+		return -ENOMEM;
+	}
+
+	if (sysfs_create_group(hwerr_recovery_stats_kobj,
+			       &hwerr_recovery_stats_group)) {
+		kobject_put(hwerr_recovery_stats_kobj);
+		pr_warn("Failed to create hwerr_recovery_stats sysfs group\n");
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int __init crash_save_vmcoreinfo_init(void)
 {
 	vmcoreinfo_data = (unsigned char *)get_zeroed_page(GFP_KERNEL);
@@ -248,6 +300,9 @@ static int __init crash_save_vmcoreinfo_init(void)
 	arch_crash_save_vmcoreinfo();
 	update_vmcoreinfo_note();
 
+	/* Create /sys/kernel/hwerr_recovery_stats/ directory */
+	hwerr_recovery_stats_init();
+
 	return 0;
 }
 
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH v2 1/2] vmcoreinfo: expose hardware error recovery statistics via sysfs

Hi Breno,

kernel/vmcore_info.c

Quoted 32 lines · Breno Leitao

Add a sysfs directory at /sys/kernel/hwerr_recovery_stats/ to expose hardware error recovery statistics that are already tracked by the kernel. This allows userspace monitoring tools to track recovered hardware errors without requiring kernel crashes.

This is useful to track recoverable hardware errors in a time series, even if the host doesn't crash.

The sysfs directory contains one file per error subsystem:

  /sys/kernel/hwerr_recovery_stats/cpu     - CPU-related errors (MCE, ARM errors)
  /sys/kernel/hwerr_recovery_stats/memory  - Memory-related errors
  /sys/kernel/hwerr_recovery_stats/pci     - PCI/PCIe AER non-fatal errors
  /sys/kernel/hwerr_recovery_stats/cxl     - CXL errors
  /sys/kernel/hwerr_recovery_stats/others  - Other hardware errors

Each file contains a single integer representing the count of recovered errors for that subsystem.

These statistics provide visibility into the health of the system's hardware and can be used by system administrators to proactively detect failing components before they cause system crashes.

---
 kernel/vmcore_info.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
kernel/vmcore_info.c +0 -0
index e2784038bbed7..b7fcd21be7c59 100644

Since we agreed hwerr_recovery_stats has nothing to do with vmcore, it seems inappropriate to put its sysfs handling code in kernel/vmcore_info.c. File kernel/vmcore_info.c is only used to build vmcore info for later vmcore dumping. And hwerr_log_error_type() should not be put in kernel/vmcore_info.c. either. I didn't check this carefully before, sorry. Please reconsider if these can be handled better.

Thanks
Baoquan

Quoted 80 lines
kernel/vmcore_info.c +55 -0
@@ -6,6 +6,8 @@
 
 #include <linux/buildid.h>
 #include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
 #include <linux/utsname.h>
 #include <linux/vmalloc.h>
 #include <linux/sizes.h>
@@ -139,6 +141,56 @@ void hwerr_log_error_type(enum hwerr_error_type src)
 }
 EXPORT_SYMBOL_GPL(hwerr_log_error_type);
 
+/* sysfs interface for hardware error recovery statistics */
+#define HWERR_ATTR_RO(_name, _type)					\
+static ssize_t _name##_show(struct kobject *kobj,			\
+			    struct kobj_attribute *attr, char *buf)	\
+{									\
+	return sysfs_emit(buf, "%d\n",					\
+			  atomic_read(&hwerr_data[_type].count));	\
+}									\
+static struct kobj_attribute hwerr_##_name##_attr = __ATTR_RO(_name)
+
+HWERR_ATTR_RO(cpu, HWERR_RECOV_CPU);
+HWERR_ATTR_RO(memory, HWERR_RECOV_MEMORY);
+HWERR_ATTR_RO(pci, HWERR_RECOV_PCI);
+HWERR_ATTR_RO(cxl, HWERR_RECOV_CXL);
+HWERR_ATTR_RO(others, HWERR_RECOV_OTHERS);
+
+static struct attribute *hwerr_recovery_stats_attrs[] = {
+	&hwerr_cpu_attr.attr,
+	&hwerr_memory_attr.attr,
+	&hwerr_pci_attr.attr,
+	&hwerr_cxl_attr.attr,
+	&hwerr_others_attr.attr,
+	NULL,
+};
+
+static const struct attribute_group hwerr_recovery_stats_group = {
+	.attrs = hwerr_recovery_stats_attrs,
+};
+
+static struct kobject *hwerr_recovery_stats_kobj;
+
+static int __init hwerr_recovery_stats_init(void)
+{
+	hwerr_recovery_stats_kobj = kobject_create_and_add("hwerr_recovery_stats",
+							   kernel_kobj);
+	if (!hwerr_recovery_stats_kobj) {
+		pr_warn("Failed to create hwerr_recovery_stats kobject\n");
+		return -ENOMEM;
+	}
+
+	if (sysfs_create_group(hwerr_recovery_stats_kobj,
+			       &hwerr_recovery_stats_group)) {
+		kobject_put(hwerr_recovery_stats_kobj);
+		pr_warn("Failed to create hwerr_recovery_stats sysfs group\n");
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int __init crash_save_vmcoreinfo_init(void)
 {
 	vmcoreinfo_data = (unsigned char *)get_zeroed_page(GFP_KERNEL);
@@ -248,6 +300,9 @@ static int __init crash_save_vmcoreinfo_init(void)
 	arch_crash_save_vmcoreinfo();
 	update_vmcoreinfo_note();
 
+	/* Create /sys/kernel/hwerr_recovery_stats/ directory */
+	hwerr_recovery_stats_init();
+
 	return 0;
 }
 
Signature · 2 lines
-- 
2.47.3
#3 lore raw

Re: [PATCH v2 1/2] vmcoreinfo: expose hardware error recovery statistics via sysfs

Hello Baoquan,

Quoted 29 lines · Baoquan He
Quoted 28 lines · Breno Leitao

Add a sysfs directory at /sys/kernel/hwerr_recovery_stats/ to expose hardware error recovery statistics that are already tracked by the kernel. This allows userspace monitoring tools to track recovered hardware errors without requiring kernel crashes.

This is useful to track recoverable hardware errors in a time series, even if the host doesn't crash.

The sysfs directory contains one file per error subsystem:

  /sys/kernel/hwerr_recovery_stats/cpu     - CPU-related errors (MCE, ARM errors)
  /sys/kernel/hwerr_recovery_stats/memory  - Memory-related errors
  /sys/kernel/hwerr_recovery_stats/pci     - PCI/PCIe AER non-fatal errors
  /sys/kernel/hwerr_recovery_stats/cxl     - CXL errors
  /sys/kernel/hwerr_recovery_stats/others  - Other hardware errors

Each file contains a single integer representing the count of recovered errors for that subsystem.

These statistics provide visibility into the health of the system's hardware and can be used by system administrators to proactively detect failing components before they cause system crashes.

---
 kernel/vmcore_info.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
Quoted 11 lines

kernel/vmcore_info.c

Quoted 4 lines
kernel/vmcore_info.c +0 -0
index e2784038bbed7..b7fcd21be7c59 100644

Since we agreed hwerr_recovery_stats has nothing to do with vmcore, it seems inappropriate to put its sysfs handling code in kernel/vmcore_info.c. File kernel/vmcore_info.c is only used to build vmcore info for later vmcore dumping. And hwerr_log_error_type() should not be put in kernel/vmcore_info.c. either. I didn't check this carefully before, sorry. Please reconsider if these can be handled better.

I've sent an RFC to move it to RAS code, which I think it belongs better. Does it make more sense?

https://lore.kernel.org/all/[email protected]/

Thanks,
--breno

Acked-by
#4 lore raw

Re: [PATCH v2 1/2] vmcoreinfo: expose hardware error recovery statistics via sysfs

Quoted 44 lines · Breno Leitao

Hello Baoquan,

Quoted 29 lines · Baoquan He
Quoted 28 lines · Breno Leitao

Add a sysfs directory at /sys/kernel/hwerr_recovery_stats/ to expose hardware error recovery statistics that are already tracked by the kernel. This allows userspace monitoring tools to track recovered hardware errors without requiring kernel crashes.

This is useful to track recoverable hardware errors in a time series, even if the host doesn't crash.

The sysfs directory contains one file per error subsystem:

  /sys/kernel/hwerr_recovery_stats/cpu     - CPU-related errors (MCE, ARM errors)
  /sys/kernel/hwerr_recovery_stats/memory  - Memory-related errors
  /sys/kernel/hwerr_recovery_stats/pci     - PCI/PCIe AER non-fatal errors
  /sys/kernel/hwerr_recovery_stats/cxl     - CXL errors
  /sys/kernel/hwerr_recovery_stats/others  - Other hardware errors

Each file contains a single integer representing the count of recovered errors for that subsystem.

These statistics provide visibility into the health of the system's hardware and can be used by system administrators to proactively detect failing components before they cause system crashes.

---
 kernel/vmcore_info.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
Quoted 11 lines

kernel/vmcore_info.c

Quoted 4 lines
kernel/vmcore_info.c +0 -0
index e2784038bbed7..b7fcd21be7c59 100644

Since we agreed hwerr_recovery_stats has nothing to do with vmcore, it seems inappropriate to put its sysfs handling code in kernel/vmcore_info.c. File kernel/vmcore_info.c is only used to build vmcore info for later vmcore dumping. And hwerr_log_error_type() should not be put in kernel/vmcore_info.c. either. I didn't check this carefully before, sorry. Please reconsider if these can be handled better.

Quoted 4 lines

I've sent an RFC to move it to RAS code, which I think it belongs better. Does it make more sense?

https://lore.kernel.org/all/[email protected]/

Dude, you pinged me but didn't add me in patch posting thread. It at least should be CC-ed to kexec mailing list since there's code change in kernel/vmcoreinfo.c.

Anyway, I am glad to see it's been taken out of vmcoreinfo.c, which is going in the right way from kdump side. For its migrating into driver folder, leave it to the relevant reviewer to review and decide.

For kdump part,

Thanks
Baoquan

#5 lore raw

Re: [PATCH v2 1/2] vmcoreinfo: expose hardware error recovery statistics via sysfs

Quoted 4 lines · Baoquan He

Anyway, I am glad to see it's been taken out of vmcoreinfo.c, which is going in the right way from kdump side. For its migrating into driver folder, leave it to the relevant reviewer to review and decide.

On that patch, If you could confirm that moving it away from vmcoreinfo is the preferred approach, that would help establish consensus around the right direction.

Thanks,
--breno

#6 lore raw

Re: [PATCH v2 1/2] vmcoreinfo: expose hardware error recovery statistics via sysfs

Quoted 10 lines · Breno Leitao
Quoted 4 lines · Baoquan He

Anyway, I am glad to see it's been taken out of vmcoreinfo.c, which is going in the right way from kdump side. For its migrating into driver folder, leave it to the relevant reviewer to review and decide.

On that patch, If you could confirm that moving it away from vmcoreinfo is the preferred approach, that would help establish consensus around the right direction.

Yes, I can confirm moving it away from vmcoreinfo is expected.

#7 lore raw

PATCH v2 2/2 docs: add ABI documentation for /sys/kernel/hwerr_recovery_stats/

In reply to Breno Leitao

Document the new hwerr_recovery_stats sysfs directory that exposes hardware error recovery statistics.

Update hw-recoverable-errors.rst to reference the new sysfs interface for runtime monitoring.

---
 .../ABI/testing/sysfs-kernel-hwerr_recovery_stats  | 47 ++++++++++++++++++++++
 Documentation/driver-api/hw-recoverable-errors.rst |  3 +-
 2 files changed, 49 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-kernel-hwerr_recovery_stats new file +47 -0
new file mode 100644
index 0000000000000..4cb9f5a89fba9
@@ -0,0 +1,47 @@
+What:		/sys/kernel/hwerr_recovery_stats/
+Date:		February 2026
+KernelVersion:	6.20
+Contact:	Breno Leitao <[email protected]>
+Description:
+		Directory containing hardware error recovery statistics.
+		These statistics track recoverable hardware errors that the
+		kernel has handled since boot.
+
+		Each file contains a single integer representing the count
+		of recovered errors for that subsystem.
+
+What:		/sys/kernel/hwerr_recovery_stats/cpu
+Date:		February 2026
+KernelVersion:	6.20
+Contact:	Breno Leitao <[email protected]>
+Description:
+		Count of CPU-related recovered errors (MCE, ARM processor
+		errors).
+
+What:		/sys/kernel/hwerr_recovery_stats/memory
+Date:		February 2026
+KernelVersion:	6.20
+Contact:	Breno Leitao <[email protected]>
+Description:
+		Count of memory-related recovered errors.
+
+What:		/sys/kernel/hwerr_recovery_stats/pci
+Date:		February 2026
+KernelVersion:	6.20
+Contact:	Breno Leitao <[email protected]>
+Description:
+		Count of PCI/PCIe AER non-fatal recovered errors.
+
+What:		/sys/kernel/hwerr_recovery_stats/cxl
+Date:		February 2026
+KernelVersion:	6.20
+Contact:	Breno Leitao <[email protected]>
+Description:
+		Count of CXL (Compute Express Link) recovered errors.
+
+What:		/sys/kernel/hwerr_recovery_stats/others
+Date:		February 2026
+KernelVersion:	6.20
+Contact:	Breno Leitao <[email protected]>
+Description:
+		Count of other hardware recovered errors.
Documentation/driver-api/hw-recoverable-errors.rst +2 -1
index fc526c3454bd7..4aefcd103be22 100644
@@ -36,7 +36,8 @@ Data Exposure and Consumption
   types like CPU, memory, PCI, CXL, and others.
 - It is exposed via vmcoreinfo crash dump notes and can be read using tools
   like `crash`, `drgn`, or other kernel crash analysis utilities.
-- There is no other way to read these data other than from crash dumps.
+- It is also exposed via sysfs at ``/sys/kernel/hwerr_recovery_stats/`` for runtime
+  monitoring without requiring a crash dump.
 - These errors are divided by area, which includes CPU, Memory, PCI, CXL and
   others.
 
Signature · 1 line
2.47.3
#8 lore raw
In reply to Breno Leitao

Hello Andrew,

Quoted 11 lines · Breno Leitao

The kernel already tracks recoverable hardware errors (CPU, memory, PCI, CXL, etc.) in the hwerr_data array for vmcoreinfo crash dump analysis. However, this data is only accessible after a crash.

This series adds a sysfs directory at /sys/kernel/hwerr_recovery_stats/ to expose these statistics at runtime, allowing monitoring tools to track hardware health without requiring a kernel crash.

The directory contains one file per error subsystem:
/sys/kernel/hwerr_recovery_stats/{cpu, memory, pci, cxl, others}

Quoted 6 lines

Each file contains a single integer representing the error count.

This is useful for:
- Proactive detection of failing hardware components
- Time-series tracking of recoverable errors
- System health monitoring in cloud environments

Is there a chance this could be included in the 6.20 merge window?

Thanks,
--breno

#9 lore raw
Quoted 14 lines · On Tue, 10 Feb 2026 01:11:41 -0800 Breno Leitao <[email protected]> wrote:

Hello Andrew,

Quoted 11 lines · Breno Leitao

The kernel already tracks recoverable hardware errors (CPU, memory, PCI, CXL, etc.) in the hwerr_data array for vmcoreinfo crash dump analysis. However, this data is only accessible after a crash.

This series adds a sysfs directory at /sys/kernel/hwerr_recovery_stats/ to expose these statistics at runtime, allowing monitoring tools to track hardware health without requiring a kernel crash.

The directory contains one file per error subsystem:
/sys/kernel/hwerr_recovery_stats/{cpu, memory, pci, cxl, others}

Quoted 8 lines
Quoted 6 lines

Each file contains a single integer representing the error count.

This is useful for:
- Proactive detection of failing hardware components
- Time-series tracking of recoverable errors
- System health monitoring in cloud environments

Is there a chance this could be included in the 6.20 merge window?

During the 7.0 merge window? Sure. I'll be taking a look at this (and a whole lot more) after 7.0-rc1 is released.