[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YXLWdVGl4NP2HBCO@boqun-archlinux>
Date: Fri, 22 Oct 2021 23:19:17 +0800
From: Boqun Feng <boqun.feng@...il.com>
To: Waiman Long <longman@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Will Deacon <will@...nel.org>, Ingo Molnar <mingo@...nel.org>,
Arnd Bergmann <arnd@...db.de>, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org, Guo Ren <guoren@...nel.org>,
Palmer Dabbelt <palmerdabbelt@...gle.com>,
Anup Patel <anup@...infault.org>,
linux-riscv <linux-riscv@...ts.infradead.org>,
Christoph Müllner <christophm30@...il.com>,
Stafford Horne <shorne@...il.com>
Subject: Re: [PATCH] locking: Generic ticket lock
On Thu, Oct 21, 2021 at 02:04:55PM -0400, Waiman Long wrote:
[...]
> > +static __always_inline int ticket_is_contended(arch_spinlock_t *lock)
> > +{
> > + u32 val = atomic_read(lock);
> > +
> > + return (__ticket(val) - __owner(val)) > 1;
> Nit: The left side is unsigned, but the right is signed. I think you are
> relying on the implicit signed to unsigned conversion. It may be a bit
> clearer if you use 1U instead.
> > +}
> > +
> > +static __always_inline int ticket_is_locked(arch_spinlock_t *lock)
> > +{
> > + return __ticket_is_locked(atomic_read(lock));
> > +}
> > +
> > +static __always_inline int ticket_value_unlocked(arch_spinlock_t lock)
> > +{
> > + return !__ticket_is_locked(lock.counter);
> > +}
> > +
> > +#undef __owner
> > +#undef __ticket
> > +#undef ONE_TICKET
> > +
> > +#define arch_spin_lock(l) ticket_lock(l)
> > +#define arch_spin_trylock(l) ticket_trylock(l)
> > +#define arch_spin_unlock(l) ticket_unlock(l)
> > +#define arch_spin_is_locked(l) ticket_is_locked(l)
> > +#define arch_spin_is_contended(l) ticket_is_contended(l)
> > +#define arch_spin_value_unlocked(l) ticket_value_unlocked(l)
> > +
> > +#endif /* __ASM_GENERIC_TICKET_LOCK_H */
>
> Other than the nit above, the patch looks good to me.
>
> Reviewed-by: Waiman Long <longman@...hat.com>
>
Same here ;-)
Reviewed-by: Boqun Feng <boqun.feng@...il.com>
Regards,
Boqun
Powered by blists - more mailing lists