Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\locking\rtmutex.c Create Date:2022-07-28 09:52:08
Last Modify:2020-03-17 14:26:38 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Adjust the priority chain

Proto:static int rt_mutex_adjust_prio_chain(struct task_struct *task, enum rtmutex_chainwalk chwalk, struct rt_mutex *orig_lock, struct rt_mutex *next_lock, struct rt_mutex_waiter *orig_waiter, struct task_struct *top_task)

Type:int

Parameter:

TypeParameterName
struct task_struct *task
enum rtmutex_chainwalkchwalk
struct rt_mutex *orig_lock
struct rt_mutex *next_lock
struct rt_mutex_waiter *orig_waiter
struct task_struct *top_task
456  top_waiter = orig_waiter
458  ret = 0 , depth = 0
461  bool requeue = true
463  detect_deadlock = Deadlock detection is conditional:* If CONFIG_DEBUG_RT_MUTEXES=n, deadlock detection is only conducted* if the detect argument is == RT_MUTEX_FULL_CHAINWALK.* If CONFIG_DEBUG_RT_MUTEXES=y, deadlock detection is always
471  again :
475  If ++depth > Max number of times we'll walk the boosting chain: Then
488  put_task_struct(task)
490  Return -EDEADLK
499  retry :
503  raw_spin_lock_irq( & Protection of the PI data structures: )
508  waiter = pi_blocked_on
519  If Not waiter Then Go to out_unlock_pi
526  If orig_waiter && Not rt_mutex_owner(orig_lock) Then Go to out_unlock_pi
538  If next_lock != lock Then Go to out_unlock_pi
546  If top_waiter Then
547  If Not task_has_pi_waiters(task) Then Go to out_unlock_pi
555  If top_waiter != task_top_pi_waiter(task) Then
556  If Not detect_deadlock Then Go to out_unlock_pi
558  Else requeue = false
570  If rt_mutex_waiter_equal(waiter, Only use with rt_mutex_waiter_{less,equal}()(task)) Then
571  If Not detect_deadlock Then Go to out_unlock_pi
573  Else requeue = false
580  lock = lock
586  If Not Define the various spin_lock methods. Note we define these* regardless of whether CONFIG_SMP or CONFIG_PREEMPTION are set. The* various methods are defined as nops in the case they are not* required.( & wait_lock) Then
587  raw_spin_unlock_irq( & Protection of the PI data structures: )
588  cpu_relax()
589  Go to retry
601  If lock == orig_lock || rt_mutex_owner(lock) == top_task Then
602  debug_rt_mutex_deadlock(chwalk, orig_waiter, lock)
603  raw_spin_unlock( & wait_lock)
604  ret = -EDEADLK
605  Go to out_unlock_pi
614  If Not requeue Then
618  raw_spin_unlock( & Protection of the PI data structures: )
619  put_task_struct(task)
625  If Not rt_mutex_owner(lock) Then
627  Return 0
631  task = get_task_struct(rt_mutex_owner(lock))
632  raw_spin_lock( & Protection of the PI data structures: )
640  next_lock = task_blocked_on_lock(task)
644  top_waiter = rt_mutex_top_waiter(lock)
647  raw_spin_unlock( & Protection of the PI data structures: )
648  raw_spin_unlock_irq( & wait_lock)
651  If Not next_lock Then Go to out_put_task
653  Go to again
661  prerequeue_top_waiter = rt_mutex_top_waiter(lock)
664  rt_mutex_dequeue(lock, waiter)
682  prio = prio
683  deadline = Absolute deadline for this instance
685  rt_mutex_enqueue(lock, waiter)
688  raw_spin_unlock( & Protection of the PI data structures: )
689  put_task_struct(task)
698  If Not rt_mutex_owner(lock) Then
704  If prerequeue_top_waiter != rt_mutex_top_waiter(lock) Then wake_up_process - Wake up a specific process*@p: The process to be woken up.* Attempt to wake up the nominated process and move it to the set of runnable* processes.* Return: 1 if the process was woken up, 0 if it was already running.
706  raw_spin_unlock_irq( & wait_lock)
707  Return 0
711  task = get_task_struct(rt_mutex_owner(lock))
712  raw_spin_lock( & Protection of the PI data structures: )
715  If waiter == rt_mutex_top_waiter(lock) Then
722  rt_mutex_dequeue_pi(task, prerequeue_top_waiter)
723  rt_mutex_enqueue_pi(task, waiter)
724  rt_mutex_adjust_prio(task)
726  Else if prerequeue_top_waiter == waiter Then
737  rt_mutex_dequeue_pi(task, waiter)
738  waiter = rt_mutex_top_waiter(lock)
739  rt_mutex_enqueue_pi(task, waiter)
740  rt_mutex_adjust_prio(task)
741  Else next_lock = task_blocked_on_lock(task)
763  top_waiter = rt_mutex_top_waiter(lock)
766  raw_spin_unlock( & Protection of the PI data structures: )
767  raw_spin_unlock_irq( & wait_lock)
776  If Not next_lock Then Go to out_put_task
784  If Not detect_deadlock && waiter != top_waiter Then Go to out_put_task
787  Go to again
789  out_unlock_pi :
790  raw_spin_unlock_irq( & Protection of the PI data structures: )
791  out_put_task :
792  put_task_struct(task)
794  Return ret
Caller
NameDescribe
task_blocks_on_rt_mutexTask blocks on lock.* Prepare waiter and propagate pi chain* This must be called with lock->wait_lock held and interrupts disabled
remove_waiterRemove a waiter from a lock and give up* Must be called with lock->wait_lock held and interrupts disabled. I must* have just failed to try_to_take_rt_mutex().
rt_mutex_adjust_piRecheck the pi chain, in case we got a priority setting* Called from sched_setscheduler