Skip to contentSkip to conversation

powerpc/mce: Remove per cpu variables from MCE handlers

PATCH Superseded Ganesh Goudar 3 participants 5 messages Dec 4, 2020 – Dec 9, 2020 PowerPC

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/mce: Remove per cpu variables from MCE handlers

Access to per-cpu variables requires translation to be enabled on pseries machine running in hash mmu mode, Since part of MCE handler runs in realmode and part of MCE handling code is shared between ppc architectures pseries and powernv, it becomes difficult to manage these variables differently on different architectures, So have these variables in paca instead of having them as per-cpu variables to avoid complications.

Maximum recursive depth of MCE is 4, Considering the maximum depth allowed reduce the size of event to 10 from 100.

---
 arch/powerpc/include/asm/mce.h  |  2 +-
 arch/powerpc/include/asm/paca.h | 12 ++++++++
 arch/powerpc/kernel/mce.c       | 54 +++++++++++++--------------------
 3 files changed, 34 insertions(+), 34 deletions(-)
arch/powerpc/include/asm/mce.h +1 -1
index 89aa8248a57d..feef45f2b51b 100644
@@ -204,7 +204,7 @@ struct mce_error_info {
 	bool			ignore_event;
 };
 
-#define MAX_MC_EVT	100
+#define MAX_MC_EVT	10
 
 /* Release flags for get_mce_event() */
 #define MCE_EVENT_RELEASE	true
arch/powerpc/include/asm/paca.h +12 -0
index 9454d29ff4b4..4769954efa7d 100644
@@ -29,6 +29,7 @@
 #include <asm/hmi.h>
 #include <asm/cpuidle.h>
 #include <asm/atomic.h>
+#include <asm/mce.h>
 
 #include <asm-generic/mmiowb_types.h>
 
@@ -273,6 +274,17 @@ struct paca_struct {
 #ifdef CONFIG_MMIOWB
 	struct mmiowb_state mmiowb_state;
 #endif
+#ifdef CONFIG_PPC_BOOK3S_64
+	int mce_nest_count;
+	struct machine_check_event mce_event[MAX_MC_EVT];
+	/* Queue for delayed MCE events. */
+	int mce_queue_count;
+	struct machine_check_event mce_event_queue[MAX_MC_EVT];
+
+	/* Queue for delayed MCE UE events. */
+	int mce_ue_count;
+	struct machine_check_event  mce_ue_event_queue[MAX_MC_EVT];
+#endif /* CONFIG_PPC_BOOK3S_64 */
 } ____cacheline_aligned;
 
 extern void copy_mm_to_paca(struct mm_struct *mm);
arch/powerpc/kernel/mce.c +21 -33

134 lines not on this page · raw message

