diff options
| author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2014-09-22 10:34:38 -0400 |
|---|---|---|
| committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2014-09-25 04:52:13 -0400 |
| commit | bbae71bf9c2fe90dc5642d4cddbbc1994861fd92 (patch) | |
| tree | 80ce9213a904817502ffc588eb31d5731cc9a250 /arch/s390/lib | |
| parent | 94232a4332de3bc210e7067fd43521b3eb12336a (diff) | |
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.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c index 01f29bb9c71b..034a35a3e9c1 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) | |||
| 114 | unsigned int owner, old; | 114 | unsigned int owner, old; |
| 115 | int count = spin_retry; | 115 | int count = spin_retry; |
| 116 | 116 | ||
| 117 | #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES | ||
| 118 | __RAW_LOCK(&rw->lock, -1, __RAW_OP_ADD); | ||
| 119 | #endif | ||
| 117 | owner = 0; | 120 | owner = 0; |
| 118 | while (1) { | 121 | while (1) { |
| 119 | if (count-- <= 0) { | 122 | if (count-- <= 0) { |
| @@ -147,6 +150,35 @@ int _raw_read_trylock_retry(arch_rwlock_t *rw) | |||
| 147 | } | 150 | } |
| 148 | EXPORT_SYMBOL(_raw_read_trylock_retry); | 151 | EXPORT_SYMBOL(_raw_read_trylock_retry); |
| 149 | 152 | ||
| 153 | #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES | ||
| 154 | |||
| 155 | void _raw_write_lock_wait(arch_rwlock_t *rw, unsigned int prev) | ||
| 156 | { | ||
| 157 | unsigned int owner, old; | ||
| 158 | int count = spin_retry; | ||
| 159 | |||
| 160 | owner = 0; | ||
| 161 | while (1) { | ||
| 162 | if (count-- <= 0) { | ||
| 163 | if (owner && !smp_vcpu_scheduled(~owner)) | ||
| 164 | smp_yield_cpu(~owner); | ||
| 165 | count = spin_retry; | ||
| 166 | } | ||
| 167 | old = ACCESS_ONCE(rw->lock); | ||
| 168 | owner = ACCESS_ONCE(rw->owner); | ||
| 169 | smp_rmb(); | ||
| 170 | if ((int) old >= 0) { | ||
| 171 | prev = __RAW_LOCK(&rw->lock, 0x80000000, __RAW_OP_OR); | ||
| 172 | old = prev; | ||
| 173 | } | ||
| 174 | if ((old & 0x7fffffff) == 0 && (int) prev >= 0) | ||
| 175 | break; | ||
| 176 | } | ||
| 177 | } | ||
| 178 | EXPORT_SYMBOL(_raw_write_lock_wait); | ||
| 179 | |||
| 180 | #else /* CONFIG_HAVE_MARCH_Z196_FEATURES */ | ||
| 181 | |||
| 150 | void _raw_write_lock_wait(arch_rwlock_t *rw) | 182 | void _raw_write_lock_wait(arch_rwlock_t *rw) |
| 151 | { | 183 | { |
| 152 | unsigned int owner, old, prev; | 184 | unsigned int owner, old, prev; |
| @@ -173,6 +205,8 @@ void _raw_write_lock_wait(arch_rwlock_t *rw) | |||
| 173 | } | 205 | } |
| 174 | EXPORT_SYMBOL(_raw_write_lock_wait); | 206 | EXPORT_SYMBOL(_raw_write_lock_wait); |
| 175 | 207 | ||
| 208 | #endif /* CONFIG_HAVE_MARCH_Z196_FEATURES */ | ||
| 209 | |||
| 176 | int _raw_write_trylock_retry(arch_rwlock_t *rw) | 210 | int _raw_write_trylock_retry(arch_rwlock_t *rw) |
| 177 | { | 211 | { |
| 178 | unsigned int old; | 212 | unsigned int old; |
