summaryrefslogtreecommitdiffstats
path: root/arch/s390/lib
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2014-09-22 16:34:38 +0200
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2014-09-25 10:52:13 +0200
commitbbae71bf9c2fe90dc5642d4cddbbc1994861fd92 (patch)
tree80ce9213a904817502ffc588eb31d5731cc9a250 /arch/s390/lib
parent94232a4332de3bc210e7067fd43521b3eb12336a (diff)
downloadop-kernel-dev-bbae71bf9c2fe90dc5642d4cddbbc1994861fd92.zip
op-kernel-dev-bbae71bf9c2fe90dc5642d4cddbbc1994861fd92.tar.gz
s390/rwlock: use the interlocked-access facility 1 instructions
Make use of the load-and-add, load-and-or and load-and-and instructions to atomically update the read-write lock without a compare-and-swap loop. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/lib')
-rw-r--r--arch/s390/lib/spinlock.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c
index 01f29bb..034a35a 100644
--- a/arch/s390/lib/spinlock.c
+++ b/arch/s390/lib/spinlock.c
@@ -114,6 +114,9 @@ void _raw_read_lock_wait(arch_rwlock_t *rw)
unsigned int owner, old;
int count = spin_retry;
+#ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
+ __RAW_LOCK(&rw->lock, -1, __RAW_OP_ADD);
+#endif
owner = 0;
while (1) {
if (count-- <= 0) {
@@ -147,6 +150,35 @@ int _raw_read_trylock_retry(arch_rwlock_t *rw)
}
EXPORT_SYMBOL(_raw_read_trylock_retry);
+#ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
+
+void _raw_write_lock_wait(arch_rwlock_t *rw, unsigned int prev)
+{
+ unsigned int owner, old;
+ int count = spin_retry;
+
+ owner = 0;
+ while (1) {
+ if (count-- <= 0) {
+ if (owner && !smp_vcpu_scheduled(~owner))
+ smp_yield_cpu(~owner);
+ count = spin_retry;
+ }
+ old = ACCESS_ONCE(rw->lock);
+ owner = ACCESS_ONCE(rw->owner);
+ smp_rmb();
+ if ((int) old >= 0) {
+ prev = __RAW_LOCK(&rw->lock, 0x80000000, __RAW_OP_OR);
+ old = prev;
+ }
+ if ((old & 0x7fffffff) == 0 && (int) prev >= 0)
+ break;
+ }
+}
+EXPORT_SYMBOL(_raw_write_lock_wait);
+
+#else /* CONFIG_HAVE_MARCH_Z196_FEATURES */
+
void _raw_write_lock_wait(arch_rwlock_t *rw)
{
unsigned int owner, old, prev;
@@ -173,6 +205,8 @@ void _raw_write_lock_wait(arch_rwlock_t *rw)
}
EXPORT_SYMBOL(_raw_write_lock_wait);
+#endif /* CONFIG_HAVE_MARCH_Z196_FEATURES */
+
int _raw_write_trylock_retry(arch_rwlock_t *rw)
{
unsigned int old;
OpenPOWER on IntegriCloud