10.1 Configuring the Number of CPU Cores
For multi-core systems, the number of CPU cores is tightly coupled with subsequent parameter configurations; therefore, it is imperative to determine the exact number of CPUs encompassed within the hardware architecture. Establishing the core count is relatively straightforward and is accomplished by identifying the bit position of the last set bit (value of 1) within the cpu_possible_mask variable, which was previously determined during the hardware configuration phase. The function that determines the CPU count is defined within the file git/kernel/smp.c, and its definition is as follows:
void __init setup_nr_cpu_ids(void)
{
nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask), NR_CPUS) + 1;
}