2024-04-22 15:43:47

by Uros Bizjak

[permalink] [raw]
Subject: [PATCH] locking/pvqspinlock/x86: Use _Q_LOCKED_VAL in PV_UNLOCK_ASM macro

Use _Q_LOCKED_VAL instead of hardcoded $0x1 in PV_UNLOCK_ASM macro.

No functional changes intended.

Signed-off-by: Uros Bizjak <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Waiman Long <[email protected]>
Cc: Boqun Feng <[email protected]>
---
arch/x86/include/asm/qspinlock_paravirt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h
index 466af57b8ed6..0a985784be9b 100644
--- a/arch/x86/include/asm/qspinlock_paravirt.h
+++ b/arch/x86/include/asm/qspinlock_paravirt.h
@@ -40,7 +40,7 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
#define PV_UNLOCK_ASM \
FRAME_BEGIN \
"push %rdx\n\t" \
- "mov $0x1,%eax\n\t" \
+ "mov $" __stringify(_Q_LOCKED_VAL) ",%eax\n\t" \
"xor %edx,%edx\n\t" \
LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \
"jne .slowpath\n\t" \
--
2.42.0



2024-04-22 19:45:46

by Boqun Feng

[permalink] [raw]
Subject: Re: [PATCH] locking/pvqspinlock/x86: Use _Q_LOCKED_VAL in PV_UNLOCK_ASM macro

On Mon, Apr 22, 2024 at 05:17:35PM +0200, Uros Bizjak wrote:
> Use _Q_LOCKED_VAL instead of hardcoded $0x1 in PV_UNLOCK_ASM macro.
>
> No functional changes intended.
>
> Signed-off-by: Uros Bizjak <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Will Deacon <[email protected]>
> Cc: Waiman Long <[email protected]>
> Cc: Boqun Feng <[email protected]>
> ---
> arch/x86/include/asm/qspinlock_paravirt.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h
> index 466af57b8ed6..0a985784be9b 100644
> --- a/arch/x86/include/asm/qspinlock_paravirt.h
> +++ b/arch/x86/include/asm/qspinlock_paravirt.h
> @@ -40,7 +40,7 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
> #define PV_UNLOCK_ASM \
> FRAME_BEGIN \
> "push %rdx\n\t" \
> - "mov $0x1,%eax\n\t" \
> + "mov $" __stringify(_Q_LOCKED_VAL) ",%eax\n\t" \
> "xor %edx,%edx\n\t" \
> LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \
> "jne .slowpath\n\t" \

There is also a "cmp $0x1,%al" afterwards.

Regards,
Boqun

> --
> 2.42.0
>

2024-04-22 19:57:28

by Uros Bizjak

[permalink] [raw]
Subject: Re: [PATCH] locking/pvqspinlock/x86: Use _Q_LOCKED_VAL in PV_UNLOCK_ASM macro

On Mon, Apr 22, 2024 at 9:45 PM Boqun Feng <[email protected]> wrote:

> > diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h
> > index 466af57b8ed6..0a985784be9b 100644
> > --- a/arch/x86/include/asm/qspinlock_paravirt.h
> > +++ b/arch/x86/include/asm/qspinlock_paravirt.h
> > @@ -40,7 +40,7 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
> > #define PV_UNLOCK_ASM \
> > FRAME_BEGIN \
> > "push %rdx\n\t" \
> > - "mov $0x1,%eax\n\t" \
> > + "mov $" __stringify(_Q_LOCKED_VAL) ",%eax\n\t" \
> > "xor %edx,%edx\n\t" \
> > LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \
> > "jne .slowpath\n\t" \
>
> There is also a "cmp $0x1,%al" afterwards.

Not anymore. Please note that the patch is against -tip, where we have:

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=91095666125a666c8f20c2323b742c53165c0325

Thanks,
Uros.

2024-04-22 20:11:37

by Boqun Feng

[permalink] [raw]
Subject: Re: [PATCH] locking/pvqspinlock/x86: Use _Q_LOCKED_VAL in PV_UNLOCK_ASM macro

On Mon, Apr 22, 2024 at 09:57:04PM +0200, Uros Bizjak wrote:
> On Mon, Apr 22, 2024 at 9:45 PM Boqun Feng <[email protected]> wrote:
>
> > > diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h
> > > index 466af57b8ed6..0a985784be9b 100644
> > > --- a/arch/x86/include/asm/qspinlock_paravirt.h
> > > +++ b/arch/x86/include/asm/qspinlock_paravirt.h
> > > @@ -40,7 +40,7 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
> > > #define PV_UNLOCK_ASM \
> > > FRAME_BEGIN \
> > > "push %rdx\n\t" \
> > > - "mov $0x1,%eax\n\t" \
> > > + "mov $" __stringify(_Q_LOCKED_VAL) ",%eax\n\t" \
> > > "xor %edx,%edx\n\t" \
> > > LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \
> > > "jne .slowpath\n\t" \
> >
> > There is also a "cmp $0x1,%al" afterwards.
>
> Not anymore. Please note that the patch is against -tip, where we have:
>

Oh, thanks for the information. Maybe it makes sense to mention the
patches dependency in the commit log?

Regards,
Boqun

> https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=91095666125a666c8f20c2323b742c53165c0325
>
> Thanks,
> Uros.

2024-04-22 20:12:33

