1

I am working on CPU-IDLE in Linux. I have the question who spawns idle tasks per CPU core i.e. if there are 4 arm CPU cores, who spawns the per CPU idle task? Where the code for the same is located for creating idle tasks? I understand that start_kernel in init/main.c is run by init process.

Can someone please point out the location of the code where the idle tasks are created per CPU core for CPU idle?

Regards, Snu

snu
  • 21
  • 1

1 Answers1

1

Using the 5.3 kernel as a reference:

  • start_kernel() in "init/main.c" calls arch_call_rest_init().
  • arch_call_rest_init() in "init/main.c" calls rest_init().
  • rest_init() in "init/main.c" calls kernel_thread() to create the init process with kernel_init as the thread function.
  • kernel_init() in "init/main.c" calls kernel_init_freeable().
  • kernel_init_freeable() in "init/main.c" calls smp_init().
  • smp_init() in "kernel/smp.c" calls idle_threads_init().
  • idle_threads_init() in "kernel/smpboot.c" calls idle_init(cpu) for each CPU apart from the boot CPU.
  • idle_cpu(cpu) in "kernel/smpboot.c" calls fork_idle(cpu).
  • fork_idle(cpu) in "kernel/fork.c" clones the init process thread and calls init_idle(task, cpu).
  • init_idle(task, cpu) in "kernel/sched/core.c" sets up the idle thread for the CPU.
Ian Abbott
  • 15,083
  • 19
  • 33