On Tue, 2015-04-28 at 10:50 -0700, Jason Low wrote:
> On Tue, 2015-04-28 at 19:17 +0200, Peter Zijlstra wrote:
> 
> > To me it makes more sense to reverse these two branches (identical code
> > wise of course) and put the special case first.
> > 
> > Alternatively we could also do something like the below, which to my
> > eyes looks a little better still, but I don't care too much.
> > 
> >     if (rwsem_has_spinner(sem)) {
> >             /*
> >              * comment ...
> >              */
> >              smp_rmb();
> >              if (!raw_spin_trylock_irqsave(&sem->wait_lock, flags))
> >                     return sem;
> >              goto locked;
> >     }
> > 
> >     raw_spin_lock_irqsave(&sem->wait_lock, flags);
> > locked:
> 
> How about putting this into its own function:
> 
> static inline bool __rwsem_wake_acquire_wait_lock(sem)
> {
>       /*
>        *
>        * Comments
>        *
>        */
>       if (unlikely(rwsem_has_spinner(sem))) {
>               /*
>                * Comments
>                */
>               smp_rmb();
>               if (!raw_spin_trylock_irqsave(&sem->wait_lock, flags))
>                       return false;
>       }
> 
>       return true;
> }

That is, with the raw_spin_lock_irqsave() too :)

static inline bool __rwsem_wake_acquire_wait_lock(sem)
{
        /*
         *
         * Comments
         *
         */
        if (unlikely(rwsem_has_spinner(sem))) {
                /*
                 * Comments
                 */
                smp_rmb();
                if (!raw_spin_trylock_irqsave(&sem->wait_lock, flags))
                        return false;

                /* trylock successful */
                return true;
        }

        raw_spin_lock_irqsave(&sem->wait_lock, flags);
        return true;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to