Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\locking\osq_lock.c Create Date:2022-07-28 09:51:18
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:osq_lock

Proto:bool osq_lock(struct optimistic_spin_queue *lock)

Type:bool

Parameter:

TypeParameterName
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  If old == OSQ_UNLOCKED_VAL Then Return true
111  prev = decode_cpu(old)
112  prev = prev
124  smp_wmb()
126  WRITE_ONCE(next, node)
137  When Not READ_ONCE(1 if lock acquired ) cycle
143  If need_resched() || In order to reduce various lock holder preemption latencies provide an* interface to see if a vCPU is currently running or not Then Go to unqueue
146  cpu_relax()
148  Return true
150  unqueue :
159  cycle
160  If next == node && cmpxchg( & next, node, NULL) == node Then Break
169  If smp_load_acquire( & 1 if lock acquired ) Then Return 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  If Not next Then Return false
200  WRITE_ONCE(prev, prev)
201  WRITE_ONCE(next, next)
203  Return false