powerpc/mce: Remove per cpu variables from MCE handlers
PATCH v3 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.
---
v2: Dynamically allocate memory for machine check event info
v3: Remove check for hash mmu lpar, use memblock_alloc_try_nid
to allocate memory.
--- arch/powerpc/include/asm/mce.h | 21 ++++++++- arch/powerpc/include/asm/paca.h | 4 ++ arch/powerpc/kernel/mce.c | 76 +++++++++++++++++------------- arch/powerpc/kernel/setup-common.c | 2 +- 4 files changed, 69 insertions(+), 34 deletions(-)
arch/powerpc/include/asm/mce.h +20 -1
@@ -204,7 +204,18 @@ struct mce_error_info {bool ignore_event; }; -#define MAX_MC_EVT 100 +#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
@@ -233,5 +244,13 @@ long __machine_check_early_realmode_p7(struct pt_regs *regs);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); +#define get_mce_info () local_paca->mce_info +#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
@@ -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 +44 -32
164 lines not on this page · raw message
arch/powerpc/kernel/setup-common.c +1 -1
@@ -916,7 +916,6 @@ void __init setup_arch(char **cmdline_p)/* On BookE, setup per-core TLB data structures. */ setup_tlb_core_data ();#endif -/* Print various info about the machine that has been gathered so far. */ print_system_info ();
@@ -938,6 +937,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
Nicholas Piggin
reviewerExcerpts from Ganesh Goudar's message of January 15, 2021 10:58 pm:
Quoted 7 lines
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.
Seems okay.
Quoted 3 lines
Maximum recursive depth of MCE is 4, Considering the maximum depth allowed reduce the size of event to 10 from 100.
Could you make this a separate patch, with memory saving numbers? "Delayed" MCEs are not necessarily the same as recursive (several sequential MCEs can occur before the first event is processed). But I agree 100 is pretty overboard (as is 4 recursive MCEs really).
Quoted 40 lines
Signed-off-by Ganesh Goudar <[email protected]>---
v2: Dynamically allocate memory for machine check event infov3: Remove check for hash mmu lpar, use
memblock_alloc_try_nid
to allocate memory.--- arch/powerpc/include/asm/mce.h | 21 ++++++++- arch/powerpc/include/asm/paca.h | 4 ++ arch/powerpc/kernel/mce.c | 76 +++++++++++++++++------------- arch/powerpc/kernel/setup-common.c | 2 +- 4 files changed, 69 insertions(+), 34 deletions(-)arch/powerpc/include/asm/mce.h +12
-1@@ -204,7 +204,18 @@ struct mce_error_info {bool ignore_event; }; -#define MAX_MC_EVT 100 +#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_RELEASEtrue
arch/powerpc/include/asm/mce.h long __machine_check_early_realmode_p7(struct pt_regs *regs); · line 247
Quoted 4 lines
arch/powerpc/include/asm/mce.h +1
-0@@ -233,5 +244,13 @@ long __machine_check_early_realmode_p7(struct pt_regs *regs);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); +#define get_mce_info () local_paca->mce_info
I don't think this adds anything. Could you open code it?
Thanks,
Nick
Quoted 8 lines · Nicholas Piggin
Excerpts from Ganesh Goudar's message of January 15, 2021 10:58 pm:
Quoted 7 lines
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.
Quoted 8 lines
Seems okay.
Quoted 2 lines
Maximum recursive depth of MCE is 4, Considering the maximum depth allowed reduce the size of event to 10 from 100.
Could you make this a separate patch, with memory saving numbers? "Delayed" MCEs are not necessarily the same as recursive (several sequential MCEs can occur before the first event is processed). But I agree 100 is pretty overboard (as is 4 recursive MCEs really).
Sure.
Quoted 35 lines
Quoted 35 lines
Signed-off-by Ganesh Goudar <[email protected]>---
v2: Dynamically allocate memory for machine check event infov3: Remove check for hash mmu lpar, use
memblock_alloc_try_nid
to allocate memory.--- arch/powerpc/include/asm/mce.h | 21 ++++++++- arch/powerpc/include/asm/paca.h | 4 ++ arch/powerpc/kernel/mce.c | 76 +++++++++++++++++------------- arch/powerpc/kernel/setup-common.c | 2 +- 4 files changed, 69 insertions(+), 34 deletions(-)arch/powerpc/include/asm/mce.h +12
-1@@ -204,7 +204,18 @@ struct mce_error_info {bool ignore_event; }; -#define MAX_MC_EVT 100 +#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 ]; +};
Quoted 8 lines
arch/powerpc/include/asm/mce.h long __machine_check_early_realmode_p7(struct pt_regs *regs); · line 247
Quoted 7 lines
arch/powerpc/include/asm/mce.h +1
-0/* Release flags for get_mce_event() */ #define MCE_EVENT_RELEASE true@@ -233,5 +244,13 @@ long __machine_check_early_realmode_p7(struct pt_regs *regs);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); +#define get_mce_info () local_paca->mce_infoI don't think this adds anything. Could you open code it?
ok
Quoted 2 lines
Thanks,
Nick