How does the linux kernel start the idle processor when creating a new task?

I am new to the Linux kernel. Currently, I looked at idle codes and asked. When the processor has no such in its own runqueue, then it can go into the standby mode defined by WFI (wating for interruption). (All I mentioned is the ARM architecture, not the X86. So something is wrong for the X86.) After being in the WFI state, perhaps another processor (not idle) wants to spread their task - the processor idle (by load balance). At that time, a busy processor makes the task infected. In my opinion, when a task is simulated, an idle processor should wake up immidiatley to process the task. correctly? However, I could not find any codes waking up by the idle processor, but only the codes found about registering the task in the idle mode of the processor.

I would like to know what mechanism is behind a waking processor when a new task is set. Or just move the task from one queue to another, let it be until some unpredictable IRQ wakes up?

Please show me the truth :)

+5
source share
4 answers

WFI- A special coprocessor team for ARM. For instance,

 ENTRY(cpu_arm946_do_idle)
         mcr     p15, 0, r0, c7, c0, 4           @ Wait for interrupt
         mov     pc, lr

This has nothing to do with Linux (directly).

idle, WFI ARM, . idle - Linux, , . WFI idle, (, ), . SMP idle, , ; . , wake ; ARM . arch/arch/kernel/process.c. , x86 default_idle(). x86, .

linux- ?, - . fork() ( ) ; init, . cron, , sleep/idle. , cron, cron fork(), .

cpufreq, cpuidle, kernel/power ..

/ , , . metric , .

+6

CPU, , .

 = > thread task_struct->flags |= PF_WAKE_UP_IDLE;
0

look at select_task_rq_fair (), which is the CFS :: select_task_rq () method. This is the most typical case where the scheduler awakens an unoccupied task to rebalance the execution queues.

0
source

smp_send_reschedule()will send IPI_RESCHEDULEto an unoccupied processor. This will wake him from wfi. It is called from several places, one of which is wake_up_process -> try_to_wake_up -> try_to_wake_up -> ttwu_queue -> ttwu_queue_remote(function names from the 3.4 kernel).

0
source

All Articles