queued spinlock 자물쇠 사용

qspinlock queued spinlock   ,                   spinlock  
     ,        
qspinlock        kernel/qspinlock.c 
struct __qspinlock {
	union {
		atomic_t val;
#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
    qspinlock         ,                      
      :
/*
 * Bitfields in the atomic value:
 *
 * When NR_CPUS < 16K
 *  0- 7: locked byte
 *     8: pending
 *  9-15: not used
 * 16-17: tail index
 * 18-31: tail cpu (+1)
 *
 * When NR_CPUS >= 16K
 *  0- 7: locked byte
 *     8: pending
 *  9-10: tail index
 * 11-31: tail cpu (+1)
 */
 qspinlock    API     include/asm-generic/qspinlock.h 
 #define arch_spin_is_locked(l)		queued_spin_is_locked(l)
#define arch_spin_is_contended(l)	queued_spin_is_contended(l)
#define arch_spin_value_unlocked(l)	queued_spin_value_unlocked(l)
#define arch_spin_lock(l)		queued_spin_lock(l)
#define arch_spin_trylock(l)		queued_spin_trylock(l)
#define arch_spin_unlock(l)		queued_spin_unlock(l)

                 qspinlock       。       spinlock        
static __always_inline int spin_is_locked(spinlock_t *lock)
{
	return raw_spin_is_locked(&lock->rlock);
}
#define raw_spin_is_locked(lock)	arch_spin_is_locked(&(lock)->raw_lock)
      qspinlock          ,       qspinlock,       code       qspinlock   
    
 makefile         qspinlock  ,    CONFIG_QUEUED_SPINLOCKS
obj-$(CONFIG_QUEUED_SPINLOCKS) += qspinlock.o

좋은 웹페이지 즐겨찾기