[PATCH 13/14] powerpc/64: runlatch CTRL[RUN] set optimisation

Vaidyanathan Srinivasan svaidy at linux.vnet.ibm.com
Tue Jun 13 03:11:38 AEST 2017


* Nicholas Piggin <npiggin at gmail.com> [2017-06-12 09:58:34]:

> The CTRL register is read-only except bit 63 which is the run latch
> control. This means it can be updated with a mtspr rather than
> mfspr/mtspr.
> 
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>

Reviewed-by: Vaidyanathan Srinivasan <svaidy at linux.vnet.ibm.com>

> ---
>  arch/powerpc/kernel/process.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index baae104b16c7..a44ea034c226 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -1960,12 +1960,8 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
>  void notrace __ppc64_runlatch_on(void)
>  {
>  	struct thread_info *ti = current_thread_info();
> -	unsigned long ctrl;
> -
> -	ctrl = mfspr(SPRN_CTRLF);
> -	ctrl |= CTRL_RUNLATCH;
> -	mtspr(SPRN_CTRLT, ctrl);
> 
> +	mtspr(SPRN_CTRLT, CTRL_RUNLATCH);
>  	ti->local_flags |= _TLF_RUNLATCH;
>  }
> 
> @@ -1973,13 +1969,9 @@ void notrace __ppc64_runlatch_on(void)
>  void notrace __ppc64_runlatch_off(void)
>  {
>  	struct thread_info *ti = current_thread_info();
> -	unsigned long ctrl;
> 
>  	ti->local_flags &= ~_TLF_RUNLATCH;
> -
> -	ctrl = mfspr(SPRN_CTRLF);
> -	ctrl &= ~CTRL_RUNLATCH;
> -	mtspr(SPRN_CTRLT, ctrl);
> +	mtspr(SPRN_CTRLT, 0);

Good idea.  Writing to CTRL register can change only the RUN field.
Was this any different in older generations?  Anton and Ben kept the
mfspr/mtspr part in earlier updates to this routine.

--Vaidy



More information about the Linuxppc-dev mailing list