函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\locking\qspinlock.c Create Date:2022-07-27 10:51:58
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:queued_spin_lock_slowpath - acquire the queued spinlock*@lock: Pointer to queued spinlock structure*@val: Current value of the queued spinlock 32-bit word* (queue tail, pending bit, lock value)* fast : slow : unlock* : :* uncontended (0,0,0) -:--> (0,0,1)

函数原型:void queued_spin_lock_slowpath(struct qspinlock *lock, unsigned int val)

返回类型:void

参数:

类型参数名称
struct qspinlock *lock
unsigned intval
320  BUILD_BUG_ON - break compile if a condition is true(FIXME: This should be fixed in the arch's Kconfig >= (1U << _Q_TAIL_CPU_BITS))
322  如果pv_enabled()则转到:pv_queue
325  如果virt_spin_lock(lock)则返回
334  如果val恒等于_Q_PENDING_VAL
335  cnt等于_Q_PENDING_LOOPS
336  val等于atomic_cond_read_relaxed( & val, (VAL != _Q_PENDING_VAL) || !cnt--)
343  如果val按位与_Q_LOCKED_MASK的反则转到:queue
351  val等于queued_fetch_set_pending_acquire(lock)
360  如果此条件成立可能性小(为编译器优化)(val & ~_Q_LOCKED_MASK)则
363  如果非val按位与_Q_PENDING_MASK的值则lear_pending - clear the pending bit.*@lock: Pointer to queued spinlock structure* *,1,* -> *,0,*
366  转到:queue
380  如果val按位与_Q_LOCKED_MASKatomic_cond_read_acquire( & val, !(VAL & _Q_LOCKED_MASK))
388  lear_pending_set_locked - take ownership and clear the pending bit.*@lock: Pointer to queued spinlock structure* *,1,0 -> *,0,1* Lock stealing is not allowed if this function is used.
390  返回
396  queue :
398  pv_queue :
399  node等于this_cpu_ptr( & mcs)
400  idx等于 nesting count, see qspinlock.c 自加
401  tail等于We must be able to distinguish between no-tail and the tail at 0:0,* therefore increment the cpu number by one.
412  如果此条件成立可能性小(为编译器优化)(idx >= MAX_NODES)则
414  当非queued_spin_trylock - try to acquire the queued spinlock*@lock : Pointer to queued spinlock structure* Return: 1 if lock acquired, 0 if failed循环
415  cpu_relax()
416  转到:release
419  node等于grab_mcs_node(node, idx)
431  The "volatile" is due to gcc bugs ()
433  1 if lock acquired 等于0
434  next = NULL
435  pv_init_node(node)
442  如果queued_spin_trylock - try to acquire the queued spinlock*@lock : Pointer to queued spinlock structure* Return: 1 if lock acquired, 0 if failed则转到:release
450  smp_wmb()
459  old等于xchg_tail - Put in the new queue tail code word & retrieve previous one*@lock : Pointer to queued spinlock structure*@tail : The new queue tail code word* Return: The previous queue tail code word* xchg(lock, tail), which heads an address dependency*
460  next = NULL
466  如果old按位与_Q_TAIL_MASK
467  prev等于decode_tail(old)
470  WRITE_ONCE(next, node)
472  pv_wait_node(node, prev)
473  Using smp_cond_load_acquire() provides the acquire semantics* required so that subsequent operations happen after the* lock is acquired. Additionally, some architectures such as* ARM64 would like to do spin-waiting instead of purely( & 1 if lock acquired )
481  next等于READ_ONCE(next)
482  如果next3dnow prefetch to get an exclusive cache line.* Useful for spinlocks to avoid one state transition in the* cache coherency protocol:
507  如果val等于pv_wait_head_or_lock(lock, node)则转到:locked
510  val等于atomic_cond_read_acquire( & val, !(VAL & _Q_LOCKED_PENDING_MASK))
512  locked :
534  如果val按位与_Q_TAIL_MASK的值恒等于tail
535  如果atomic_try_cmpxchg_relaxed( & val, & val, _Q_LOCKED_VAL)则转到:release
544  set_locked - Set the lock bit and own the lock*@lock: Pointer to queued spinlock structure* *,*,0 -> *,0,1
549  如果非nextnext等于smp_cond_load_relaxed() - (Spin) wait for cond with no ordering guarantees*@ptr: pointer to the variable to wait on*@cond: boolean expression to wait for* Equivalent to using READ_ONCE() on the condition variable( & next, (VAL))
552  smp_store_release() provides a memory barrier to ensure all* operations in the critical section has been completed before* unlocking.( & 1 if lock acquired )
553  pv_kick_node(lock, next)
555  release :
559  __this_cpu_dec(count)
调用者
名称描述
queued_spin_lockqueued_spin_lock - acquire a queued spinlock*@lock: Pointer to queued spinlock structure