* [PATCH] powerpc64: use fixed lock token for !CONFIG_PPC_SPLPAR
@ 2015-03-07 11:19 Kevin Hao
2015-03-09 6:53 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Hao @ 2015-03-07 11:19 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Scott Wood, Paul Mackerras
It makes no sense to use a variant lock token on a platform which
doesn't support for shared-processor logical partitions. Actually we
can eliminate a memory load by using a fixed lock token on these
platforms.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
arch/powerpc/include/asm/spinlock.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
index 4dbe072eecbe..d303cdad2519 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -30,7 +30,7 @@
#define smp_mb__after_unlock_lock() smp_mb() /* Full ordering for lock. */
-#ifdef CONFIG_PPC64
+#ifdef CONFIG_PPC_SPLPAR
/* use 0x800000yy when locked, where yy == CPU number */
#ifdef __BIG_ENDIAN__
#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
@@ -187,9 +187,13 @@ extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
#ifdef CONFIG_PPC64
#define __DO_SIGN_EXTEND "extsw %0,%0\n"
-#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */
#else
#define __DO_SIGN_EXTEND
+#endif
+
+#ifdef CONFIG_PPC_SPLPAR
+#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */
+#else
#define WRLOCK_TOKEN (-1)
#endif
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc64: use fixed lock token for !CONFIG_PPC_SPLPAR
2015-03-07 11:19 [PATCH] powerpc64: use fixed lock token for !CONFIG_PPC_SPLPAR Kevin Hao
@ 2015-03-09 6:53 ` Benjamin Herrenschmidt
2015-03-10 0:15 ` Michael Ellerman
0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2015-03-09 6:53 UTC (permalink / raw)
To: Kevin Hao; +Cc: Scott Wood, Paul Mackerras, linuxppc-dev
On Sat, 2015-03-07 at 19:19 +0800, Kevin Hao wrote:
> It makes no sense to use a variant lock token on a platform which
> doesn't support for shared-processor logical partitions. Actually we
> can eliminate a memory load by using a fixed lock token on these
> platforms.
Does this provide an actual measurable benefit ? I found that the lock
token was quite handy for debugging ...
Cheers,
Ben.
> Signed-off-by: Kevin Hao <haokexin@gmail.com>
> ---
> arch/powerpc/include/asm/spinlock.h | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
> index 4dbe072eecbe..d303cdad2519 100644
> --- a/arch/powerpc/include/asm/spinlock.h
> +++ b/arch/powerpc/include/asm/spinlock.h
> @@ -30,7 +30,7 @@
>
> #define smp_mb__after_unlock_lock() smp_mb() /* Full ordering for lock. */
>
> -#ifdef CONFIG_PPC64
> +#ifdef CONFIG_PPC_SPLPAR
> /* use 0x800000yy when locked, where yy == CPU number */
> #ifdef __BIG_ENDIAN__
> #define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
> @@ -187,9 +187,13 @@ extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
>
> #ifdef CONFIG_PPC64
> #define __DO_SIGN_EXTEND "extsw %0,%0\n"
> -#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */
> #else
> #define __DO_SIGN_EXTEND
> +#endif
> +
> +#ifdef CONFIG_PPC_SPLPAR
> +#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */
> +#else
> #define WRLOCK_TOKEN (-1)
> #endif
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc64: use fixed lock token for !CONFIG_PPC_SPLPAR
2015-03-09 6:53 ` Benjamin Herrenschmidt
@ 2015-03-10 0:15 ` Michael Ellerman
2015-03-10 12:32 ` Kevin Hao
0 siblings, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2015-03-10 0:15 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Scott Wood, linuxppc-dev, Kevin Hao, Paul Mackerras
On Mon, 2015-03-09 at 17:53 +1100, Benjamin Herrenschmidt wrote:
> On Sat, 2015-03-07 at 19:19 +0800, Kevin Hao wrote:
> > It makes no sense to use a variant lock token on a platform which
> > doesn't support for shared-processor logical partitions. Actually we
> > can eliminate a memory load by using a fixed lock token on these
> > platforms.
>
> Does this provide an actual measurable benefit ? I found that the lock
> token was quite handy for debugging ...
Yeah. It can be very useful to know which cpu holds a lock when you get into a
dead lock.
Unless you can show this is a performance boost I'm inclined to leave it as-is.
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc64: use fixed lock token for !CONFIG_PPC_SPLPAR
2015-03-10 0:15 ` Michael Ellerman
@ 2015-03-10 12:32 ` Kevin Hao
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Hao @ 2015-03-10 12:32 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Scott Wood, linuxppc-dev, Paul Mackerras
[-- Attachment #1: Type: text/plain, Size: 1664 bytes --]
On Tue, Mar 10, 2015 at 11:15:18AM +1100, Michael Ellerman wrote:
> On Mon, 2015-03-09 at 17:53 +1100, Benjamin Herrenschmidt wrote:
> > On Sat, 2015-03-07 at 19:19 +0800, Kevin Hao wrote:
> > > It makes no sense to use a variant lock token on a platform which
> > > doesn't support for shared-processor logical partitions. Actually we
> > > can eliminate a memory load by using a fixed lock token on these
> > > platforms.
> >
> > Does this provide an actual measurable benefit ? I found that the lock
> > token was quite handy for debugging ...
>
> Yeah. It can be very useful to know which cpu holds a lock when you get into a
> dead lock.
>
> Unless you can show this is a performance boost I'm inclined to leave it as-is.
I am not sure if there is more suitable benchmark for spinlock. I tried the
perf locking benchmark got from here [1]. The test was running on a t4240rdb
board with xfs rootfs. I have run the following commands four times before and
after applying this patch.
./perf record ./perf bench locking vfs; ./perf report
Before:
3.06% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock
3.04% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock
3.03% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock
3.00% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock
After:
3.05% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock
2.97% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock
2.96% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock
2.97% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock
[1] http://lkml.iu.edu/hypermail/linux/kernel/1412.1/01419.html
Thanks,
Kevin
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-10 12:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-07 11:19 [PATCH] powerpc64: use fixed lock token for !CONFIG_PPC_SPLPAR Kevin Hao
2015-03-09 6:53 ` Benjamin Herrenschmidt
2015-03-10 0:15 ` Michael Ellerman
2015-03-10 12:32 ` Kevin Hao
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).