Skip to contentSkip to conversation

powerpc/mce: Reduce the size of event arrays

PATCH Applied Ganesh Goudar 2 participants 3 messages Jan 28, 2021 – Feb 3, 2021 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/2 powerpc/mce: Reduce the size of event arrays

Maximum recursive depth of MCE is 4, Considering the maximum depth allowed reduce the size of event to 10 from 100. This saves us ~19kB of memory and has no fatal consequences.

---
v4: This patch is a fragment of the orignal patch which is
split into two.

v5: No changes.

---
 arch/powerpc/include/asm/mce.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/mce.h +1 -1
index e6c27ae843dc..7d8b6679ec68 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
Signature · 1 line
2.26.2
#1 lore raw

PATCH v5 2/2 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.

---
v2: Dynamically allocate memory for machine check event info.

v3: Remove check for hash mmu lpar, use memblock_alloc_try_nid
to allocate memory.

v4: Spliting the patch into two.

v5: Fix build error for PPC32.

---
 arch/powerpc/include/asm/mce.h     | 18 +++++++
 arch/powerpc/include/asm/paca.h    |  4 ++
 arch/powerpc/kernel/mce.c          | 79 ++++++++++++++++++------------
 arch/powerpc/kernel/setup-common.c |  2 +
 4 files changed, 71 insertions(+), 32 deletions(-)
arch/powerpc/include/asm/mce.h +18 -0
index 7d8b6679ec68..331d944280b8 100644
@@ -206,6 +206,17 @@ struct mce_error_info {
 
 #define MAX_MC_EVT	10
 
+struct mce_info {
+	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];
+};
+
 /* Release flags for get_mce_event() */
 #define MCE_EVENT_RELEASE	true
 #define MCE_EVENT_DONTRELEASE	false
@@ -234,4 +245,11 @@ long __machine_check_early_realmode_p8(struct pt_regs *regs);
 long __machine_check_early_realmode_p9(struct pt_regs *regs);
 long __machine_check_early_realmode_p10(struct pt_regs *regs);
 #endif /* CONFIG_PPC_BOOK3S_64 */
+
+#ifdef CONFIG_PPC_BOOK3S_64
+void mce_init(void);
+#else
+static inline void mce_init(void) { };
+#endif /* CONFIG_PPC_BOOK3S_64 */
+
 #endif /* __ASM_PPC64_MCE_H__ */
arch/powerpc/include/asm/paca.h +4 -0
index 9454d29ff4b4..38e0c55e845d 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,9 @@ struct paca_struct {
 #ifdef CONFIG_MMIOWB
 	struct mmiowb_state mmiowb_state;
 #endif
+#ifdef CONFIG_PPC_BOOK3S_64
+	struct mce_info *mce_info;
+#endif /* CONFIG_PPC_BOOK3S_64 */
 } ____cacheline_aligned;
 
 extern void copy_mm_to_paca(struct mm_struct *mm);
arch/powerpc/kernel/mce.c +47 -32

168 lines not on this page · raw message

arch/powerpc/kernel/setup-common.c +2 -0
index 71f38e9248be..d480f091e0ad 100644
@@ -64,6 +64,7 @@
 #include <asm/mmu_context.h>
 #include <asm/cpu_has_feature.h>
 #include <asm/kasan.h>
+#include <asm/mce.h>
 
 #include "setup.h"
 
@@ -938,6 +939,7 @@ void __init setup_arch(char **cmdline_p)
 	exc_lvl_early_init();
 	emergency_stack_init();
 
+	mce_init();
 	smp_release_cpus();
 
 	initmem_init();
Signature · 1 line
2.26.2
#2 lore raw
In reply to Ganesh Goudar
Quoted 3 lines · Ganesh Goudar

Maximum recursive depth of MCE is 4, Considering the maximum depth allowed reduce the size of event to 10 from 100. This saves us ~19kB of memory and has no fatal consequences.

Applied to powerpc/next.

[1/2] powerpc/mce: Reduce the size of event arrays

      https://git.kernel.org/powerpc/c/17c5cf0fb993e219bda4f53aa9ec90d3cfcf92ab
[2/2] powerpc/mce: Remove per cpu variables from MCE handlers
      https://git.kernel.org/powerpc/c/923b3cf00b3ffc896543bac99affc0fa8553e41a

cheers