Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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;
}
Copyright © 2026 Guangzhou eSmart Information Technology Co., Ltd. All Rights Reserved.
All content in this book is copyrighted by the author. For personal learning and exchange only. Commercial use without authorization is strictly prohibited. Email:

✉ 3348194517@qq.com | hai616878@gmail.com