by Uros Bizjak

[permalink] [raw]
Subject: Re: [PATCH] locking/pvqspinlock/x86: Use _Q_LOCKED_VAL in PV_UNLOCK_ASM macro

On Mon, Apr 22, 2024 at 10:00 PM Boqun Feng <[email protected]> wrote:
>
> On Mon, Apr 22, 2024 at 09:57:04PM +0200, Uros Bizjak wrote:
> > On Mon, Apr 22, 2024 at 9:45 PM Boqun Feng <[email protected]> wrote:
> >
> > > > diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h
> > > > index 466af57b8ed6..0a985784be9b 100644
> > > > --- a/arch/x86/include/asm/qspinlock_paravirt.h
> > > > +++ b/arch/x86/include/asm/qspinlock_paravirt.h
> > > > @@ -40,7 +40,7 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
> > > > #define PV_UNLOCK_ASM \
> > > > FRAME_BEGIN \
> > > > "push %rdx\n\t" \
> > > > - "mov $0x1,%eax\n\t" \
> > > > + "mov $" __stringify(_Q_LOCKED_VAL) ",%eax\n\t" \
> > > > "xor %edx,%edx\n\t" \
> > > > LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \
> > > > "jne .slowpath\n\t" \
> > >
> > > There is also a "cmp $0x1,%al" afterwards.
> >
> > Not anymore. Please note that the patch is against -tip, where we have:
> >
>
> Oh, thanks for the information. Maybe it makes sense to mention the
> patches dependency in the commit log?

Hm, yes ... I should mention this as "[PATCH -tip]" in the subject
line to avoid confusion with this particular patch.

Thanks,
Uros.

2024-04-22 22:28:26

by Boqun Feng

[permalink] [raw]
Subject: Re: [PATCH] locking/pvqspinlock/x86: Use _Q_LOCKED_VAL in PV_UNLOCK_ASM macro

On Mon, Apr 22, 2024 at 10:12:11PM +0200, Uros Bizjak wrote:
> On Mon, Apr 22, 2024 at 10:00 PM Boqun Feng <[email protected]> wrote:
> >
> > On Mon, Apr 22, 2024 at 09:57:04PM +0200, Uros Bizjak wrote:
> > > On Mon, Apr 22, 2024 at 9:45 PM Boqun Feng <[email protected]> wrote:
> > >
> > > > > diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h
> > > > > index 466af57b8ed6..0a985784be9b 100644
> > > > > --- a/arch/x86/include/asm/qspinlock_paravirt.h
> > > > > +++ b/arch/x86/include/asm/qspinlock_paravirt.h
> > > > > @@ -40,7 +40,7 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
> > > > > #define PV_UNLOCK_ASM \
> > > > > FRAME_BEGIN \
> > > > > "push %rdx\n\t" \
> > > > > - "mov $0x1,%eax\n\t" \
> > > > > + "mov $" __stringify(_Q_LOCKED_VAL) ",%eax\n\t" \
> > > > > "xor %edx,%edx\n\t" \
> > > > > LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \
> > > > > "jne .slowpath\n\t" \
> > > >
> > > > There is also a "cmp $0x1,%al" afterwards.
> > >
> > > Not anymore. Please note that the patch is against -tip, where we have:
> > >
> >
> > Oh, thanks for the information. Maybe it makes sense to mention the
> > patches dependency in the commit log?
>
> Hm, yes ... I should mention this as "[PATCH -tip]" in the subject
> line to avoid confusion with this particular patch.
>

Anyway, the code looks good to me.

Acked-by: Boqun Feng <[email protected]>

Regards,
Boqun

> Thanks,
> Uros.

Subject: [tip: locking/core] locking/pvqspinlock/x86: Use _Q_LOCKED_VAL in PV_UNLOCK_ASM macro

The following commit has been merged into the locking/core branch of tip:

Commit-ID: 532453e7aa78f3962fb4d86caf40ff81ebf62160
Gitweb: https://git.kernel.org/tip/532453e7aa78f3962fb4d86caf40ff81ebf62160
Author: Uros Bizjak <[email protected]>
AuthorDate: Mon, 22 Apr 2024 17:17:35 +02:00
Committer: Ingo Molnar <[email protected]>
CommitterDate: Wed, 24 Apr 2024 11:48:08 +02:00

locking/pvqspinlock/x86: Use _Q_LOCKED_VAL in PV_UNLOCK_ASM macro

Use _Q_LOCKED_VAL instead of hardcoded $0x1 in PV_UNLOCK_ASM macro.

No functional changes intended.

Signed-off-by: Uros Bizjak <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Acked-by: Boqun Feng <[email protected]>
Cc: Waiman Long <[email protected]>
Cc: Linus Torvalds <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
arch/x86/include/asm/qspinlock_paravirt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h
index 466af57..0a98578 100644
--- a/arch/x86/include/asm/qspinlock_paravirt.h
+++ b/arch/x86/include/asm/qspinlock_paravirt.h
@@ -40,7 +40,7 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
#define PV_UNLOCK_ASM \
FRAME_BEGIN \
"push %rdx\n\t" \
- "mov $0x1,%eax\n\t" \
+ "mov $" __stringify(_Q_LOCKED_VAL) ",%eax\n\t" \
"xor %edx,%edx\n\t" \
LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \
"jne .slowpath\n\t" \