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) { 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; } owner = lp->owner_cpu; if (owner) smp_yield_cpu(~owner); local_irq_disable(); if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0) return; local_irq_restore(flags); } }
void arch_spin_lock_wait(arch_spinlock_t *lp) { unsigned int cpu = SPINLOCK_LOCKVAL; unsigned int owner; int count; while (1) { owner = ACCESS_ONCE(lp->lock); /* Try to get the lock if it is free. */ if (!owner) { if (_raw_compare_and_swap(&lp->lock, 0, cpu)) return; continue; } /* Check if the lock owner is running. */ if (!smp_vcpu_scheduled(~owner)) { smp_yield_cpu(~owner); continue; } /* Loop for a while on the lock value. */ count = spin_retry; do { owner = ACCESS_ONCE(lp->lock); } while (owner && count-- > 0); if (!owner) continue; /* * For multiple layers of hypervisors, e.g. z/VM + LPAR * yield the CPU if the lock is still unavailable. */ if (!MACHINE_IS_LPAR) smp_yield_cpu(~owner); } }
int _raw_write_trylock_retry(arch_rwlock_t *rw) { int count = spin_retry; while (count-- > 0) { if (!arch_write_can_lock(rw)) continue; if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0) return 1; } return 0; }
int arch_spin_trylock_retry(arch_spinlock_t *lp) { unsigned int cpu = ~smp_processor_id(); int count; 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 1; } return 0; }
int _raw_write_trylock_retry(arch_rwlock_t *rw) { unsigned int old; int count = spin_retry; while (count-- > 0) { old = ACCESS_ONCE(rw->lock); if (old) continue; if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000)) return 1; } return 0; }
int _raw_read_trylock_retry(arch_rwlock_t *rw) { unsigned int old; int count = spin_retry; while (count-- > 0) { old = ACCESS_ONCE(rw->lock); if ((int) old < 0) continue; if (_raw_compare_and_swap(&rw->lock, old, old + 1)) return 1; } return 0; }
int _raw_read_trylock_retry(arch_rwlock_t *rw) { unsigned int old; int count = spin_retry; while (count-- > 0) { if (!arch_read_can_lock(rw)) continue; old = rw->lock & 0x7fffffffU; if (_raw_compare_and_swap(&rw->lock, old, old + 1) == old) return 1; } return 0; }
void _raw_write_lock_wait(arch_rwlock_t *rw) { int count = spin_retry; while (1) { if (count-- <= 0) { smp_yield(); count = spin_retry; } if (!arch_write_can_lock(rw)) continue; if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0) return; } }
void _raw_write_lock_wait(arch_rwlock_t *rw) { unsigned int old; int count = spin_retry; while (1) { if (count-- <= 0) { smp_yield(); count = spin_retry; } old = ACCESS_ONCE(rw->lock); if (old) continue; if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000)) return; } }
void _raw_read_lock_wait(arch_rwlock_t *rw) { unsigned int old; int count = spin_retry; while (1) { if (count-- <= 0) { smp_yield(); count = spin_retry; } old = ACCESS_ONCE(rw->lock); if ((int) old < 0) continue; if (_raw_compare_and_swap(&rw->lock, old, old + 1)) return; } }
void _raw_write_lock_wait_flags(arch_rwlock_t *rw, unsigned long flags) { int count = spin_retry; local_irq_restore(flags); while (1) { if (count-- <= 0) { smp_yield(); count = spin_retry; } if (!arch_write_can_lock(rw)) continue; local_irq_disable(); if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0) return; } }
void _raw_read_lock_wait(arch_rwlock_t *rw) { unsigned int old; int count = spin_retry; while (1) { if (count-- <= 0) { smp_yield(); count = spin_retry; } if (!arch_read_can_lock(rw)) continue; old = rw->lock & 0x7fffffffU; if (_raw_compare_and_swap(&rw->lock, old, old + 1) == old) return; } }
void _raw_read_lock_wait_flags(arch_rwlock_t *rw, unsigned long flags) { unsigned int old; int count = spin_retry; local_irq_restore(flags); while (1) { if (count-- <= 0) { smp_yield(); count = spin_retry; } if (!arch_read_can_lock(rw)) continue; old = rw->lock & 0x7fffffffU; local_irq_disable(); if (_raw_compare_and_swap(&rw->lock, old, old + 1) == old) return; } }
void _raw_write_lock_wait_flags(arch_rwlock_t *rw, unsigned long flags) { unsigned int old; int count = spin_retry; local_irq_restore(flags); while (1) { if (count-- <= 0) { smp_yield(); count = spin_retry; } old = ACCESS_ONCE(rw->lock); if (old) continue; local_irq_disable(); if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000)) return; local_irq_restore(flags); } }
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) { if (owner && !smp_vcpu_scheduled(~owner)) smp_yield_cpu(~owner); count = spin_retry; } old = ACCESS_ONCE(rw->lock); owner = ACCESS_ONCE(rw->owner); if ((int) old < 0) continue; if (_raw_compare_and_swap(&rw->lock, old, old + 1)) return; } }
void _raw_write_lock_wait(arch_rwlock_t *rw) { unsigned int owner, old, prev; int count = spin_retry; prev = 0x80000000; 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); if ((int) old >= 0 && _raw_compare_and_swap(&rw->lock, old, old | 0x80000000)) prev = old; else smp_rmb(); if ((old & 0x7fffffff) == 0 && (int) prev >= 0) break; } }