Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:handle the lock release when processes blocked on it that can now run* - if we come here from up_xxxx(), then the RWSEM_FLAG_WAITERS bit must* have been set

Proto:static void rwsem_mark_wake(struct rw_semaphore *sem, enum rwsem_wake_type wake_type, struct wake_q_head *wake_q)

Type:void

Parameter:

TypeParameterName
struct rw_semaphore *sem
enum rwsem_wake_typewake_type
struct wake_q_head *wake_q
406  woken = 0 , adjustment = 0
409  lockdep_assert_held( & wait_lock)
415  waiter = rwsem_first_waiter(sem)
417  If type == RWSEM_WAITING_FOR_WRITE Then
430  Return
436  If Value for the false possibility is greater at compile time(atomic_long_read( & count) < 0) Then Return
444  If wake_type != RWSEM_WAKE_READ_OWNED Then
447  adjustment = RWSEM_READER_BIAS
448  oldcount = atomic_long_fetch_add(adjustment, & count)
462  Return
470  owner = task
475  The task_struct pointer of the last owning reader will be left in* the owner field.* Note that the owner value just indicates the task has owned the rwsem* previously, it may not be the real owner or one of the real owners
501  Initialization list head
503  If type == RWSEM_WAITING_FOR_WRITE Then Continue
506  woken++
507  list_move_tail - delete from one list and add as another's tail*@list: the entry to move*@head: the head that will follow our entry
512  If woken >= Magic number to batch-wakeup waiting readers, even when writers are* also present in the queue. This both limits the amount of work the* waking thread must do and also prevents any potential counter overflow,* however unlikely. Then Break
516  adjustment = woken * RWSEM_READER_BIAS - adjustment
518  If list_empty - tests whether a list is empty*@head: the list to test. Then
520  adjustment -= RWSEM_FLAG_WAITERS
527  If woken && atomic_long_read( & count) & RWSEM_FLAG_HANDOFF Then adjustment -= RWSEM_FLAG_HANDOFF
530  If adjustment Then atomic_long_add(adjustment, & count)
537  tsk = task
538  get_task_struct(tsk)
546  smp_store_release( & task, NULL)
551  wake_q_add_safe() - safely queue a wakeup for 'later' waking
Caller
NameDescribe
rwsem_down_read_slowpathWait for the read lock to be granted
rwsem_down_write_slowpathWait until we successfully acquire the write lock
rwsem_wakehandle waking up a waiter on the semaphore* - up_read/up_write has decremented the active part of count if we come here
rwsem_downgrade_wakedowngrade a write lock into a read lock* - caller incremented waiting part of count and discovered it still negative* - just wake up any readers at the front of the queue