Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:This function must be called with the sem->wait_lock held to prevent* race conditions between checking the rwsem wait list and setting the* If wstate is WRITER_HANDOFF, it will make sure that either the handoff

Proto:static inline bool rwsem_try_write_lock(struct rw_semaphore *sem, enum writer_wait_state wstate)

Type:bool

Parameter:

TypeParameterName
struct rw_semaphore *sem>count accordingly.
enum writer_wait_statewstate
568  lockdep_assert_held( & wait_lock)
570  count = atomic_long_read( & count)
571  Do
572  has_handoff = Not Not (count & RWSEM_FLAG_HANDOFF)
574  If has_handoff && wstate == Writer is not first in wait list Then Return false
577  new = count
579  If count & RWSEM_LOCK_MASK Then
580  If has_handoff || wstate != WRITER_HANDOFF Then Return false
584  Else
591  When Not atomic_long_try_cmpxchg_acquire( & count, & count, new) cycle
597  If new & RWSEM_FLAG_HANDOFF Then Return false
600  All writes to owner are protected by WRITE_ONCE() to make sure that* store tearing can't happen as optimistic spinners may read and use* the owner value concurrently without lock
601  Return true
Caller
NameDescribe
rwsem_down_write_slowpathWait until we successfully acquire the write lock