Skip to contentSkip to conversation

powerpc/mce: Add MCE notification chain

PATCH In review Ganesh Goudar 3 participants 6 messages Mar 30, 2020 – May 4, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/mce: Add MCE notification chain

From: Santosh S <[email protected]>

Introduce notification chain which lets know about uncorrected memory errors(UE). This would help prospective users in pmem or nvdimm subsystem to track bad blocks for better handling of persistent memory allocations.

---
 arch/powerpc/include/asm/mce.h |  2 ++
 arch/powerpc/kernel/mce.c      | 15 +++++++++++++++
 2 files changed, 17 insertions(+)
arch/powerpc/include/asm/mce.h +2 -0
index 6a6ddaabdb34..6e222a94a68a 100644
@@ -218,6 +218,8 @@ extern void machine_check_queue_event(void);
 extern void machine_check_print_event_info(struct machine_check_event *evt,
 					   bool user_mode, bool in_guest);
 unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr);
+int mce_register_notifier(struct notifier_block *nb);
+int mce_unregister_notifier(struct notifier_block *nb);
 #ifdef CONFIG_PPC_BOOK3S_64
 void flush_and_reload_slb(void);
 #endif /* CONFIG_PPC_BOOK3S_64 */
arch/powerpc/kernel/mce.c +15 -0
index 34c1001e9e8b..f50d7f56c02c 100644
@@ -47,6 +47,20 @@ static struct irq_work mce_ue_event_irq_work = {
 
 DECLARE_WORK(mce_ue_event_work, machine_process_ue_event);
 
+static BLOCKING_NOTIFIER_HEAD(mce_notifier_list);
+
+int mce_register_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&mce_notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(mce_register_notifier);
+
+int mce_unregister_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(&mce_notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(mce_unregister_notifier);
+
 static void mce_set_error_info(struct machine_check_event *mce,
 			       struct mce_error_info *mce_err)
 {
@@ -263,6 +277,7 @@ static void machine_process_ue_event(struct work_struct *work)
 	while (__this_cpu_read(mce_ue_count) > 0) {
 		index = __this_cpu_read(mce_ue_count) - 1;
 		evt = this_cpu_ptr(&mce_ue_event_queue[index]);
+		blocking_notifier_call_chain(&mce_notifier_list, 0, evt);
 #ifdef CONFIG_MEMORY_FAILURE
 		/*
 		 * This should probably queued elsewhere, but
Signature · 1 line
2.17.2
#1 lore raw

Ganesh Goudar's on March 30, 2020 5:12 pm:

Quoted 8 lines

From: Santosh S <[email protected]>

Introduce notification chain which lets know about uncorrected memory errors(UE). This would help prospective users in pmem or nvdimm subsystem to track bad blocks for better handling of persistent memory allocations.

Do you have any such users yet? It would be good to refer to an example user and give a brief description of what it does in its notifier.

arch/powerpc/kernel/mce.c static void machine_process_ue_event(struct work_struct *work) · line 280

Quoted 5 lines
arch/powerpc/kernel/mce.c +1 -0
@@ -263,6 +277,7 @@ static void machine_process_ue_event(struct work_struct *work)
 	while (__this_cpu_read(mce_ue_count) > 0) {
 		index = __this_cpu_read(mce_ue_count) - 1;
 		evt = this_cpu_ptr(&mce_ue_event_queue[index]);
+		blocking_notifier_call_chain(&mce_notifier_list, 0, evt);

Can we really use a blocking notifier here? I'm not sure that we can.

Thanks,
Nick

author
#2 lore raw
Quoted 11 lines · Nicholas Piggin

Ganesh Goudar's on March 30, 2020 5:12 pm:

Quoted 8 lines

From: Santosh S <[email protected]>

Introduce notification chain which lets know about uncorrected memory errors(UE). This would help prospective users in pmem or nvdimm subsystem to track bad blocks for better handling of persistent memory allocations.

Do you have any such users yet? It would be good to refer to an example user and give a brief description of what it does in its notifier.

Santosh has sent a patch which uses this notification.
https://patchwork.ozlabs.org/patch/1265062/

Quoted 6 lines

arch/powerpc/kernel/mce.c static void machine_process_ue_event(struct work_struct *work) · line 280

Quoted 5 lines
arch/powerpc/kernel/mce.c +1 -0
@@ -263,6 +277,7 @@ static void machine_process_ue_event(struct work_struct *work)
  	while (__this_cpu_read(mce_ue_count) > 0) {
  		index = __this_cpu_read(mce_ue_count) - 1;
  		evt = this_cpu_ptr(&mce_ue_event_queue[index]);
+		blocking_notifier_call_chain(&mce_notifier_list, 0, evt);

Can we really use a blocking notifier here? I'm not sure that we can.

I think we can, do you see any problem?

Quoted 3 lines

Thanks,
Nick

#3 lore raw

Ganesh's on April 4, 2020 11:05 pm:

Quoted 9 lines · Nicholas Piggin
Quoted 8 lines

Ganesh Goudar's on March 30, 2020 5:12 pm:

Quoted 6 lines

From: Santosh S <[email protected]>

Introduce notification chain which lets know about uncorrected memory errors(UE). This would help prospective users in pmem or nvdimm subsystem to track bad blocks for better handling of persistent memory allocations.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Do you have any such users yet? It would be good to refer to an example user and give a brief description of what it does in its notifier.

Santosh has sent a patch which uses this notification.
https://patchwork.ozlabs.org/patch/1265062/

Okay. So these things are asynchronous after the machine check. I guess that's the design of it and memory offlining does something similar by the looks, but how do you prevent the memory being allocated for something else before the notifiers run?

Quoted 8 lines
Quoted 6 lines

arch/powerpc/kernel/mce.c static void machine_process_ue_event(struct work_struct *work) · line 280

Quoted 5 lines
arch/powerpc/kernel/mce.c +1 -0
@@ -263,6 +277,7 @@ static void machine_process_ue_event(struct work_struct *work)
  	while (__this_cpu_read(mce_ue_count) > 0) {
  		index = __this_cpu_read(mce_ue_count) - 1;
  		evt = this_cpu_ptr(&mce_ue_event_queue[index]);
+		blocking_notifier_call_chain(&mce_notifier_list, 0, evt);

Can we really use a blocking notifier here? I'm not sure that we can.

I think we can, do you see any problem?

No it looks okay after better look, sorry for the noise.

Thanks,
Nick

#4 lore raw
Quoted 15 lines · Nicholas Piggin

Ganesh's on April 4, 2020 11:05 pm:

Quoted 14 lines · Nicholas Piggin
Quoted 12 lines

Ganesh Goudar's on March 30, 2020 5:12 pm:

Quoted 8 lines

From: Santosh S <[email protected]>

Introduce notification chain which lets know about uncorrected memory errors(UE). This would help prospective users in pmem or nvdimm subsystem to track bad blocks for better handling of persistent memory allocations.

Do you have any such users yet? It would be good to refer to an example user and give a brief description of what it does in its notifier.

Quoted 7 lines
Quoted 2 lines

Santosh has sent a patch which uses this notification.
https://patchwork.ozlabs.org/patch/1265062/

Okay. So these things are asynchronous after the machine check. I guess that's the design of it and memory offlining does something similar by the looks, but how do you prevent the memory being allocated for something else before the notifiers run?

We can't. This race even exists today when we call memory_failure(). If the same memory is allocated again then we may hit another mce on same address when touched until the subsystem that has resistered for notification has completed handling the notified address.

Thanks,
-Mahesh.

Quoted 14 lines
Quoted 9 lines
Quoted 7 lines

arch/powerpc/kernel/mce.c static void machine_process_ue_event(struct work_struct *work) · line 280

Quoted 6 lines
arch/powerpc/kernel/mce.c +1 -0
@@ -263,6 +277,7 @@ static void machine_process_ue_event(struct work_struct *work)
  	while (__this_cpu_read(mce_ue_count) > 0) {
  		index = __this_cpu_read(mce_ue_count) - 1;
  		evt = this_cpu_ptr(&mce_ue_event_queue[index]);
+		blocking_notifier_call_chain(&mce_notifier_list, 0, evt);

Can we really use a blocking notifier here? I'm not sure that we can.

I think we can, do you see any problem?

No it looks okay after better look, sorry for the noise.

Thanks,
Nick

Signature · 1 line
Mahesh J Salgaonkar
author
#5 lore raw
In reply to Ganesh Goudar
Quoted 9 lines · Ganesh Goudar

From: Santosh S <[email protected]>

Introduce notification chain which lets know about uncorrected memory errors(UE). This would help prospective users in pmem or nvdimm subsystem to track bad blocks for better handling of persistent memory allocations.

---

Hi mpe, Do you have any comments on this patch?