Subject: Re: [RFC PATCH powerpc ] Protect smp_processor_id() in arch_spin_unlock_wait()

From: Benjamin Herrenschmidt <[email-masked]>
Date: Thu, 10 Jan 2013 17:02:06 +1100

On Mon, 2012-11-19 at 14:16 +0800, Li Zhong wrote:
> This patch tries to disable preemption for using smp_processor_id() in arch_spin_unlock_wait(), 
> to avoid following report:

 .../...

> diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
> index bb7cfec..7a7c31b 100644
> --- a/arch/powerpc/lib/locks.c
> +++ b/arch/powerpc/lib/locks.c
> @@ -72,8 +72,10 @@ void arch_spin_unlock_wait(arch_spinlock_t *lock)
>  {
>  	while (lock->slock) {
>  		HMT_low();
> +		preempt_disable();
>  		if (SHARED_PROCESSOR)
>  			__spin_yield(lock);
> +		preempt_enable();
>  	}

I assume what you are protecting is the PACA access in SHARED_PROCESSOR
or is there more ?

In that case I'd say just make it use local_paca-> directly or something
like that. It doesn't matter if the access is racy, all processors will
have the same value for that field as far as I can tell.

Cheers,
Ben.