xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com,
	tglx@linutronix.de, mingo@redhat.com,
	xen-devel@lists.xensource.com, konrad.wilk@oracle.com,
	david.vrabel@citrix.com, boris.ostrovsky@oracle.com,
	jeremy@goop.org, chrisw@sous-sol.org, akataria@vmware.com,
	rusty@rustcorp.com.au, virtualization@lists.linux-foundation.org,
	gleb@kernel.org, pbonzini@redhat.com, kvm@vger.kernel.org
Cc: Juergen Gross <jgross@suse.com>
Subject: [PATCH 2/6] x86: move decision about clearing slowpath flag into arch_spin_lock()
Date: Thu, 30 Apr 2015 12:53:59 +0200	[thread overview]
Message-ID: <1430391243-7112-3-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1430391243-7112-1-git-send-email-jgross@suse.com>

The decision whether the slowpath flag is to be cleared for
paravirtualized spinlocks is located in
__ticket_check_and_clear_slowpath() today.

Move that decision into arch_spin_lock() and add an unlikely attribute
to it to avoid calling a function in case the compiler chooses not to
inline __ticket_check_and_clear_slowpath() and the slowpath flag isn't
set.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/include/asm/spinlock.h | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index 8ceec8d..268b9da 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -66,20 +66,18 @@ static inline int  __tickets_equal(__ticket_t one, __ticket_t two)
 	return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
 }
 
-static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
-							__ticket_t head)
+static inline void __ticket_clear_slowpath(arch_spinlock_t *lock,
+					   __ticket_t head)
 {
-	if (head & TICKET_SLOWPATH_FLAG) {
-		arch_spinlock_t old, new;
+	arch_spinlock_t old, new;
 
-		old.tickets.head = head;
-		new.tickets.head = head & ~TICKET_SLOWPATH_FLAG;
-		old.tickets.tail = new.tickets.head + TICKET_LOCK_INC;
-		new.tickets.tail = old.tickets.tail;
+	old.tickets.head = head;
+	new.tickets.head = head & ~TICKET_SLOWPATH_FLAG;
+	old.tickets.tail = new.tickets.head + TICKET_LOCK_INC;
+	new.tickets.tail = old.tickets.tail;
 
-		/* try to clear slowpath flag when there are no contenders */
-		cmpxchg(&lock->head_tail, old.head_tail, new.head_tail);
-	}
+	/* try to clear slowpath flag when there are no contenders */
+	cmpxchg(&lock->head_tail, old.head_tail, new.head_tail);
 }
 
 static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
@@ -120,7 +118,8 @@ static __always_inline void arch_spin_lock(arch_spinlock_t *lock)
 		__ticket_lock_spinning(lock, inc.tail);
 	}
 clear_slowpath:
-	__ticket_check_and_clear_slowpath(lock, inc.head);
+	if (unlikely(inc.head & TICKET_SLOWPATH_FLAG))
+		__ticket_clear_slowpath(lock, inc.head);
 out:
 	barrier();	/* make sure nothing creeps before the lock is taken */
 }
-- 
2.1.4

  parent reply	other threads:[~2015-04-30 10:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 10:53 [PATCH 0/6] x86: reduce paravirtualized spinlock overhead Juergen Gross
2015-04-30 10:53 ` [PATCH 1/6] x86: use macro instead of "0" for setting TICKET_SLOWPATH_FLAG Juergen Gross
2015-04-30 10:53 ` Juergen Gross [this message]
2015-04-30 10:54 ` [PATCH 3/6] x86: introduce new pvops function clear_slowpath Juergen Gross
2015-04-30 10:54 ` [PATCH 4/6] x86: introduce new pvops function spin_unlock Juergen Gross
2015-04-30 10:54 ` [PATCH 5/6] x86: switch config from UNINLINE_SPIN_UNLOCK to INLINE_SPIN_UNLOCK Juergen Gross
2015-04-30 10:54 ` [PATCH 6/6] x86: remove no longer needed paravirt_ticketlocks_enabled Juergen Gross
2015-04-30 16:39 ` [PATCH 0/6] x86: reduce paravirtualized spinlock overhead Jeremy Fitzhardinge
2015-05-04  5:55   ` Juergen Gross
2015-05-05 17:21     ` Jeremy Fitzhardinge
2015-05-06 11:55       ` Juergen Gross
2015-05-17  5:30         ` Ingo Molnar
2015-05-18  8:11           ` Juergen Gross
2015-05-15 12:16 ` Juergen Gross
2015-06-08  4:09 ` Juergen Gross
2015-06-16 14:37 ` Juergen Gross
2015-06-16 15:18   ` Thomas Gleixner

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=1430391243-7112-3-git-send-email-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=akataria@vmware.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=chrisw@sous-sol.org \
    --cc=david.vrabel@citrix.com \
    --cc=gleb@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=konrad.wilk@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xensource.com \
    /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).