powerpc/pseries: Move VPHN constants into vphn.h
Subsystems (5)
Michael Ellerman
reviewerPATCH 1/4 powerpc/pseries: Move VPHN constants into vphn.h
These don't have any particularly good reason to belong in lppaca.h, move them into their own header.
--- arch/powerpc/include/asm/lppaca.h | 22 ------------------- arch/powerpc/include/asm/vphn.h | 22 +++++++++++++++++++ arch/powerpc/mm/numa.c | 1 + arch/powerpc/platforms/pseries/lpar.c | 1 + arch/powerpc/platforms/pseries/vas.c | 1 + arch/powerpc/platforms/pseries/vphn.c | 2 +- .../selftests/powerpc/vphn/asm/lppaca.h | 1 - .../testing/selftests/powerpc/vphn/asm/vphn.h | 1 + 8 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 arch/powerpc/include/asm/vphn.h delete mode 120000 tools/testing/selftests/powerpc/vphn/asm/lppaca.h create mode 120000 tools/testing/selftests/powerpc/vphn/asm/vphn.h
arch/powerpc/include/asm/lppaca.h +0 -22
@@ -6,28 +6,6 @@#ifndef _ASM_POWERPC_LPPACA_H#define _ASM_POWERPC_LPPACA_H -/* -* The below VPHN macros are outside the __KERNEL__ check since these are -* used for compiling the vphn selftest in userspace -*/ - -/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers. */ -#define VPHN_REGISTER_COUNT 6 - -/* -* 6 64-bit registers unpacked into up to 24 be32 associativity values. To -* form the complete property we have to add the length in the first cell. -*/ -#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u16) + 1) - -/* -* The H_HOME_NODE_ASSOCIATIVITY hcall takes two values for flags: -* 1 for retrieving associativity information for a guest cpu -* 2 for retrieving associativity information for a host/hypervisor cpu -*/ -#define VPHN_FLAG_VCPU 1 -#define VPHN_FLAG_PCPU 2 -#ifdef __KERNEL__/*
arch/powerpc/include/asm/vphn.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _ASM_POWERPC_VPHN_H +#define _ASM_POWERPC_VPHN_H + +/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers. */ +#define VPHN_REGISTER_COUNT 6 + +/* +* 6 64-bit registers unpacked into up to 24 be32 associativity values. To +* form the complete property we have to add the length in the first cell. +*/ +#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u16) + 1) + +/* +* The H_HOME_NODE_ASSOCIATIVITY hcall takes two values for flags: +* 1 for retrieving associativity information for a guest cpu +* 2 for retrieving associativity information for a host/hypervisor cpu +*/ +#define VPHN_FLAG_VCPU 1 +#define VPHN_FLAG_PCPU 2 + +#endif // _ASM_POWERPC_VPHN_H
arch/powerpc/mm/numa.c +1 -0
@@ -34,6 +34,7 @@#include <asm/hvcall.h> #include <asm/setup.h> #include <asm/vdso.h> +#include <asm/vphn.h> #include <asm/drmem.h> static int numa_enabled =1 ;
arch/powerpc/platforms/pseries/lpar.c +1 -0
@@ -41,6 +41,7 @@#include <asm/kexec.h> #include <asm/fadump.h> #include <asm/dtl.h> +#include <asm/vphn.h> #include "pseries.h"
arch/powerpc/platforms/pseries/vas.c +1 -0
@@ -17,6 +17,7 @@#include <asm/hvcall.h> #include <asm/plpar_wrappers.h> #include <asm/firmware.h> +#include <asm/vphn.h> #include <asm/vas.h> #include "vas.h"
arch/powerpc/platforms/pseries/vphn.c +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <asm/byteorder.h> -#include <asm/lppaca.h> +#include <asm/vphn.h> /* * The associativity domain numbers are returned from the hypervisor as a
tools/testing/selftests/powerpc/vphn/asm/lppaca.h deleted +0 -1
@@ -1 +0,0 @@ -../../../../../../arch/powerpc/include/asm/lppaca.h
tools/testing/selftests/powerpc/vphn/asm/vphn.h new file +1 -0
@@ -0,0 +1 @@ +../../../../../../arch/powerpc/include/asm/vphn.h
Signature · 1 line
2.41.0
Michael Ellerman
reviewerPATCH 2/4 powerpc/pseries: Move hcall_vphn() prototype into vphn.h
Consolidate the two prototypes for hcall_vphn() into vphn.h.
--- arch/powerpc/include/asm/dtl.h | 1 - arch/powerpc/include/asm/lppaca.h | 2 -- arch/powerpc/include/asm/vphn.h | 2 ++ 3 files changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/dtl.h +0 -1
@@ -39,6 +39,5 @@ extern rwlock_t dtl_access_lock;extern void register_dtl_buffer (int cpu);extern void alloc_dtl_buffers (unsigned long *time_limit); -extern long hcall_vphn (unsigned long cpu,u64 flags,__be32 *associativity);#endif /* _ASM_POWERPC_DTL_H */
arch/powerpc/include/asm/lppaca.h +0 -2
@@ -127,8 +127,6 @@ struct slb_shadow { } save_area[SLB_NUM_BOLTED]; } ____cacheline_aligned; -extern long hcall_vphn (unsigned long cpu,u64 flags,__be32 *associativity); -#endif /* CONFIG_PPC_BOOK3S */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_LPPACA_H */
arch/powerpc/include/asm/vphn.h +2 -0
@@ -19,4 +19,6 @@#define VPHN_FLAG_VCPU 1#define VPHN_FLAG_PCPU 2 +long hcall_vphn (unsigned long cpu,u64 flags,__be32 *associativity); +#endif // _ASM_POWERPC_VPHN_H
Signature · 1 line
2.41.0
Michael Ellerman
reviewerPATCH v2 4/4 powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT
In reply to Michael EllermanFrom: Russell Currey <[email protected]>
lppaca_shared_proc() takes a pointer to the lppaca which is typically accessed through get_lppaca(). With DEBUG_PREEMPT enabled, this leads to checking if preemption is enabled, for example:
BUG: using smp_processor_id() in preemptible [00000000] code: grep/10693
caller is lparcfg_data+0x408/0x19a0
CPU: 4 PID: 10693 Comm: grep Not tainted 6.5.0-rc3 #2
Call Trace:
dump_stack_lvl+0x154/0x200 (unreliable)
check_preemption_disabled+0x214/0x220
lparcfg_data+0x408/0x19a0
...This isn't actually a problem however, as it does not matter which lppaca is accessed, the shared proc state will be the same. vcpudispatch_stats_procfs_init() already works around this by disabling preemption, but the lparcfg code does not, erroring any time /proc/powerpc/lparcfg is accessed with DEBUG_PREEMPT enabled.
Instead of disabling preemption on the caller side, rework lppaca_shared_proc() to not take a pointer and instead directly access the lppaca, bypassing any potential preemption checks.
--- arch/powerpc/include/asm/lppaca.h | 11 +++++++++-- arch/powerpc/platforms/pseries/lpar.c | 10 +--------- arch/powerpc/platforms/pseries/lparcfg.c | 4 ++-- arch/powerpc/platforms/pseries/setup.c | 2 +- drivers/cpuidle/cpuidle-pseries.c | 8 +------- 5 files changed, 14 insertions(+), 21 deletions(-)
v2: mpe, rework based on the preceeding header untangling patches.
arch/powerpc/include/asm/lppaca.h +9 -2
@@ -23,6 +23,7 @@#include <asm/types.h> #include <asm/mmu.h> #include <asm/firmware.h> +#include <asm/paca.h> /* * The lppaca is the "virtual processor area" registered with the hypervisor,
@@ -105,14 +106,20 @@ struct lppaca {*/ #define LPPACA_OLD_SHARED_PROC 2 -static inline bool lppaca_shared_proc (struct lppaca *l) +#ifdef CONFIG_PPC_PSERIES +/* +* All CPUs should have the same shared proc value, so directly access the PACA +* to avoid false positives from DEBUG_PREEMPT. +*/ +static inline bool lppaca_shared_proc (void ) { +struct lppaca *l = local_paca->lppaca_ptr; +if (!firmware_has_feature (FW_FEATURE_SPLPAR ))return false;return !!(l->__old_status &LPPACA_OLD_SHARED_PROC ); } -#ifdef CONFIG_PPC_PSERIES #define get_lppaca () (get_paca()->lppaca_ptr)#endif
arch/powerpc/platforms/pseries/lpar.c +1 -9
@@ -640,16 +640,8 @@ static const struct proc_ops vcpudispatch_stats_freq_proc_ops = {static int __init vcpudispatch_stats_procfs_init (void ) { -/* -* Avoid smp_processor_id while preemptible. All CPUs should have -* the same value for lppaca_shared_proc. -*/ -preempt_disable (); -if (!lppaca_shared_proc (get_lppaca ())) { -preempt_enable (); +if (!lppaca_shared_proc ())return 0 ; - } -preempt_enable ();if (!proc_create ("powerpc/vcpudispatch_stats" ,0600 ,NULL , &vcpudispatch_stats_proc_ops))
arch/powerpc/platforms/pseries/lparcfg.c +2 -2
@@ -206,7 +206,7 @@ static void parse_ppp_data(struct seq_file *m) ppp_data.active_system_procs);/* pool related entries are appropriate for shared configs */ -if (lppaca_shared_proc (get_lppaca ())) { +if (lppaca_shared_proc ()) {unsigned long pool_idle_time, pool_procs;seq_printf (m,"pool=%d\n" , ppp_data.pool_num);
@@ -560,7 +560,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v) partition_potential_processors);seq_printf (m,"shared_processor_mode=%d\n" , -lppaca_shared_proc (get_lppaca ())); +lppaca_shared_proc ());#ifdef CONFIG_PPC_64S_HASH_MMU if (!radix_enabled ())
arch/powerpc/platforms/pseries/setup.c +1 -1
@@ -849,7 +849,7 @@ static void __init pSeries_setup_arch(void)if (firmware_has_feature (FW_FEATURE_LPAR )) {vpa_init (boot_cpuid); -if (lppaca_shared_proc (get_lppaca ())) { +if (lppaca_shared_proc ()) {static_branch_enable (&shared_processor);pv_spinlocks_init ();#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
drivers/cpuidle/cpuidle-pseries.c +1 -7
@@ -414,13 +414,7 @@ static int __init pseries_idle_probe(void)return -ENODEV ;if (firmware_has_feature (FW_FEATURE_SPLPAR )) { -/* -* Use local_paca instead of get_lppaca() since -* preemption is not disabled, and it is not required in -* fact, since lppaca_ptr does not need to be the value -* associated to the current CPU, it can be from any CPU. -*/ -if (lppaca_shared_proc (local_paca->lppaca_ptr)) { +if (lppaca_shared_proc ()) { cpuidle_state_table = shared_states; max_idle_state =ARRAY_SIZE (shared_states); }else {
Signature · 1 line
2.41.0
Michael Ellerman
AppliedRe: (subset) [PATCH v2 4/4] powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT
Quoted 13 lines · Michael Ellerman
lppaca_shared_proc()takes a pointer to the lppaca which is typically accessed throughget_lppaca(). WithDEBUG_PREEMPTenabled, this leads to checking if preemption is enabled, for example:BUG: using smp_processor_id() in preemptible [00000000] code: grep/10693 caller is lparcfg_data+0x408/0x19a0 CPU: 4 PID: 10693 Comm: grep Not tainted 6.5.0-rc3 #2 Call Trace: dump_stack_lvl+0x154/0x200 (unreliable) check_preemption_disabled+0x214/0x220 lparcfg_data+0x408/0x19a0 ...
Quoted 1 line
[...]
Applied to powerpc/next.
[4/4] powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT
https://git.kernel.org/powerpc/c/eac030b22ea12cdfcbb2e941c21c03964403c63f
cheers
Michael Ellerman
reviewerPATCH 3/4 powerpc: Don't include lppaca.h in paca.h
In reply to Michael EllermanBy adding a forward declaration for struct lppaca we can untangle paca.h and lppaca.h. Also move get_lppaca() into lppaca.h for consistency.
Add includes of lppaca.h to some files that need it.
--- arch/powerpc/include/asm/lppaca.h | 4 ++++ arch/powerpc/include/asm/paca.h | 6 +----- arch/powerpc/include/asm/paravirt.h | 1 + arch/powerpc/include/asm/plpar_wrappers.h | 1 + arch/powerpc/kvm/book3s_hv_ras.c | 1 + arch/powerpc/mm/book3s64/slb.c | 1 + arch/powerpc/xmon/xmon.c | 1 + 7 files changed, 10 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/lppaca.h +4 -0
@@ -112,6 +112,10 @@ static inline bool lppaca_shared_proc(struct lppaca *l)return !!(l->__old_status &LPPACA_OLD_SHARED_PROC ); } +#ifdef CONFIG_PPC_PSERIES +#define get_lppaca () (get_paca()->lppaca_ptr) +#endif +/* * SLB shadow buffer structure as defined in the PAPR. The save_area * contains adjacent ESID and VSID pairs for each shadowed SLB. The
arch/powerpc/include/asm/paca.h +1 -5
@@ -15,7 +15,6 @@#include <linux/cache.h> #include <linux/string.h> #include <asm/types.h> -#include <asm/lppaca.h> #include <asm/mmu.h> #include <asm/page.h> #ifdef CONFIG_PPC_BOOK3E_64
@@ -47,14 +46,11 @@ extern unsigned int debug_smp_processor_id(void); /* from linux/smp.h */#define get_paca () local_paca#endif -#ifdef CONFIG_PPC_PSERIES -#define get_lppaca () (get_paca()->lppaca_ptr) -#endif -#define get_slb_shadow () (get_paca()->slb_shadow_ptr)struct task_struct ;struct rtas_args ; +struct lppaca ;/* * Defines the layout of the paca.
arch/powerpc/include/asm/paravirt.h +1 -0
@@ -6,6 +6,7 @@#include <asm/smp.h> #ifdef CONFIG_PPC64 #include <asm/paca.h> +#include <asm/lppaca.h> #include <asm/hvcall.h> #endif
arch/powerpc/include/asm/plpar_wrappers.h +1 -0
@@ -9,6 +9,7 @@#include <asm/hvcall.h> #include <asm/paca.h> +#include <asm/lppaca.h> #include <asm/page.h> static inline long poll_pending (void )
arch/powerpc/kvm/book3s_hv_ras.c +1 -0
@@ -9,6 +9,7 @@#include <linux/kvm.h> #include <linux/kvm_host.h> #include <linux/kernel.h> +#include <asm/lppaca.h> #include <asm/opal.h> #include <asm/mce.h> #include <asm/machdep.h>
arch/powerpc/mm/book3s64/slb.c +1 -0
@@ -13,6 +13,7 @@#include <asm/mmu.h> #include <asm/mmu_context.h> #include <asm/paca.h> +#include <asm/lppaca.h> #include <asm/ppc-opcode.h> #include <asm/cputable.h> #include <asm/cacheflush.h>
arch/powerpc/xmon/xmon.c +1 -0
@@ -58,6 +58,7 @@#ifdef CONFIG_PPC64 #include <asm/hvcall.h> #include <asm/paca.h> +#include <asm/lppaca.h> #endif #include "nonstdio.h"
Signature · 1 line
2.41.0
Michael Ellerman
AppliedQuoted 4 lines · Michael Ellerman
These don't have any particularly good reason to belong in
lppaca.h, move them into their own header.
Applied to powerpc/next.
[1/4] powerpc/pseries: Move VPHN constants into vphn.h
https://git.kernel.org/powerpc/c/c040c7488b6a89c98dd0f6dd5f001101413779e2 [2/4] powerpc/pseries: Move hcall_vphn() prototype into vphn.h https://git.kernel.org/powerpc/c/9a6c05fe9a998386a61b5e70ce07d31ec47a01a0 [3/4] powerpc: Don't include lppaca.h in paca.h https://git.kernel.org/powerpc/c/1aa000667669fa855853decbb1c69e974d8ff716
cheers