diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-27 16:20:17 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-27 16:20:17 -0800 |
commit | 7981164791d18d5ed1dcdfa9598949ed158a5333 (patch) | |
tree | 6565e7406dd55eb5014efd3e54109159a47cb10e /arch/s390/lib/spinlock.c | |
parent | f1dd6ad599732fc89f36fdd65a2c2cf3c63a8711 (diff) | |
parent | a8d6356cdabf4495aaae7d3e89eb058b1909761c (diff) | |
download | linux-7981164791d18d5ed1dcdfa9598949ed158a5333.tar.gz |
Merge branch 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6
* 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6: (35 commits)
[S390] time: remove unused code
[S390] zcore: Add prefix registers to dump header
[S390] correct vdso version string
[S390] add support for compressed kernels
[S390] Define new s390 ELF note sections in elf.h
[S390] codepage conversion of kernel parameter line
[S390] seq_file: convert drivers/s390/
[S390] add z9-ec/z10 instruction to kernel disassembler
[S390] dasd: correct offline processing
[S390] dasd: fix refcounting.
[S390] dasd: fix online/offline race
[S390] use kprobes_built_in() in mm/fault code
[S390] bug: use relative pointers in bug table entries
[S390] Cleanup struct _lowcore usage and defines.
[S390] free_initmem: reduce code duplication
[S390] Replace ENOTSUPP usage with EOPNOTSUPP
[S390] spinlock: check virtual cpu running status
[S390] sysinfo: fix SYSIB 3,2,2 structure
[S390] add MACHINE_IS_LPAR flag
[S390] qdio: optimize cache line usage of struct qdio_irq
...
Diffstat (limited to 'arch/s390/lib/spinlock.c')
-rw-r--r-- | arch/s390/lib/spinlock.c | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c index cff327f109a8..91754ffb9203 100644 --- a/arch/s390/lib/spinlock.c +++ b/arch/s390/lib/spinlock.c @@ -43,16 +43,24 @@ void arch_spin_lock_wait(arch_spinlock_t *lp) { int count = spin_retry; unsigned int cpu = ~smp_processor_id(); + unsigned int owner; while (1) { - if (count-- <= 0) { - unsigned int owner = lp->owner_cpu; - if (owner != 0) - _raw_yield_cpu(~owner); - count = spin_retry; + owner = lp->owner_cpu; + if (!owner || smp_vcpu_scheduled(~owner)) { + for (count = spin_retry; count > 0; count--) { + if (arch_spin_is_locked(lp)) + continue; + if (_raw_compare_and_swap(&lp->owner_cpu, 0, + cpu) == 0) + return; + } + if (MACHINE_IS_LPAR) + continue; } - if (arch_spin_is_locked(lp)) - continue; + owner = lp->owner_cpu; + if (owner) + _raw_yield_cpu(~owner); if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0) return; } @@ -63,17 +71,27 @@ void arch_spin_lock_wait_flags(arch_spinlock_t *lp, unsigned long flags) { int count = spin_retry; unsigned int cpu = ~smp_processor_id(); + unsigned int owner; local_irq_restore(flags); while (1) { - if (count-- <= 0) { - unsigned int owner = lp->owner_cpu; - if (owner != 0) - _raw_yield_cpu(~owner); - count = spin_retry; + owner = lp->owner_cpu; + if (!owner || smp_vcpu_scheduled(~owner)) { + for (count = spin_retry; count > 0; count--) { + if (arch_spin_is_locked(lp)) + continue; + local_irq_disable(); + if (_raw_compare_and_swap(&lp->owner_cpu, 0, + cpu) == 0) + return; + local_irq_restore(flags); + } + if (MACHINE_IS_LPAR) + continue; } - if (arch_spin_is_locked(lp)) - continue; + owner = lp->owner_cpu; + if (owner) + _raw_yield_cpu(~owner); local_irq_disable(); if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0) return; @@ -100,8 +118,11 @@ EXPORT_SYMBOL(arch_spin_trylock_retry); void arch_spin_relax(arch_spinlock_t *lock) { unsigned int cpu = lock->owner_cpu; - if (cpu != 0) - _raw_yield_cpu(~cpu); + if (cpu != 0) { + if (MACHINE_IS_VM || MACHINE_IS_KVM || + !smp_vcpu_scheduled(~cpu)) + _raw_yield_cpu(~cpu); + } } EXPORT_SYMBOL(arch_spin_relax); |