public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: eliminate TICKET_MASK
@ 2012-02-03 15:06 Jan Beulich
  2012-02-03 19:36 ` Jeremy Fitzhardinge
  2012-02-07 19:40 ` [tip:x86/asm] x86/spinlocks: Eliminate TICKET_MASK tip-bot for Jan Beulich
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2012-02-03 15:06 UTC (permalink / raw)
  To: mingo, tglx, hpa; +Cc: Jeremy Fitzhardinge, linux-kernel

The definition of it being questionable already (unnecessarily
including a cast), and it being used in a single place that can be
written shorter without it, remove this #define.

Along the same lines, simplify __ticket_spin_is_locked()'s main
expression, which was the more convoluted way because of needs that
went away with the recent type changes by Jeremy.

This is pure cleanup, no functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>

---
 arch/x86/include/asm/spinlock.h       |    4 ++--
 arch/x86/include/asm/spinlock_types.h |    1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

--- 3.3-rc2/arch/x86/include/asm/spinlock.h
+++ 3.3-rc2-x86-ticket-mask/arch/x86/include/asm/spinlock.h
@@ -88,14 +88,14 @@ static inline int __ticket_spin_is_locke
 {
 	struct __raw_tickets tmp = ACCESS_ONCE(lock->tickets);
 
-	return !!(tmp.tail ^ tmp.head);
+	return tmp.tail != tmp.head;
 }
 
 static inline int __ticket_spin_is_contended(arch_spinlock_t *lock)
 {
 	struct __raw_tickets tmp = ACCESS_ONCE(lock->tickets);
 
-	return ((tmp.tail - tmp.head) & TICKET_MASK) > 1;
+	return (__ticket_t)(tmp.tail - tmp.head) > 1;
 }
 
 #ifndef CONFIG_PARAVIRT_SPINLOCKS
--- 3.3-rc2/arch/x86/include/asm/spinlock_types.h
+++ 3.3-rc2-x86-ticket-mask/arch/x86/include/asm/spinlock_types.h
@@ -16,7 +16,6 @@ typedef u32 __ticketpair_t;
 #endif
 
 #define TICKET_SHIFT	(sizeof(__ticket_t) * 8)
