Rename syscall_exit_prepare_main() into interrupt_exit_prepare_main()
Make it static as it is not used anywhere else.
Pass it the 'ret' so that it can 'or' it directly instead of
oring twice, once inside the function and once outside.
And remove 'r3' parameter which is not used.
Also fix a typo where CONFIG_PPC_BOOK3S should be CONFIG_PPC_BOOK3S_64.
Signed-off-by: Christophe Leroy <redacted>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
This series applies on top of Nic's series speeding up interrupt return on 64s
arch/powerpc/kernel/interrupt.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
@@ -269,7 +268,7 @@ notrace unsigned long syscall_exit_prepare_main(unsigned long r3,ti_flags=READ_ONCE(current_thread_info()->flags);}-if(IS_ENABLED(CONFIG_PPC_BOOK3S)&&IS_ENABLED(CONFIG_PPC_FPU)){+if(IS_ENABLED(CONFIG_PPC_BOOK3S_64)&&IS_ENABLED(CONFIG_PPC_FPU)){if(IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM)&&unlikely((ti_flags&_TIF_RESTORE_TM))){restore_tm_state(regs);
@@ -365,7 +364,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,}local_irq_disable();-ret|=syscall_exit_prepare_main(r3,regs);+ret=interrupt_exit_user_prepare_main(regs,ret);#ifdef CONFIG_PPC64regs->exit_result=ret;
@@ -393,7 +392,7 @@ notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *regBUG_ON(!user_mode(regs));-regs->exit_result|=syscall_exit_prepare_main(r3,regs);+regs->exit_result=interrupt_exit_user_prepare_main(regs,regs->exit_result);returnregs->exit_result;}
@@ -400,9 +400,7 @@ notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *regnotraceunsignedlonginterrupt_exit_user_prepare(structpt_regs*regs){-unsignedlongti_flags;-unsignedlongflags;-unsignedlongret=0;+unsignedlongret;if(!IS_ENABLED(CONFIG_BOOKE)&&!IS_ENABLED(CONFIG_40x))BUG_ON(!(regs->msr&MSR_RI));
@@ -416,63 +414,14 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs)*/kuap_assert_locked();-local_irq_save(flags);--again:-ti_flags=READ_ONCE(current_thread_info()->flags);-while(unlikely(ti_flags&(_TIF_USER_WORK_MASK&~_TIF_RESTORE_TM))){-local_irq_enable();/* returning to user: may enable */-if(ti_flags&_TIF_NEED_RESCHED){-schedule();-}else{-if(ti_flags&_TIF_SIGPENDING)-ret|=_TIF_RESTOREALL;-do_notify_resume(regs,ti_flags);-}-local_irq_disable();-ti_flags=READ_ONCE(current_thread_info()->flags);-}--if(IS_ENABLED(CONFIG_PPC_BOOK3S_64)&&IS_ENABLED(CONFIG_PPC_FPU)){-if(IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM)&&-unlikely((ti_flags&_TIF_RESTORE_TM))){-restore_tm_state(regs);-}else{-unsignedlongmathflags=MSR_FP;--if(cpu_has_feature(CPU_FTR_VSX))-mathflags|=MSR_VEC|MSR_VSX;-elseif(cpu_has_feature(CPU_FTR_ALTIVEC))-mathflags|=MSR_VEC;--/* See above restore_math comment */-if((regs->msr&mathflags)!=mathflags)-restore_math(regs);-}-}--if(!prep_irq_for_user_exit()){-local_irq_enable();-local_irq_disable();-gotoagain;-}--booke_load_dbcr0();--#ifdef CONFIG_PPC_TRANSACTIONAL_MEM-local_paca->tm_scratch=regs->msr;-#endif+local_irq_disable();-account_cpu_user_exit();+ret=interrupt_exit_user_prepare_main(regs,0);#ifdef CONFIG_PPC64regs->exit_result=ret;#endif-/* Restore user access locks last */-kuap_user_restore(regs);-kuep_unlock();-returnret;}
prep_irq_for_user_exit() is a superset of
prep_irq_for_kernel_enabled_exit(). In order to allow refactoring in
following patch, interchange the two. This will allow
prep_irq_for_user_exit() to call a renamed version of
prep_irq_for_kernel_enabled_exit().
Signed-off-by: Christophe Leroy <redacted>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/interrupt.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
@@ -46,27 +46,28 @@ static inline bool exit_must_hard_disable(void)*Thisshouldbecalledwithlocalirqsdisabled,butiftheywerepreviously*enabledwhentheinterrupthandlerreturns(indicatingaprocess-context/*synchronousinterrupt)thenirqs_enabledshouldbetrue.+*+*restartableistruethenEE/RIcanbeleftonbecauseinterruptsarehandled+*witharestartsequence.*/-staticnotrace__always_inlineboolprep_irq_for_user_exit(void)+staticnotrace__always_inlineboolprep_irq_for_kernel_enabled_exit(boolrestartable){-user_enter_irqoff();/* This must be done with RI=1 because tracing may touch vmaps */trace_hardirqs_on();#ifdef CONFIG_PPC32__hard_EE_RI_disable();#else-if(exit_must_hard_disable())+if(exit_must_hard_disable()||!restartable)__hard_EE_RI_disable();/* This pattern matches prep_irq_for_idle */if(unlikely(lazy_irq_pending_nocheck())){-if(exit_must_hard_disable()){+if(exit_must_hard_disable()||!restartable){local_paca->irq_happened|=PACA_IRQ_HARD_DIS;__hard_RI_enable();}trace_hardirqs_off();-user_exit_irqoff();returnfalse;}
@@ -74,28 +75,26 @@ static notrace __always_inline bool prep_irq_for_user_exit(void)returntrue;}-/*-*restartableistruethenEE/RIcanbeleftonbecauseinterruptsarehandled-*witharestartsequence.-*/-staticnotrace__always_inlineboolprep_irq_for_kernel_enabled_exit(boolrestartable)+staticnotrace__always_inlineboolprep_irq_for_user_exit(void){+user_enter_irqoff();/* This must be done with RI=1 because tracing may touch vmaps */trace_hardirqs_on();#ifdef CONFIG_PPC32__hard_EE_RI_disable();#else-if(exit_must_hard_disable()||!restartable)+if(exit_must_hard_disable())__hard_EE_RI_disable();/* This pattern matches prep_irq_for_idle */if(unlikely(lazy_irq_pending_nocheck())){-if(exit_must_hard_disable()||!restartable){+if(exit_must_hard_disable()){local_paca->irq_happened|=PACA_IRQ_HARD_DIS;__hard_RI_enable();}trace_hardirqs_off();+user_exit_irqoff();returnfalse;}
prep_irq_for_user_exit() is a superset of
prep_irq_for_kernel_enabled_exit().
Rename prep_irq_for_kernel_enabled_exit() as prep_irq_for_enabled_exit()
and have prep_irq_for_user_exit() use it.
Signed-off-by: Christophe Leroy <redacted>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/interrupt.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
@@ -50,7 +50,7 @@ static inline bool exit_must_hard_disable(void)*restartableistruethenEE/RIcanbeleftonbecauseinterruptsarehandled*witharestartsequence.*/-staticnotrace__always_inlineboolprep_irq_for_kernel_enabled_exit(boolrestartable)+staticnotrace__always_inlineboolprep_irq_for_enabled_exit(boolrestartable){/* This must be done with RI=1 because tracing may touch vmaps */trace_hardirqs_on();
@@ -77,29 +77,14 @@ static notrace __always_inline bool prep_irq_for_kernel_enabled_exit(bool restarstaticnotrace__always_inlineboolprep_irq_for_user_exit(void){-user_enter_irqoff();-/* This must be done with RI=1 because tracing may touch vmaps */-trace_hardirqs_on();--#ifdef CONFIG_PPC32-__hard_EE_RI_disable();-#else-if(exit_must_hard_disable())-__hard_EE_RI_disable();+boolret;-/* This pattern matches prep_irq_for_idle */-if(unlikely(lazy_irq_pending_nocheck())){-if(exit_must_hard_disable()){-local_paca->irq_happened|=PACA_IRQ_HARD_DIS;-__hard_RI_enable();-}-trace_hardirqs_off();+user_enter_irqoff();+ret=prep_irq_for_enabled_exit(true);+if(!ret)user_exit_irqoff();-returnfalse;-}-#endif-returntrue;+returnret;}/* Has to run notrace because it is entered not completely "reconciled" */
@@ -465,7 +450,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)*Stackstoreexitcan'tberestartedbecausetheinterrupt*stackframemighthavebeenclobbered.*/-if(!prep_irq_for_kernel_enabled_exit(unlikely(stack_store))){+if(!prep_irq_for_enabled_exit(unlikely(stack_store))){/**Replaypendingsoft-maskedinterruptsnow.Don't*justlocal_irq_enabe();local_irq_disable();because
@@ -75,18 +75,6 @@ static notrace __always_inline bool prep_irq_for_enabled_exit(bool restartable)returntrue;}-staticnotrace__always_inlineboolprep_irq_for_user_exit(void)-{-boolret;--user_enter_irqoff();-ret=prep_irq_for_enabled_exit(true);-if(!ret)-user_exit_irqoff();--returnret;-}-/* Has to run notrace because it is entered not completely "reconciled" */notracelongsystem_call_exception(longr3,longr4,longr5,longr6,longr7,longr8,
@@ -276,7 +264,9 @@ interrupt_exit_user_prepare_main(struct pt_regs *regs, unsigned long ret)}}-if(!prep_irq_for_user_exit()){+user_enter_irqoff();+if(!prep_irq_for_enabled_exit(true)){+user_exit_irqoff();local_irq_enable();local_irq_disable();gotoagain;
From: Nicholas Piggin <npiggin@gmail.com> Date: 2021-06-17 11:25:53
Excerpts from Christophe Leroy's message of June 15, 2021 6:33 pm:
quoted hunk
Rename syscall_exit_prepare_main() into interrupt_exit_prepare_main()
Make it static as it is not used anywhere else.
Pass it the 'ret' so that it can 'or' it directly instead of
oring twice, once inside the function and once outside.
And remove 'r3' parameter which is not used.
Also fix a typo where CONFIG_PPC_BOOK3S should be CONFIG_PPC_BOOK3S_64.
Signed-off-by: Christophe Leroy <redacted>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
This series applies on top of Nic's series speeding up interrupt return on 64s
arch/powerpc/kernel/interrupt.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
Hmm, I tried switching the order of the arguments thinking it would
match caller and return registers better but didn't seem to help
generated code. Yet I think I will make that change to your patch if
you don't mind.
Thanks,
Nick
Excerpts from Christophe Leroy's message of June 15, 2021 6:33 pm:
quoted
Rename syscall_exit_prepare_main() into interrupt_exit_prepare_main()
Make it static as it is not used anywhere else.
Pass it the 'ret' so that it can 'or' it directly instead of
oring twice, once inside the function and once outside.
And remove 'r3' parameter which is not used.
Also fix a typo where CONFIG_PPC_BOOK3S should be CONFIG_PPC_BOOK3S_64.
Signed-off-by: Christophe Leroy <redacted>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
This series applies on top of Nic's series speeding up interrupt return on 64s
arch/powerpc/kernel/interrupt.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
Hmm, I tried switching the order of the arguments thinking it would
match caller and return registers better but didn't seem to help
generated code. Yet I think I will make that change to your patch if
you don't mind.
That's a static function that most likely gets inlined so the order of parameters makes no difference.
I tend to like that almost all functions dealing with interrupts take regs as first param, but I have no strong opinion about it so you can change it if that's better for you.
Christophe