Function report

Linux Kernel


Brick Technologies Co., Ltd

Source Code:kernel\sched\core.c Create Date:2022-07-28 09:36:08
Last Modify:2022-05-22 13:40:38 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:__schedule() is the main scheduler function.* The main means of driving the scheduler and thus entering this function are:* 1. Explicit blocking: mutex, semaphore, waitqueue, etc.* 2. TIF_NEED_RESCHED flag is checked on interrupt and userspace return

Proto:static void __sched notrace __schedule(bool preempt)



4014  cpu = smp_processor_id()
4015  rq = cpu_rq(cpu)
4016  prev = curr
4018  Various schedule()-time debugging checks and statistics:
4020  If sched_feat(HRTICK) Then hrtick_clear(rq)
4023  local_irq_disable()
4024  Note a PREEMPT=n context switch. The caller must have disabled interrupts.
4034  rq_lock(rq, & rf)
4035  smp_mb__after_spinlock() provides the equivalent of a full memory barrier* between program-order earlier lock acquisitions and program-order later* memory accesses()
4038  clock_update_flags <<= 1
4039  update_rq_clock(rq)
4041  switch_count = nivcsw
4042  If Not preempt && run state Then
4045  Else
4048  If in_iowait Then
4053  switch_count = Context switch counts:
4056  next = Pick up the highest-prio task:
4057  clear_tsk_need_resched(prev)
4058  clear_preempt_need_resched()
4060  If Value is more likely to compile time(prev != next) Then
4061  nr_switches++
4066  RCU_INIT_POINTER() - initialize an RCU protected pointer*@p: The pointer to be initialized.*@v: The value to initialized the pointer to.* Initialize an RCU-protected pointer in special cases where readers(curr, next)
4081  ++switch_count
4083  Tracepoint for task switches, performed by the scheduler:
4086  rq = ext_switch - switch to the new MM and the new thread's register state.
4087  Else
4088  clock_update_flags &= ~(RQCF_ACT_SKIP | q::clock_update_flags bits* %RQCF_REQ_SKIP - will request skipping of clock update on the next* call to __schedule(). This is an optimisation to avoid* neighbouring rq clock updates.* %RQCF_ACT_SKIP - is set from inside of __schedule() when skipping is)
4089  rq_unlock_irq(rq, & rf)
4092  balance_callback(rq)
schedule_idlesynchronize_rcu_tasks() makes sure that no task is stuck in preempted* state (have scheduled out non-voluntarily) by making sure that all* tasks have either left the run queue or have gone into user space
preempt_schedule_irqThis is the entry point to schedule() from kernel preemption* off of irq context.* Note, that this is called and return with irqs disabled. This will* protect us against recursive calling from irq.