From: Waiman Long <longman@redhat.com>
To: guoren@kernel.org, palmer@rivosinc.com, arnd@arndb.de,
mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com
Cc: linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org, Guo Ren <guoren@linux.alibaba.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH V7 4/5] asm-generic: spinlock: Add combo spinlock (ticket & queued)
Date: Tue, 28 Jun 2022 14:13:39 -0400 [thread overview]
Message-ID: <09abc75e-2ffb-1ab5-d0fc-1c15c943948d@redhat.com> (raw)
In-Reply-To: <20220628081707.1997728-5-guoren@kernel.org>
On 6/28/22 04:17, guoren@kernel.org wrote:
> From: Guo Ren <guoren@linux.alibaba.com>
>
> Some architecture has a flexible requirement on the type of spinlock.
> Some LL/SC architectures of ISA don't force micro-arch to give a strong
> forward guarantee. Thus different kinds of memory model micro-arch would
> come out in one ISA. The ticket lock is suitable for exclusive monitor
> designed LL/SC micro-arch with limited cores and "!NUMA". The
> queue-spinlock could deal with NUMA/large-scale scenarios with a strong
> forward guarantee designed LL/SC micro-arch.
>
> So, make the spinlock a combo with feature.
>
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> Signed-off-by: Guo Ren <guoren@kernel.org>
> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Palmer Dabbelt <palmer@rivosinc.com>
> ---
> include/asm-generic/spinlock.h | 43 ++++++++++++++++++++++++++++++++--
> kernel/locking/qspinlock.c | 2 ++
> 2 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/spinlock.h b/include/asm-generic/spinlock.h
> index f41dc7c2b900..a9b43089bf99 100644
> --- a/include/asm-generic/spinlock.h
> +++ b/include/asm-generic/spinlock.h
> @@ -28,34 +28,73 @@
> #define __ASM_GENERIC_SPINLOCK_H
>
> #include <asm-generic/ticket_spinlock.h>
> +#ifdef CONFIG_ARCH_USE_QUEUED_SPINLOCKS
> +#include <linux/jump_label.h>
> +#include <asm-generic/qspinlock.h>
> +
> +DECLARE_STATIC_KEY_TRUE(use_qspinlock_key);
> +#endif
> +
> +#undef arch_spin_is_locked
> +#undef arch_spin_is_contended
> +#undef arch_spin_value_unlocked
> +#undef arch_spin_lock
> +#undef arch_spin_trylock
> +#undef arch_spin_unlock
>
> static __always_inline void arch_spin_lock(arch_spinlock_t *lock)
> {
> - ticket_spin_lock(lock);
> +#ifdef CONFIG_ARCH_USE_QUEUED_SPINLOCKS
> + if (static_branch_likely(&use_qspinlock_key))
> + queued_spin_lock(lock);
> + else
> +#endif
> + ticket_spin_lock(lock);
> }
Why do you use a static key to control whether to use qspinlock or
ticket lock? In the next patch, you have
+#if !defined(CONFIG_NUMA) && defined(CONFIG_QUEUED_SPINLOCKS)
+ static_branch_disable(&use_qspinlock_key);
+#endif
So the current config setting determines if qspinlock will be used, not
some boot time parameter that user needs to specify. This patch will
just add useless code to lock/unlock sites. I don't see any benefit of
doing that.
Cheers,
Longman
WARNING: multiple messages have this Message-ID (diff)
From: Waiman Long <longman@redhat.com>
To: guoren@kernel.org, palmer@rivosinc.com, arnd@arndb.de,
mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com
Cc: linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org, Guo Ren <guoren@linux.alibaba.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH V7 4/5] asm-generic: spinlock: Add combo spinlock (ticket & queued)
Date: Tue, 28 Jun 2022 14:13:39 -0400 [thread overview]
Message-ID: <09abc75e-2ffb-1ab5-d0fc-1c15c943948d@redhat.com> (raw)
In-Reply-To: <20220628081707.1997728-5-guoren@kernel.org>
On 6/28/22 04:17, guoren@kernel.org wrote:
> From: Guo Ren <guoren@linux.alibaba.com>
>
> Some architecture has a flexible requirement on the type of spinlock.
> Some LL/SC architectures of ISA don't force micro-arch to give a strong
> forward guarantee. Thus different kinds of memory model micro-arch would
> come out in one ISA. The ticket lock is suitable for exclusive monitor
> designed LL/SC micro-arch with limited cores and "!NUMA". The
> queue-spinlock could deal with NUMA/large-scale scenarios with a strong
> forward guarantee designed LL/SC micro-arch.
>
> So, make the spinlock a combo with feature.
>
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> Signed-off-by: Guo Ren <guoren@kernel.org>
> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Palmer Dabbelt <palmer@rivosinc.com>
> ---
> include/asm-generic/spinlock.h | 43 ++++++++++++++++++++++++++++++++--
> kernel/locking/qspinlock.c | 2 ++
> 2 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/spinlock.h b/include/asm-generic/spinlock.h
> index f41dc7c2b900..a9b43089bf99 100644
> --- a/include/asm-generic/spinlock.h
> +++ b/include/asm-generic/spinlock.h
> @@ -28,34 +28,73 @@
> #define __ASM_GENERIC_SPINLOCK_H
>
> #include <asm-generic/ticket_spinlock.h>
> +#ifdef CONFIG_ARCH_USE_QUEUED_SPINLOCKS
> +#include <linux/jump_label.h>
> +#include <asm-generic/qspinlock.h>
> +
> +DECLARE_STATIC_KEY_TRUE(use_qspinlock_key);
> +#endif
> +
> +#undef arch_spin_is_locked
> +#undef arch_spin_is_contended
> +#undef arch_spin_value_unlocked
> +#undef arch_spin_lock
> +#undef arch_spin_trylock
> +#undef arch_spin_unlock
>
> static __always_inline void arch_spin_lock(arch_spinlock_t *lock)
> {
> - ticket_spin_lock(lock);
> +#ifdef CONFIG_ARCH_USE_QUEUED_SPINLOCKS
> + if (static_branch_likely(&use_qspinlock_key))
> + queued_spin_lock(lock);
> + else
> +#endif
> + ticket_spin_lock(lock);
> }
Why do you use a static key to control whether to use qspinlock or
ticket lock? In the next patch, you have
+#if !defined(CONFIG_NUMA) && defined(CONFIG_QUEUED_SPINLOCKS)
+ static_branch_disable(&use_qspinlock_key);
+#endif
So the current config setting determines if qspinlock will be used, not
some boot time parameter that user needs to specify. This patch will
just add useless code to lock/unlock sites. I don't see any benefit of
doing that.
Cheers,
Longman
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2022-06-28 18:13 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 8:17 [PATCH V7 0/5] riscv: Add qspinlock support with combo style guoren
2022-06-28 8:17 ` guoren
2022-06-28 8:17 ` [PATCH V7 1/5] asm-generic: ticket-lock: Remove unnecessary atomic_read guoren
2022-06-28 8:17 ` guoren
2022-06-28 18:05 ` Waiman Long
2022-06-28 18:05 ` Waiman Long
2022-06-29 2:12 ` Guo Ren
2022-06-29 2:12 ` Guo Ren
2022-06-29 8:27 ` David Laight
2022-06-29 8:27 ` David Laight
2022-07-01 15:18 ` Guo Ren
2022-07-01 15:18 ` Guo Ren
2022-07-04 9:52 ` Peter Zijlstra
2022-07-04 9:52 ` Peter Zijlstra
2022-07-04 11:10 ` Guo Ren
2022-07-04 11:10 ` Guo Ren
2022-06-28 8:17 ` [PATCH V7 2/5] asm-generic: ticket-lock: Use the same struct definitions with qspinlock guoren
2022-06-28 8:17 ` guoren
2022-06-28 8:17 ` [PATCH V7 3/5] asm-generic: ticket-lock: Move into ticket_spinlock.h guoren
2022-06-28 8:17 ` guoren
2022-06-28 8:17 ` [PATCH V7 4/5] asm-generic: spinlock: Add combo spinlock (ticket & queued) guoren
2022-06-28 8:17 ` guoren
2022-06-28 18:13 ` Waiman Long [this message]
2022-06-28 18:13 ` Waiman Long
2022-06-29 1:17 ` Guo Ren
2022-06-29 1:17 ` Guo Ren
2022-06-29 1:34 ` Waiman Long
2022-06-29 1:34 ` Waiman Long
2022-06-29 2:29 ` Guo Ren
2022-06-29 2:29 ` Guo Ren
2022-06-29 7:08 ` Arnd Bergmann
2022-06-29 7:08 ` Arnd Bergmann
2022-06-29 8:24 ` Guo Ren
2022-06-29 8:24 ` Guo Ren
2022-06-29 8:29 ` Arnd Bergmann
2022-06-29 8:29 ` Arnd Bergmann
2022-07-01 12:18 ` Guo Ren
2022-07-01 12:18 ` Guo Ren
2022-06-29 12:53 ` Waiman Long
2022-06-29 12:53 ` Waiman Long
2022-07-04 9:57 ` Peter Zijlstra
2022-07-04 9:57 ` Peter Zijlstra
2022-07-04 13:13 ` Guo Ren
2022-07-04 13:13 ` Guo Ren
2022-07-04 13:45 ` Peter Zijlstra
2022-07-04 13:45 ` Peter Zijlstra
2022-06-28 8:17 ` [PATCH V7 5/5] riscv: Add qspinlock support guoren
2022-06-28 8:17 ` guoren
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=09abc75e-2ffb-1ab5-d0fc-1c15c943948d@redhat.com \
--to=longman@redhat.com \
--cc=arnd@arndb.de \
--cc=boqun.feng@gmail.com \
--cc=guoren@kernel.org \
--cc=guoren@linux.alibaba.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mingo@redhat.com \
--cc=palmer@rivosinc.com \
--cc=peterz@infradead.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.