函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:osq_lock

函数原型:bool osq_lock(struct optimistic_spin_queue *lock)

返回类型:bool

参数:

类型参数名称
struct optimistic_spin_queue *lock
92  node等于this_cpu_ptr( & An MCS like lock especially tailored for optimistic spinning for sleeping* lock implementations (mutex, rwsem, etc))
94  curr等于We use the value 0 to represent "no CPU", thus the encoded value* will be the CPU number incremented by 1.
97  1 if lock acquired 等于0
98  next = NULL
99  coded CPU # + 1 value 等于curr
107  old等于atomic_xchg( & * Stores an encoded value of the CPU # of the tail node in the queue. * If the queue is empty, then it's set to OSQ_UNLOCKED_VAL., curr)
108  如果old恒等于OSQ_UNLOCKED_VAL则返回:true
111  prev等于decode_cpu(old)
112  prev等于prev
124  smp_wmb()
126  WRITE_ONCE(next, node)
137  当非READ_ONCE(1 if lock acquired )循环
143  如果need_resched()或In order to reduce various lock holder preemption latencies provide an* interface to see if a vCPU is currently running or not则转到:unqueue
146  cpu_relax()
148  返回:true
150  unqueue :
159  循环
160  如果next恒等于nodecmpxchg( & next, node, NULL)恒等于node退出
169  如果smp_load_acquire( & 1 if lock acquired )则返回:true
172  cpu_relax()
178  prev等于READ_ONCE(prev)
188  next等于Get a stable @node->next pointer, either for unlock() or unqueue() purposes.* Can return NULL in case we were the last queued and we updated @lock instead.
189  如果非next则返回:false
200  WRITE_ONCE(prev, prev)
201  WRITE_ONCE(next, next)
203  返回:false