函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:Wait for the read lock to be granted

函数原型:static struct rw_semaphore __sched *rwsem_down_read_slowpath(struct rw_semaphore *sem, int state)

返回类型:struct rw_semaphore

参数:

类型参数名称
struct rw_semaphore *sem
intstate
997  adjustment等于负RWSEM_READER_BIAS
1000  bool wake = false
1006  last_rowner等于atomic_long_read( & Write owner or one of the read owners as well flags regarding* the current state of the rwsem. Can be used as a speculative* check to see if the write owner is running on the cpu.)
1007  如果非last_rowner按位与The least significant 3 bits of the owner value has the following* meanings when set.* - Bit 0: RWSEM_READER_OWNED - The rwsem is owned by readers* - Bit 1: RWSEM_RD_NONSPINNABLE - Readers cannot spin on this lock.的值则last_rowner与等于RWSEM_RD_NONSPINNABLE
1010  如果非rwsem_can_spin_on_owner(sem, RWSEM_RD_NONSPINNABLE)则转到:queue
1016  atomic_long_add( - RWSEM_READER_BIAS, & count)
1017  adjustment等于0
1018  如果rwsem_optimistic_spin(sem, false)则
1024  如果atomic_long_read( & count)按位与RWSEM_FLAG_WAITERS
1030  wake_up_q( & wake_q)
1032  返回:sem
1033  否则如果rwsem_reader_phase_trylock(sem, last_rowner)则
1035  返回:sem
1038  queue :
1039  task等于当前进程
1040  type等于RWSEM_WAITING_FOR_READ
1041  timeout等于jiffiesThe typical HZ value is either 250 or 1000. So set the minimum waiting* time to at least 4ms or 1 jiffy (if it is higher than 4ms) in the wait* queue before initiating the handoff protocol.
1043  关闭本地中断,获取所要保护的运行队列(runqueue)的自旋锁(spinlock),为查找可运行进程做准备。( & wait_lock)
1044  如果链表为空
1051  如果adjustment且非atomic_long_read( & count)按位与RWSEM_WRITER_MASK按位或RWSEM_FLAG_HANDOFF的值的值则
1058  返回:sem
1060  adjustment加等于RWSEM_FLAG_WAITERS
1062  添加链表项
1065  如果adjustmentcount等于atomic_long_add_return(adjustment, & count)
1067  否则count等于atomic_long_read( & count)
1076  如果非count按位与RWSEM_LOCK_MASK的值则
1077  clear_wr_nonspinnable(sem)
1078  wake = true
1080  如果wake或非count按位与RWSEM_WRITER_MASK的值且adjustment按位与RWSEM_FLAG_WAITERShandle 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
1084  raw_spin_unlock_irq( & wait_lock)
1085  wake_up_q( & wake_q)
1088  循环
1089  set_current_state(state)
1090  如果非smp_load_acquire( & task)则
1092  退出
1096  如果task则转到:out_nolock
1100  退出
1102  进程调度
1106  set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:* for (;;) {* set_current_state(TASK_UNINTERRUPTIBLE);* if (!need_sleep)* break;* (就绪态)
1108  返回:sem
1110  out_nolock :
1111  删除链表项
1112  如果链表为空
1113  atomic_long_andnot(RWSEM_FLAG_WAITERS | RWSEM_FLAG_HANDOFF, & count)
1116  raw_spin_unlock_irq( & wait_lock)
1117  set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:* for (;;) {* set_current_state(TASK_UNINTERRUPTIBLE);* if (!need_sleep)* break;* (就绪态)
1119  返回:错误号
调用者
名称描述
__down_readlock for reading
__down_read_killable