Skip to content

Commit eac030b

Browse files
ruscurmpe
authored andcommitted
powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT
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. Fixes: f13c13a ("powerpc: Stop using non-architected shared_proc field in lppaca") Signed-off-by: Russell Currey <[email protected]> [mpe: Rework to avoid needing a definition in paca.h and lppaca.h] Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 1aa0006 commit eac030b

File tree

5 files changed

+14
-21
lines changed

5 files changed

+14
-21
lines changed

arch/powerpc/include/asm/lppaca.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <asm/types.h>
2424
#include <asm/mmu.h>
2525
#include <asm/firmware.h>
26+
#include <asm/paca.h>
2627

2728
/*
2829
* The lppaca is the "virtual processor area" registered with the hypervisor,
@@ -105,14 +106,20 @@ struct lppaca {
105106
*/
106107
#define LPPACA_OLD_SHARED_PROC 2
107108

108-
static inline bool lppaca_shared_proc(struct lppaca *l)
109+
#ifdef CONFIG_PPC_PSERIES
110+
/*
111+
* All CPUs should have the same shared proc value, so directly access the PACA
112+
* to avoid false positives from DEBUG_PREEMPT.
113+
*/
114+
static inline bool lppaca_shared_proc(void)
109115
{
116+
struct lppaca *l = local_paca->lppaca_ptr;
117+
110118
if (!firmware_has_feature(FW_FEATURE_SPLPAR))
111119
return false;
112120
return !!(l->__old_status & LPPACA_OLD_SHARED_PROC);
113121
}
114122

115-
#ifdef CONFIG_PPC_PSERIES
116123
#define get_lppaca() (get_paca()->lppaca_ptr)
117124
#endif
118125

arch/powerpc/platforms/pseries/lpar.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -640,16 +640,8 @@ static const struct proc_ops vcpudispatch_stats_freq_proc_ops = {
640640

641641
static int __init vcpudispatch_stats_procfs_init(void)
642642
{
643-
/*
644-
* Avoid smp_processor_id while preemptible. All CPUs should have
645-
* the same value for lppaca_shared_proc.
646-
*/
647-
preempt_disable();
648-
if (!lppaca_shared_proc(get_lppaca())) {
649-
preempt_enable();
643+
if (!lppaca_shared_proc())
650644
return 0;
651-
}
652-
preempt_enable();
653645

654646
if (!proc_create("powerpc/vcpudispatch_stats", 0600, NULL,
655647
&vcpudispatch_stats_proc_ops))

arch/powerpc/platforms/pseries/lparcfg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static void parse_ppp_data(struct seq_file *m)
206206
ppp_data.active_system_procs);
207207

208208
/* pool related entries are appropriate for shared configs */
209-
if (lppaca_shared_proc(get_lppaca())) {
209+
if (lppaca_shared_proc()) {
210210
unsigned long pool_idle_time, pool_procs;
211211

212212
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)
560560
partition_potential_processors);
561561

562562
seq_printf(m, "shared_processor_mode=%d\n",
563-
lppaca_shared_proc(get_lppaca()));
563+
lppaca_shared_proc());
564564

565565
#ifdef CONFIG_PPC_64S_HASH_MMU
566566
if (!radix_enabled())

arch/powerpc/platforms/pseries/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ static void __init pSeries_setup_arch(void)
849849
if (firmware_has_feature(FW_FEATURE_LPAR)) {
850850
vpa_init(boot_cpuid);
851851

852-
if (lppaca_shared_proc(get_lppaca())) {
852+
if (lppaca_shared_proc()) {
853853
static_branch_enable(&shared_processor);
854854
pv_spinlocks_init();
855855
#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING

drivers/cpuidle/cpuidle-pseries.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,7 @@ static int __init pseries_idle_probe(void)
414414
return -ENODEV;
415415

416416
if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
417-
/*
418-
* Use local_paca instead of get_lppaca() since
419-
* preemption is not disabled, and it is not required in
420-
* fact, since lppaca_ptr does not need to be the value
421-
* associated to the current CPU, it can be from any CPU.
422-
*/
423-
if (lppaca_shared_proc(local_paca->lppaca_ptr)) {
417+
if (lppaca_shared_proc()) {
424418
cpuidle_state_table = shared_states;
425419
max_idle_state = ARRAY_SIZE(shared_states);
426420
} else {

0 commit comments

Comments
 (0)