diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-02-18 05:58:24 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-02-18 05:58:24 -0500 |
commit | cc1a99fb7466d767b606fe459f4d5db535e9ceee (patch) | |
tree | 543f75a2cbf4ab3577458126dd9650441f700461 /include/linux/spinlock.h | |
parent | a1e928af839fc088121bf6934d5f6cd493af7611 (diff) |
Switch to pthread_mutex_t for spinlocks, too
This fixes an observed journal deadlock - real spinlocks aren't safe in
userspace.
Diffstat (limited to 'include/linux/spinlock.h')
-rw-r--r-- | include/linux/spinlock.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index c9be6b61..bd51188d 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -2,27 +2,27 @@ #define __TOOLS_LINUX_SPINLOCK_H #include <linux/atomic.h> +#include <pthread.h> typedef struct { - int count; + pthread_mutex_t lock; } raw_spinlock_t; -#define __RAW_SPIN_LOCK_UNLOCKED(name) (raw_spinlock_t) { .count = 0 } +#define __RAW_SPIN_LOCK_UNLOCKED(name) (raw_spinlock_t) { .lock = PTHREAD_MUTEX_INITIALIZER } static inline void raw_spin_lock_init(raw_spinlock_t *lock) { - smp_store_release(&lock->count, 0); + pthread_mutex_init(&lock->lock, NULL); } static inline void raw_spin_lock(raw_spinlock_t *lock) { - while (xchg_acquire(&lock->count, 1)) - ; + pthread_mutex_lock(&lock->lock); } static inline void raw_spin_unlock(raw_spinlock_t *lock) { - smp_store_release(&lock->count, 0); + pthread_mutex_unlock(&lock->lock); } #define raw_spin_lock_irq(lock) raw_spin_lock(lock) |