Signature · 1 line
2.26.2
#1 lore raw
Quoted 10 lines · Ganesh Goudar
arch/powerpc/include/asm/paca.h +2 -0
index 9454d29ff4b4..4769954efa7d 100644
@@ -273,6 +274,17 @@ struct paca_struct {
 #ifdef CONFIG_MMIOWB
 	struct mmiowb_state mmiowb_state;
 #endif
+#ifdef CONFIG_PPC_BOOK3S_64
+	int mce_nest_count;

arch/powerpc/include/asm/paca.h struct paca_struct { · line 288

Quoted 10 lines
arch/powerpc/include/asm/paca.h +9 -0
+	struct machine_check_event mce_event[MAX_MC_EVT];
+	/* Queue for delayed MCE events. */
+	int mce_queue_count;
+	struct machine_check_event mce_event_queue[MAX_MC_EVT];
+
+	/* Queue for delayed MCE UE events. */
+	int mce_ue_count;
+	struct machine_check_event  mce_ue_event_queue[MAX_MC_EVT];
+#endif /* CONFIG_PPC_BOOK3S_64 */
 } ____cacheline_aligned;

How much does this expand the paca by?

pahole can tell you.

cheers

author
#2 lore raw
Quoted 14 lines · Michael Ellerman
Quoted 13 lines · Ganesh Goudar
arch/powerpc/include/asm/paca.h +5 -0
index 9454d29ff4b4..4769954efa7d 100644
@@ -273,6 +274,17 @@ struct paca_struct {
  #ifdef CONFIG_MMIOWB
  	struct mmiowb_state mmiowb_state;
  #endif
+#ifdef CONFIG_PPC_BOOK3S_64
+	int mce_nest_count;
+	struct machine_check_event mce_event[MAX_MC_EVT];
+	/* Queue for delayed MCE events. */
+	int mce_queue_count;
Quoted 8 lines

arch/powerpc/include/asm/paca.h struct paca_struct { · line 288

Quoted 7 lines
arch/powerpc/include/asm/paca.h +6 -0
+	struct machine_check_event mce_event_queue[MAX_MC_EVT];
+
+	/* Queue for delayed MCE UE events. */
+	int mce_ue_count;
+	struct machine_check_event  mce_ue_event_queue[MAX_MC_EVT];
+#endif /* CONFIG_PPC_BOOK3S_64 */
  } ____cacheline_aligned;

How much does this expand the paca by?

Size of paca is 4480 bytes, these add up another 2160 bytes, so expands it by 48%.

#3 lore raw
Quoted 26 lines · Ganesh
Quoted 15 lines · Michael Ellerman
Quoted 14 lines · Ganesh Goudar
arch/powerpc/include/asm/paca.h +5 -0
index 9454d29ff4b4..4769954efa7d 100644
@@ -273,6 +274,17 @@ struct paca_struct {
   #ifdef CONFIG_MMIOWB
       struct mmiowb_state mmiowb_state;
   #endif
+#ifdef CONFIG_PPC_BOOK3S_64
+    int mce_nest_count;
+    struct machine_check_event mce_event[MAX_MC_EVT];
+    /* Queue for delayed MCE events. */
+    int mce_queue_count;
Quoted 8 lines

arch/powerpc/include/asm/paca.h struct paca_struct { · line 288

Quoted 7 lines
arch/powerpc/include/asm/paca.h +6 -0
+    struct machine_check_event mce_event_queue[MAX_MC_EVT];
+
+    /* Queue for delayed MCE UE events. */
+    int mce_ue_count;
+    struct machine_check_event  mce_ue_event_queue[MAX_MC_EVT];
+#endif /* CONFIG_PPC_BOOK3S_64 */
   } ____cacheline_aligned;

How much does this expand the paca by?

Quoted 3 lines

Size of paca is 4480 bytes, these add up another 2160 bytes, so expands it by 48%.

Should we dynamically allocate the array sizes early as similar to that of paca->mce_faulty_slbs so that we don't bump up paca size ?

Thanks,
-Mahesh.

#4 lore raw
Quoted 27 lines · Mahesh Jagannath Salgaonkar
Quoted 26 lines · Ganesh
Quoted 23 lines · Michael Ellerman
Quoted 11 lines · Ganesh Goudar
arch/powerpc/include/asm/paca.h +2 -0
index 9454d29ff4b4..4769954efa7d 100644
@@ -273,6 +274,17 @@ struct paca_struct {
   #ifdef CONFIG_MMIOWB
       struct mmiowb_state mmiowb_state;
   #endif
+#ifdef CONFIG_PPC_BOOK3S_64
+    int mce_nest_count;

arch/powerpc/include/asm/paca.h struct paca_struct { · line 288

Quoted 10 lines
arch/powerpc/include/asm/paca.h +9 -0
+    struct machine_check_event mce_event[MAX_MC_EVT];
+    /* Queue for delayed MCE events. */
+    int mce_queue_count;
+    struct machine_check_event mce_event_queue[MAX_MC_EVT];
+
+    /* Queue for delayed MCE UE events. */
+    int mce_ue_count;
+    struct machine_check_event  mce_ue_event_queue[MAX_MC_EVT];
+#endif /* CONFIG_PPC_BOOK3S_64 */
   } ____cacheline_aligned;

How much does this expand the paca by?

Quoted 5 lines
Quoted 2 lines

Size of paca is 4480 bytes, these add up another 2160 bytes, so expands it by 48%.

Should we dynamically allocate the array sizes early as similar to that of paca->mce_faulty_slbs so that we don't bump up paca size ?

Yeah I think that would be preferable.

That way those allocations can be normal node-local allocations on bare metal, or when using radix. (Or even on KVM).

In fact what we probably want is a separate struct for all the MCE related data, eg something like:

struct mce_stuff {
int nest_count;
/* Queue for delayed MCE events. */
int queue_count;
/* Queue for delayed MCE UE events. */
int mce_ue_count;

struct machine_check_event events[MAX_MC_EVT]; struct machine_check_event event_queue[MAX_MC_EVT]; struct machine_check_event  ue_event_queue[MAX_MC_EVT];
};

And then you allocate one of those per CPU, inside the RMO for pseries with hash, and node-local otherwise.

cheers