函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:do_semtimedop

函数原型:static long do_semtimedop(int semid, struct sembuf __user *tsops, unsigned nsops, const struct timespec64 *timeout)

返回类型:long

参数:

类型参数名称
intsemid
struct sembuf __user *tsops
unsignednsops
const struct timespec64 *timeout
1969  error等于负EINVAL
1972  sops等于fast_sops
1975  bool undos = TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., alter = TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., dupsop = false
1977  dup等于0, jiffies_left等于0
1980  ns等于ipc_ns
1982  如果nsops小于1或semid小于0则返回:负EINVAL
1984  如果nsops大于sc_semopm则返回:负E2BIG
1986  如果nsops大于~ 372 bytes on stack
1987  sops等于kvmalloc_array(nsops, sops的长度, GFP_KERNEL)
1988  如果(sops == NULL)则返回:负ENOMEM
1992  如果copy_from_user(sops, tsops, nsops * tsops的长度)则
1993  error等于负EFAULT
1994  转到:out_free
1997  如果timeout
1998  如果 seconds 小于0或 nanoseconds 小于0或 nanoseconds 大于等于1000000000L则
2000  error等于负EINVAL
2001  转到:out_free
2003  jiffies_left等于timespec64_to_jiffies(timeout)
2006  max等于0
2007 sop小于sopsnsops循环
2008  mask等于1ULL左移semaphore index in array 取模BITS_PER_LONG
2010  如果semaphore index in array 大于等于maxmax等于semaphore index in array
2012  如果peration flags 按位与undo the operation on exit undos = true
2014  如果dup按位与mask
2021  dupsop = true
2023  如果semaphore operation 不等于0则
2024  alter = true
2025  dup或等于mask
2029  如果undos
2031  un等于d_alloc_undo - lookup (and if not present create) undo array*@ns: namespace*@semid: semaphore array id* The function looks up (and if not present creates) the undo structure.* The size of the undo structure depends on the size of the semaphore
2032  如果是错误
2033  error等于错误
2034  转到:out_free
2036  否则
2037  un = NULL
2038  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
2041  sma等于sem_obtain_object_check(ns, semid)
2042  如果是错误
2043  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
2044  error等于错误
2045  转到:out_free
2048  error等于负EFBIG
2049  如果max大于等于. of semaphores in array
2050  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
2051  转到:out_free
2054  error等于负EACCES
2055  如果pcperms - check ipc permissions*@ns: ipc namespace*@ipcp: ipc permission set*@flag: desired permission set* Check user, group, other permissions for access* to ipc resources. return 0 if allowed*@flag will most probably be 0 or ``S_
2056  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
2057  转到:out_free
2060  error等于security_sem_semop( & permissions .. see ipc.h , sops, nsops, alter)
2061  如果error
2062  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
2063  转到:out_free
2066  error等于负EIDRM
2067  locknum等于If the request contains only one semaphore operation, and there are* no complex transactions pending, lock only the semaphore involved
2076  如果非pc_valid_object() - helper to sort out IPC_RMID races for codepaths* where the respective ipc_ids.rwsem is not being held down.* Checks whether the ipc object is still around or if it's gone already, as则转到:out_unlock_free
2085  如果unsemaphore set identifier 恒等于负1则转到:out_unlock_free
2088  array of pending operations 等于sops
2089  umber of operations 等于nsops
2090  undo structure 等于un
2091  process id of requesting process 等于task_tgid(当前进程)
2092  does *sops alter the array? 等于alter
2093  sops on more than one sem_num 等于dupsop
2095  error等于perform_atomic_semop(sma, & queue)
2096  如果error恒等于0则
2103  如果alterdo_smart_update - optimized update_queue*@sma: semaphore array*@sops: operations that were performed*@nsops: number of operations*@otime: force setting otime*@wake_q: lockless wake-queue head* do_smart_update() does the required calls to update_queue and
2105  否则set_semotime - set sem_otime*@sma: semaphore array*@sops: operations that modified the array, may be NULL* sem_otime is replicated to avoid cache line trashing.* This function sets one instance to the current time.
2108  sem_unlock(sma, locknum)
2109  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
2110  wake_up_q( & wake_q)
2112  转到:out_free
2114  如果error小于0则转到:out_unlock_free
2121  如果nsops恒等于1则
2123  idx等于array_index_nospec - sanitize an array index after a bounds check* For a code sequence like:* if (index < size) {* index = array_index_nospec(index, size);* val = array[index];* }* (semaphore index in array , . of semaphores in array )
2124  curr等于sems[idx]
2126  如果alter
2127  如果pending complex operations
2130  否则
2135  否则
2138  否则
2139  如果非pending complex operations merge_queues - merge single semop queues into global queue*@sma: semaphore array* This function merges all per-semaphore queues into the global queue.* It is necessary to achieve FIFO ordering for the pending single-sop
2142  如果alter添加链表项
2144  否则添加链表项
2147  pending complex operations 自加
2150  循环
2151  WRITE_ONCE(completion status of operation , - EINTR)
2152  his process 等于当前进程
2154  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;* (睡眠态)
2155  sem_unlock(sma, locknum)
2156  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
2158  如果timeoutjiffies_left等于schedule_timeout - sleep until timeout*@timeout: timeout value in jiffies* Make the current task sleep until @timeout jiffies have* elapsed
2160  否则进程调度
2174  error等于READ_ONCE(completion status of operation )
2175  如果error不等于负EINTR
2182  smp_mb()
2183  转到:out_free
2186  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
2187  locknum等于If the request contains only one semaphore operation, and there are* no complex transactions pending, lock only the semaphore involved
2189  如果非pc_valid_object() - helper to sort out IPC_RMID races for codepaths* where the respective ipc_ids.rwsem is not being held down.* Checks whether the ipc object is still around or if it's gone already, as则转到:out_unlock_free
2192  error等于READ_ONCE(completion status of operation )
2198  如果error不等于负EINTR则转到:out_unlock_free
2204  如果timeoutjiffies_left恒等于0则error等于负EAGAIN
2206 error恒等于负EINTR且非signal_pending(当前进程)循环
2208  unlink_queue(sma, & queue)
2210  out_unlock_free :
2211  sem_unlock(sma, locknum)
2212  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
2213  out_free :
2214  如果sops不等于fast_sopskvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
2216  返回:error
调用者
名称描述
ksys_semtimedop
SYSCALL_DEFINE3