Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\futex.c Create Date:2022-07-28 10:54:39
Last Modify:2020-03-17 15:28:32 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Userspace tried a 0 -> TID atomic transition of the futex value* and failed. The kernel side here does the whole locking operation:* if there are waiters then it will block as a consequence of relying* on rt-mutexes, it does PI, etc

Proto:static int futex_lock_pi(unsigned int __user *uaddr, unsigned int flags, ktime_t *time, int trylock)

Type:int

Parameter:

TypeParameterName
unsigned int __user *uaddr
unsigned intflags
ktime_t *time
inttrylock
2881  struct futex_pi_state * pi_state = NULL
2882  struct task_struct * exiting = NULL
2885  q = futex_q_init
2888  If Not IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_FUTEX_PI) Then Return -ENOSYS
2891  If PI code: Then Return -ENOMEM
2894  to = ex_setup_timer - set up the sleeping hrtimer
2896  retry :
2897  ret = get_futex_key() - Get parameters which are the keys for a futex*@uaddr: virtual address of the futex*@fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED*@key: address where result is stored
2898  If Value for the false possibility is greater at compile time(ret != 0) Then Go to out
2901  retry_private :
2902  hb = The key must be already stored in q->key.
2904  ret = ex_lock_pi_atomic() - Atomic work required to acquire a pi aware futex*@uaddr: the pi futex user address*@hb: the pi futex hash bucket*@key: the futex key associated with uaddr and hb*@ps: the pi_state pointer where we store the result of the* lookup
2906  If Value for the false possibility is greater at compile time(ret) Then
2912  Case ret == 1
2914  ret = 0
2915  Go to out_unlock_put_key
2916  Case ret == -EFAULT
2917  Go to uaddr_faulted
2918  Case ret == -EBUSY
2919  Case ret == -EAGAIN
2926  queue_unlock(hb)
2927  put_futex_key( & key)
2934  cond_resched()
2935  Go to retry
2936  Default
2937  Go to out_unlock_put_key
2941  WARN_ON(!pi_state)
2946  __queue_me( & q, hb)
2948  If trylock Then
2949  ret = Futex variant, must not use fastpath.
2951  ret = If ret Then 0 Else -EWOULDBLOCK
2952  Go to no_block
2955  rt_mutex_init_waiter( & rt_waiter)
2970  raw_spin_lock_irq( & wait_lock)
2971  spin_unlock(lock_ptr)
2977  ret = __rt_mutex_start_proxy_lock() - Start lock acquisition for another task*@lock: the rt_mutex to take*@waiter: the pre-initialized rt_mutex_waiter*@task: the task to prepare* Starts the rt_mutex acquire; it enqueues the @waiter and does deadlock* detection
2978  raw_spin_unlock_irq( & wait_lock)
2980  If ret Then
2981  If ret == 1 Then ret = 0
2983  Go to cleanup
2986  If Value for the false possibility is greater at compile time(to) Then hrtimer_sleeper_start_expires - Start a hrtimer sleeper timer*@sl: sleeper to be started*@mode: timer mode abs/rel* Wrapper around hrtimer_start_expires() for hrtimer_sleeper based timers* to allow PREEMPT_RT to tweak the delivery mode (soft/hardirq
2989  ret = _mutex_wait_proxy_lock() - Wait for lock acquisition*@lock: the rt_mutex we were woken on*@to: the timeout, null if none
2991  cleanup :
2992  spin_lock(lock_ptr)
3002  If ret && Not _mutex_cleanup_proxy_lock() - Cleanup failed lock acquisition*@lock: the rt_mutex we were woken on*@waiter: the pre-initialized rt_mutex_waiter* Attempt to clean up after a failed __rt_mutex_start_proxy_lock() or* rt_mutex_wait_proxy_lock() Then ret = 0
3005  no_block :
3010  res = xup_owner() - Post lock pi_state and corner case management*@uaddr: user address of the futex*@q: futex_q (contains pi_state and access to the rt_mutex)*@locked: if the attempt to take the rt_mutex succeeded (1) or not (0)* After attempting to lock an
3015  If res Then ret = If res < 0 Then res Else 0
3022  If ret && rt_mutex_owner( & The PI object:) == current process Then
3023  pi_state = pi_state
3024  get_pi_state(pi_state)
3028  PI futexes can not be requeued and must remove themself from the* hash bucket. The hash bucket lock (i.e. lock_ptr) is held on entry* and dropped here.
3030  If pi_state Then
3031  rt_mutex_futex_unlock( & The PI object:)
3032  Drops a reference to the pi_state object and frees or caches it* when the last reference is gone.
3035  Go to out_put_key
3037  out_unlock_put_key :
3038  queue_unlock(hb)
3040  out_put_key :
3041  put_futex_key( & key)
3042  out :
3043  If to Then
3044  hrtimer_cancel - cancel a timer and wait for the handler to finish.*@timer: the timer to be cancelled* Returns:* 0 when the timer was not active* 1 when the timer was active
3045  destroy_hrtimer_on_stack( & timer)
3047  Return If ret != -EINTR Then ret Else -ERESTARTNOINTR
3049  uaddr_faulted :
3050  queue_unlock(hb)
3052  ret = ault_in_user_writeable() - Fault in user address and verify RW access*@uaddr: pointer to faulting user space address* Slow path to fixup the fault we just took in the atomic write* access to @uaddr
3053  If ret Then Go to out_put_key
3056  If Not (flags & Futex flags used to encode options to functions and preserve them across* restarts.) Then Go to retry_private
3059  put_futex_key( & key)
3060  Go to retry
Caller
NameDescribe
do_futex