raw_spin_lock_irqsave() flow
include/linux/spinlock.h
#define raw_spin_lock_irqsave(lock, flags) do { typecheck(unsigned long, flags); flags = _raw_spin_lock_irqsave(lock); } while (0)
static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t *lock)
static inline void do_raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long *flags) __acquires(lock) { __acquire(lock); arch_spin_lock_flags(&lock->raw_lock, *flags); }
上面raw_lock是:
arch_spinlock_t raw_lock;
arch_spinlock_t为qspinlock:
typedef struct qspinlock { union { atomic_t val; /* * By using the whole 2nd least significant byte for the * pending bit, we can allow better optimization of the lock * acquisition for the pending bit holder. */ #ifdef __LITTLE_ENDIAN struct { u8 locked; u8 pending; }; struct { u16 locked_pending; u16 tail; }; #else struct { u16 tail; u16 locked_pending; }; struct { u8 reserved[2]; u8 pending; u8 locked; }; #endif }; } arch_spinlock_t;
上面arch_spin_lock_flags define为arch_spin_lock(),这个define在qspinlock.h
#ifndef arch_spin_lock_flags #define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock) #endif
4.19includeasm-genericQspinlock.h
#define arch_spin_lock(l) queued_spin_lock(l)