cregit-Linux how code gets into the kernel

Release 4.14 arch/parisc/include/asm/spinlock.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_SPINLOCK_H

#define __ASM_SPINLOCK_H

#include <asm/barrier.h>
#include <asm/ldcw.h>
#include <asm/processor.h>
#include <asm/spinlock_types.h>


static inline int arch_spin_is_locked(arch_spinlock_t *x) { volatile unsigned int *a = __ldcw_align(x); return *a == 0; }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox2692.86%250.00%
Thomas Gleixner27.14%250.00%
Total28100.00%4100.00%

#define arch_spin_lock(lock) arch_spin_lock_flags(lock, 0)
static inline void arch_spin_lock_flags(arch_spinlock_t *x, unsigned long flags) { volatile unsigned int *a; mb(); a = __ldcw_align(x); while (__ldcw(a) == 0) while (*a == 0) if (flags & PSW_SM_I) { local_irq_enable(); cpu_relax(); local_irq_disable(); } else cpu_relax(); mb(); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox4360.56%342.86%
James Bottomley2535.21%114.29%
Thomas Gleixner22.82%228.57%
Linus Torvalds (pre-git)11.41%114.29%
Total71100.00%7100.00%


static inline void arch_spin_unlock(arch_spinlock_t *x) { volatile unsigned int *a; mb(); a = __ldcw_align(x); *a = 1; mb(); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox3085.71%240.00%
Linus Torvalds (pre-git)38.57%120.00%
Thomas Gleixner25.71%240.00%
Total35100.00%5100.00%


static inline int arch_spin_trylock(arch_spinlock_t *x) { volatile unsigned int *a; int ret; mb(); a = __ldcw_align(x); ret = __ldcw(a) != 0; mb(); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox4088.89%240.00%
Linus Torvalds (pre-git)36.67%120.00%
Thomas Gleixner24.44%240.00%
Total45100.00%5100.00%

/* * Read-write spinlocks, allowing multiple readers but only one writer. * Linux rwlocks are unfair to writers; they can be starved for an indefinite * time by readers. With care, they can also be taken in interrupt context. * * In the PA-RISC implementation, we have a spinlock and a counter. * Readers use the lock to serialise their access to the counter (which * records how many readers currently hold the lock). * Writers hold the spinlock, preventing any readers or other writers from * grabbing the rwlock. */ /* Note that we have to ensure interrupts are disabled in case we're * interrupted by some other code that wants to grab the same read lock */
static __inline__ void arch_read_lock(arch_rwlock_t *rw) { unsigned long flags; local_irq_save(flags); arch_spin_lock_flags(&rw->lock, flags); rw->counter++; arch_spin_unlock(&rw->lock); local_irq_restore(flags); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2552.08%114.29%
Matthew Wilcox1939.58%342.86%
Thomas Gleixner48.33%342.86%
Total48100.00%7100.00%

/* Note that we have to ensure interrupts are disabled in case we're * interrupted by some other code that wants to grab the same read lock */
static __inline__ void arch_read_unlock(arch_rwlock_t *rw) { unsigned long flags; local_irq_save(flags); arch_spin_lock_flags(&rw->lock, flags); rw->counter--; arch_spin_unlock(&rw->lock); local_irq_restore(flags); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2552.08%114.29%
Matthew Wilcox1939.58%342.86%
Thomas Gleixner48.33%342.86%
Total48100.00%7100.00%

/* Note that we have to ensure interrupts are disabled in case we're * interrupted by some other code that wants to grab the same read lock */
static __inline__ int arch_read_trylock(arch_rwlock_t *rw) { unsigned long flags; retry: local_irq_save(flags); if (arch_spin_trylock(&rw->lock)) { rw->counter++; arch_spin_unlock(&rw->lock); local_irq_restore(flags); return 1; } local_irq_restore(flags); /* If write-locked, we fail to acquire the lock */ if (rw->counter < 0) return 0; /* Wait until we have a realistic chance at the lock */ while (arch_spin_is_locked(&rw->lock) && rw->counter >= 0) cpu_relax(); goto retry; }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox9094.74%125.00%
Thomas Gleixner55.26%375.00%
Total95100.00%4100.00%

/* Note that we have to ensure interrupts are disabled in case we're * interrupted by some other code that wants to read_trylock() this lock */
static __inline__ void arch_write_lock(arch_rwlock_t *rw) { unsigned long flags; retry: local_irq_save(flags); arch_spin_lock_flags(&rw->lock, flags); if (rw->counter != 0) { arch_spin_unlock(&rw->lock); local_irq_restore(flags); while (rw->counter != 0) cpu_relax(); goto retry; } rw->counter = -1; /* mark as write-locked */ mb(); local_irq_restore(flags); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4552.94%112.50%
Matthew Wilcox3338.82%337.50%
Thomas Gleixner44.71%337.50%
Ingo Molnar33.53%112.50%
Total85100.00%8100.00%


static __inline__ void arch_write_unlock(arch_rwlock_t *rw) { rw->counter = 0; arch_spin_unlock(&rw->lock); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1560.00%120.00%
Matthew Wilcox728.00%120.00%
Thomas Gleixner312.00%360.00%
Total25100.00%5100.00%

/* Note that we have to ensure interrupts are disabled in case we're * interrupted by some other code that wants to read_trylock() this lock */
static __inline__ int arch_write_trylock(arch_rwlock_t *rw) { unsigned long flags; int result = 0; local_irq_save(flags); if (arch_spin_trylock(&rw->lock)) { if (rw->counter == 0) { rw->counter = -1; result = 1; } else { /* Read-locked. Oh well. */ arch_spin_unlock(&rw->lock); } } local_irq_restore(flags); return result; }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox7494.87%240.00%
Thomas Gleixner45.13%360.00%
Total78100.00%5100.00%

/* * read_can_lock - would read_trylock() succeed? * @lock: the rwlock in question. */
static __inline__ int arch_read_can_lock(arch_rwlock_t *rw) { return rw->counter >= 0; }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox1583.33%125.00%
Thomas Gleixner211.11%250.00%
Kyle McMartin15.56%125.00%
Total18100.00%4100.00%

/* * write_can_lock - would write_trylock() succeed? * @lock: the rwlock in question. */
static __inline__ int arch_write_can_lock(arch_rwlock_t *rw) { return !rw->counter; }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox1482.35%125.00%
Thomas Gleixner211.76%250.00%
Kyle McMartin15.88%125.00%
Total17100.00%4100.00%

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock) #define arch_write_lock_flags(lock, flags) arch_write_lock(lock) #endif /* __ASM_SPINLOCK_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox41664.20%635.29%
Linus Torvalds (pre-git)13220.37%15.88%
Thomas Gleixner426.48%423.53%
James Bottomley253.86%15.88%
Robin Holt142.16%15.88%
Ingo Molnar81.23%15.88%
Rolf Eike Beer60.93%15.88%
Kyle McMartin40.62%15.88%
Greg Kroah-Hartman10.15%15.88%
Total648100.00%17100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.