This is a function in Linux kernel, (it's called inside start_kernel()
)
void __init parse_early_param(void)
{
static int done __initdata;
static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
if (done)
return;
/* All fall through to do_early_param. */
strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
parse_early_options(tmp_cmdline);
done = 1;
}
As we know static variable done is stored in the data segment so if the function finishes, the data is still there. In the above function, the variable data
is static and if it's nonzero, the function returns immediately. but if not, it performs the parsing of command line and sets done to 1. Does this mean that this parse_early_param()
is processed by multiple core? I don't think so because at this stage, only the first core is running. As I understand, other cores are woken up very late in the start_kernel()
(see for_each_possible_cpu macro in vmalloc_init() function, does the code run in only one cpu? or in every cpu?). So what is the logic in this function?