All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: akpm@osdl.org
Cc: paulus@samba.org, linux-kernel@vger.kernel.org
Subject: [PATCH] SPLPAR spinlock optimisation
Date: Sun, 4 Jul 2004 20:11:58 +1000	[thread overview]
Message-ID: <20040704101158.GF4923@krispykreme> (raw)


Currently our spinlocks can call into the hypervisor on dedicated
processor machines. Doing this may slow our locks down, so avoid it
where possible.

Signed-off-by: Anton Blanchard <anton@samba.org>

diff -puN arch/ppc64/lib/locks.c~splpar_speedup arch/ppc64/lib/locks.c
--- foobar2/arch/ppc64/lib/locks.c~splpar_speedup	2004-07-04 19:40:39.518987541 +1000
+++ foobar2-anton/arch/ppc64/lib/locks.c	2004-07-04 19:55:27.966154716 +1000
@@ -38,6 +38,10 @@
 
 /* waiting for a spinlock... */
 #if defined(CONFIG_PPC_SPLPAR) || defined(CONFIG_PPC_ISERIES)
+
+/* We only yield to the hypervisor if we are in shared processor mode */
+#define SHARED_PROCESSOR (get_paca()->lppaca.xSharedProc)
+
 void __spin_yield(spinlock_t *lock)
 {
 	unsigned int lock_value, holder_cpu, yield_count;
@@ -65,6 +69,7 @@ void __spin_yield(spinlock_t *lock)
 
 #else /* SPLPAR || ISERIES */
 #define __spin_yield(x)	barrier()
+#define SHARED_PROCESSOR	0
 #endif
 
 /*
@@ -104,7 +109,8 @@ void _raw_spin_lock(spinlock_t *lock)
 			break;
 		do {
 			HMT_low();
-			__spin_yield(lock);
+			if (SHARED_PROCESSOR)
+				__spin_yield(lock);
 		} while (likely(lock->lock != 0));
 		HMT_medium();
 	}
@@ -123,7 +129,8 @@ void _raw_spin_lock_flags(spinlock_t *lo
 		local_irq_restore(flags);
 		do {
 			HMT_low();
-			__spin_yield(lock);
+			if (SHARED_PROCESSOR)
+				__spin_yield(lock);
 		} while (likely(lock->lock != 0));
 		HMT_medium();
 		local_irq_restore(flags_dis);
@@ -134,8 +141,12 @@ EXPORT_SYMBOL(_raw_spin_lock_flags);
 
 void spin_unlock_wait(spinlock_t *lock)
 {
-	while (lock->lock)
-		__spin_yield(lock);
+	while (lock->lock) {
+		HMT_low();
+		if (SHARED_PROCESSOR)
+			__spin_yield(lock);
+	}
+	HMT_medium();
 }
 
 EXPORT_SYMBOL(spin_unlock_wait);
@@ -213,7 +224,8 @@ void _raw_read_lock(rwlock_t *rw)
 			break;
 		do {
 			HMT_low();
-			__rw_yield(rw);
+			if (SHARED_PROCESSOR)
+				__rw_yield(rw);
 		} while (likely(rw->lock < 0));
 		HMT_medium();
 	}
@@ -275,7 +287,8 @@ void _raw_write_lock(rwlock_t *rw)
 			break;
 		do {
 			HMT_low();
-			__rw_yield(rw);
+			if (SHARED_PROCESSOR)
+				__rw_yield(rw);
 		} while (likely(rw->lock != 0));
 		HMT_medium();
 	}

_

                 reply	other threads:[~2004-07-04 10:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20040704101158.GF4923@krispykreme \
    --to=anton@samba.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.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.