[PATCH 01/17] powerpc/qspinlock: powerpc qspinlock implementation

Christophe Leroy christophe.leroy at csgroup.eu
Wed Aug 10 16:48:03 AEST 2022



Le 10/08/2022 à 03:52, Jordan NIethe a écrit :
> On Thu, 2022-07-28 at 16:31 +1000, Nicholas Piggin wrote:
> <snip>
>> -#define queued_spin_lock queued_spin_lock
>>   
>> -static inline void queued_spin_unlock(struct qspinlock *lock)
>> +static __always_inline int queued_spin_trylock(struct qspinlock *lock)
>>   {
>> -	if (!IS_ENABLED(CONFIG_PARAVIRT_SPINLOCKS) || !is_shared_processor())
>> -		smp_store_release(&lock->locked, 0);
>> -	else
>> -		__pv_queued_spin_unlock(lock);
>> +	if (atomic_cmpxchg_acquire(&lock->val, 0, 1) == 0)
>> +		return 1;
>> +	return 0;
> 
> optional style nit: return (atomic_cmpxchg_acquire(&lock->val, 0, 1) == 0);
> 

The parenthesis are pointless, and ! is usually prefered to == 0, 
something like that:

	return !atomic_cmpxchg_acquire(&lock->val, 0, 1);


More information about the Linuxppc-dev mailing list