From: Boqun Feng <boqun.feng@gmail.com>
To: Rui Wang <wangrui@loongson.cn>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Arnd Bergmann <arnd@arndb.de>, Waiman Long <longman@redhat.com>,
Guo Ren <guoren@kernel.org>,
linux-arch@vger.kernel.org, hev <r@hev.cc>,
Xuefeng Li <lixuefeng@loongson.cn>,
Huacai Chen <chenhuacai@gmail.com>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
Huacai Chen <chenhuacai@loongson.cn>
Subject: Re: [RFC PATCH v1 2/5] locking/qspinlock: Refactor xchg_tail to use atomic_fetch_and_or
Date: Wed, 28 Jul 2021 20:27:32 +0800 [thread overview]
Message-ID: <YQFNNN9Fee9PaPUi@boqun-archlinux> (raw)
In-Reply-To: <20210728114923.1294-1-wangrui@loongson.cn>
On Wed, Jul 28, 2021 at 07:49:23PM +0800, Rui Wang wrote:
> From: wangrui <wangrui@loongson.cn>
>
Please add the explanation of why the change here, ditto for rest of the
patchset.
> Signed-by-off: Rui Wang <wangrui@loongson.cn>
> Signed-by-off: hev <r@hev.cc>
> ---
> kernel/locking/qspinlock.c | 18 ++----------------
> 1 file changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
> index cbff6ba53d56..350363e14e38 100644
> --- a/kernel/locking/qspinlock.c
> +++ b/kernel/locking/qspinlock.c
> @@ -219,22 +219,8 @@ static __always_inline void clear_pending_set_locked(struct qspinlock *lock)
> */
> static __always_inline u32 xchg_tail(struct qspinlock *lock, u32 tail)
> {
> - u32 old, new, val = atomic_read(&lock->val);
> -
> - for (;;) {
> - new = (val & _Q_LOCKED_PENDING_MASK) | tail;
> - /*
> - * We can use relaxed semantics since the caller ensures that
> - * the MCS node is properly initialized before updating the
> - * tail.
> - */
> - old = atomic_cmpxchg_relaxed(&lock->val, val, new);
> - if (old == val)
> - break;
> -
> - val = old;
> - }
> - return old;
> + const u32 mask = _Q_LOCKED_PENDING_MASK;
There should be a blank line between definition and code, also please
keep the comments for why we use _relaxed() here.
Regards,
Boqun
> + return atomic_fetch_and_or_relaxed(mask, tail, &lock->val);
> }
> #endif /* _Q_PENDING_BITS == 8 */
>
> --
> 2.32.0
>
prev parent reply other threads:[~2021-07-28 12:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 11:49 [RFC PATCH v1 2/5] locking/qspinlock: Refactor xchg_tail to use atomic_fetch_and_or Rui Wang
2021-07-28 12:27 ` Boqun Feng [this message]
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=YQFNNN9Fee9PaPUi@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=arnd@arndb.de \
--cc=chenhuacai@gmail.com \
--cc=chenhuacai@loongson.cn \
--cc=guoren@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-arch@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=r@hev.cc \
--cc=wangrui@loongson.cn \
--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).