linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Waiman Long <longman@redhat.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
	"Will Deacon" <will@kernel.org>, "Ingo Molnar" <mingo@kernel.org>,
	"Arnd Bergmann" <arnd@arndb.de>,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Guo Ren" <guoren@kernel.org>,
	"Palmer Dabbelt" <palmerdabbelt@google.com>,
	"Anup Patel" <anup@brainfault.org>,
	linux-riscv <linux-riscv@lists.infradead.org>,
	"Christoph Müllner" <christophm30@gmail.com>,
	"Stafford Horne" <shorne@gmail.com>
Subject: Re: [PATCH] locking: Generic ticket lock
Date: Fri, 22 Oct 2021 23:19:17 +0800	[thread overview]
Message-ID: <YXLWdVGl4NP2HBCO@boqun-archlinux> (raw)
In-Reply-To: <4de96b16-a146-f82a-a7f2-706dba4f901f@redhat.com>

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@redhat.com>
> 

Same here ;-)

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

  reply	other threads:[~2021-10-22 15:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 13:05 [PATCH] locking: Generic ticket lock Peter Zijlstra
2021-10-21 13:12 ` Peter Zijlstra
2021-10-21 13:50   ` Stafford Horne
2021-10-21 13:49 ` Arnd Bergmann
2021-10-21 15:14   ` Peter Zijlstra
2021-10-21 15:31     ` Arnd Bergmann
2021-10-21 16:28       ` Peter Zijlstra
2021-10-21 18:04 ` Waiman Long
2021-10-22 15:19   ` Boqun Feng [this message]
2021-10-22  2:04 ` Guo Ren
2021-10-22  9:23 ` Mark Rutland
2021-10-22 12:31   ` Peter Zijlstra
2021-12-14 15:40 ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YXLWdVGl4NP2HBCO@boqun-archlinux \
    --to=boqun.feng@gmail.com \
    --cc=anup@brainfault.org \
    --cc=arnd@arndb.de \
    --cc=christophm30@gmail.com \
    --cc=guoren@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=longman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=palmerdabbelt@google.com \
    --cc=peterz@infradead.org \
    --cc=shorne@gmail.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).