Brief description of initcall_debug [transfer]

This article is reproduced from: https://blog.csdn.net/zangdongming/article/details/37769265

Linux version 3.10.40

 

1. Instructions for use

The instructions in Documentation/kernel-parameters.txt are as follows:

         initcall_debug  [KNL] Trace initcalls as they are executed.  Useful

                            for working out where the kernel is dying during

                            startup.

Note that initcall_debug is a kernel parameter that can track initcall to locate the problem of kernel initialization. After adding initcall_debug to the cmdline, the following log will be added during the kernel startup process. There is a print before each init function is called, and after the end, there is a print and the running time of the Init function is output. Through this information, you can use To locate which init function failed to run during startup and which init function took longer to run.

calling  init_workqueues+0x0/0x414 @ 1

initcall init_workqueues+0x0/0x414 returned 0 after 0 usecs

In addition to adding logs during the startup process, the following forms of logs are also added during the system sleep and wake-up process, which can be used to locate the problems of sleep-wake-up failure and too long sleep-wake-up time.

calling  xxxxxx.dma+ @ 6, parent: xxx.0

call xxxxxx.dma+ returned 0 after 2 usecs

 

2. Related code

The place where the variable is declared in ./init/main.c is as follows. Through core_param, the status of initcall_debug can be obtained in user space through /sys/module/kernel/parameters/initcall_debug. In addition, cmdline should also depend on this line of code. The implementation of core_param is also very complicated and will be studied later.

bool initcall_debug;

core_param(initcall_debug, initcall_debug, bool, 0644);

The do_one_initcall function determines whether to directly call the startup init function or call do_one_initcall_debug according to initcall_debug. In do_one_initcall_debug, the log and the running time of the calculation function are added when the init function is called.

Set pm_print_times_enabled according to initcall_debug in ./kernel/power/main.c, and print logs according to pm_print_times_enabled in ./drivers/base/power/main.c during system sleep wakeup.

 

Remaining problem:

1. Implementation principle of core_param

2. He judges the initcall_debug variable in several places in the kernel and increases the function of log output

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326369602&siteId=291194637