Trace Analysis The boot process of the Linux kernel uses GDB to trace the debug kernel
Starting from Start_kernel to Init process
Set_task_stack_end_magic ()
To detect Stack Overflow
SMP_SETUP_PROCESSOR_ID ()
Setting up a symmetric multi-processor
Cgroup_init_early ()
Initialize Control Groups
*control Groups provide a mechanism for aggregating/partitioning sets of
Tasks, and all their The future children, to hierarchical groups with
Specialized behaviour.*
Page_address_init ()
Page address initialization (part of memory management)
Setup_arch ()
Setup_arch-architecture-specific boot-time initializations
Build_all_zonelists ()
Called with Zonelists_mutex held always unless system_state = = system_booting.
Page_alloc_init ()
Setup_log_buf ()
Initialize the log buffer (KERNEL/PRINTK/PRINTK.C)
Pidhash_init ()
Initializing a PID hash table
The PID hash table is scaled according to the amount of memory in the machine. From a minimum of slots up to 4096 slots at one gigabyte or more.
Vfs_caches_init_early ()
Sort_main_extable ()
Sort the kernel ' s built-in exception table
Trap_init ()
Initializing interrupt vectors
Mm_init ()
Memory Management Initialization
Sched_init ()
Scheduling Service Initialization
......
Rest_init ()
Remaining initialization
- Kernel_init:init process
- Kthreadd: Kernel thread
- Cpu_idle process: The code keeps looping, and if there are no executable processes in the system, the idle process is executed
Summarize
- When Start_kernel executes to the last part, a new kernel_init process is created in Rest_init, the
kernel_thread(kernel_init, NULL, CLONE_FS);
init process is the number 1th process in the system, the ancestor of all subsequent user-state processes, and the new Kthreadd process, pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
Kthreadd as the number 2nd process, is the ancestor of all kernel threads, in cpu_startup_entry(CPUHP_ONLINE)
, is a while(1)
loop that always has an idle process executing, and if the system does not always have any processes that can be executed, the idle process executes.
Last quote from the Monensin teacher's passage:
Daosh One: (Start_kernel)
Life Two: (Kernel_init and Kthreadd)
Two students three: (that is, the 0,1,2 process)
Sansheng: (Process 1th is all user-state process ancestor, process 2nd is all kernel thread ancestor)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Trace analysis of the boot process of the Linux kernel