-#define TICKET_MASK	((__ticket_t)((1 << TICKET_SHIFT) - 1))
 
 typedef struct arch_spinlock {
 	union {




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86: eliminate TICKET_MASK
  2012-02-03 15:06 [PATCH] x86: eliminate TICKET_MASK Jan Beulich
@ 2012-02-03 19:36 ` Jeremy Fitzhardinge
  2012-02-07 19:40 ` [tip:x86/asm] x86/spinlocks: Eliminate TICKET_MASK tip-bot for Jan Beulich
  1 sibling, 0 replies; 3+ messages in thread
From: Jeremy Fitzhardinge @ 2012-02-03 19:36 UTC (permalink / raw)
  To: Jan Beulich; +Cc: mingo, tglx, hpa, linux-kernel

On 02/03/2012 07:06 AM, Jan Beulich wrote:
> The definition of it being questionable already (unnecessarily
> including a cast), and it being used in a single place that can be
> written shorter without it, remove this #define.
>
> Along the same lines, simplify __ticket_spin_is_locked()'s main
> expression, which was the more convoluted way because of needs that
> went away with the recent type changes by Jeremy.
>
> This is pure cleanup, no functional change intended.

That looks reasonable to me.

> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Cc: Jeremy Fitzhardinge <jeremy@goop.org>
>
> ---
>  arch/x86/include/asm/spinlock.h       |    4 ++--
>  arch/x86/include/asm/spinlock_types.h |    1 -
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> --- 3.3-rc2/arch/x86/include/asm/spinlock.h
> +++ 3.3-rc2-x86-ticket-mask/arch/x86/include/asm/spinlock.h
> @@ -88,14 +88,14 @@ static inline int __ticket_spin_is_locke
>  {
>  	struct __raw_tickets tmp = ACCESS_ONCE(lock->tickets);
>  
> -	return !!(tmp.tail ^ tmp.head);
> +	return tmp.tail != tmp.head;
>  }
>  
>  static inline int __ticket_spin_is_contended(arch_spinlock_t *lock)
>  {
>  	struct __raw_tickets tmp = ACCESS_ONCE(lock->tickets);
>  
> -	return ((tmp.tail - tmp.head) & TICKET_MASK) > 1;
> +	return (__ticket_t)(tmp.tail - tmp.head) > 1;
>  }

Yes.  I only left these unchanged the first time around because I didn't
want to inadvertently change them, but my intent was to make them more
straightforward like this.

>  
>  #ifndef CONFIG_PARAVIRT_SPINLOCKS
> --- 3.3-rc2/arch/x86/include/asm/spinlock_types.h
> +++ 3.3-rc2-x86-ticket-mask/arch/x86/include/asm/spinlock_types.h
> @@ -16,7 +16,6 @@ typedef u32 __ticketpair_t;
>  #endif
>  
>  #define TICKET_SHIFT	(sizeof(__ticket_t) * 8)
> -#define TICKET_MASK	((__ticket_t)((1 << TICKET_SHIFT) - 1))
>  
>  typedef struct arch_spinlock {
>  	union {
>
>
>

Acked-by: Jeremy Fitzhardinge <jeremy@goop.org>

Thanks,
    J

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/asm] x86/spinlocks: Eliminate TICKET_MASK
  2012-02-03 15:06 [PATCH] x86: eliminate TICKET_MASK Jan Beulich
  2012-02-03 19:36 ` Jeremy Fitzhardinge
@ 2012-02-07 19:40 ` tip-bot for Jan Beulich
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Jan Beulich @ 2012-02-07 19:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, torvalds, jbeulich,
	jeremy, akpm, JBeulich, tglx, mingo

Commit-ID:  7931d493051ea9b09e4fddee2dc40b2eb88d62b9
Gitweb:     http://git.kernel.org/tip/7931d493051ea9b09e4fddee2dc40b2eb88d62b9
Author:     Jan Beulich <JBeulich@suse.com>
AuthorDate: Fri, 3 Feb 2012 15:06:26 +0000
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 7 Feb 2012 10:09:54 +0100

x86/spinlocks: Eliminate TICKET_MASK

The definition of it being questionable already (unnecessarily
including a cast), and it being used in a single place that can
be written shorter without it, remove this #define.

Along the same lines, simplify __ticket_spin_is_locked()'s main
expression, which was the more convoluted way because of needs
that went away with the recent type changes by Jeremy.

This is pure cleanup, no functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/4F2C06020200007800071066@nat28.tlf.novell.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/include/asm/spinlock.h       |    4 ++--
 arch/x86/include/asm/spinlock_types.h |    1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index a82c2bf..76bfa2c 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -88,14 +88,14 @@ static inline int __ticket_spin_is_locked(arch_spinlock_t *lock)
 {
 	struct __raw_tickets tmp = ACCESS_ONCE(lock->tickets);
 
-	return !!(tmp.tail ^ tmp.head);
+	return tmp.tail != tmp.head;
 }
 
 static inline int __ticket_spin_is_contended(arch_spinlock_t *lock)
 {
 	struct __raw_tickets tmp = ACCESS_ONCE(lock->tickets);
 
-	return ((tmp.tail - tmp.head) & TICKET_MASK) > 1;
+	return (__ticket_t)(tmp.tail - tmp.head) > 1;
 }
 
 #ifndef CONFIG_PARAVIRT_SPINLOCKS
diff --git a/arch/x86/include/asm/spinlock_types.h b/arch/x86/include/asm/spinlock_types.h
index 8ebd5df..ad0ad07 100644
--- a/arch/x86/include/asm/spinlock_types.h
+++ b/arch/x86/include/asm/spinlock_types.h
@@ -16,7 +16,6 @@ typedef u32 __ticketpair_t;
 #endif
 
 #define TICKET_SHIFT	(sizeof(__ticket_t) * 8)
-#define TICKET_MASK	((__ticket_t)((1 << TICKET_SHIFT) - 1))
 
 typedef struct arch_spinlock {
 	union {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-02-07 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-03 15:06 [PATCH] x86: eliminate TICKET_MASK Jan Beulich
2012-02-03 19:36 ` Jeremy Fitzhardinge
2012-02-07 19:40 ` [tip:x86/asm] x86/spinlocks: Eliminate TICKET_MASK tip-bot for Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox