全部博文(32)
分类: LINUX
2011-07-21 18:25:49
wangjianchangdx2011-08-04 23:53:03
上面搜索到的是mpparse.c 中的smp_read_mpc函数,该函数遍历mptable中的每一行,其中与CPU数目相关的在MP_PROCESSOR switch case,接下来MP_processor_info->generic_processor_info,在后一个函数中,有这样一段注释:
/*
* x86_bios_cpu_apicid is required to have processors listed
* in same order as logical cpu numbers. Hence the first
* entry is BSP, and so on.
*/
可以推测这个表里面是区分了phys cpu和logical cpu的。
OK,这个暂时告一段落吧,其实这里还缺少从smp_read_mpc向上的回溯(也可以回溯到setup_arch),还是记录一下回溯的方法吧:
① jump to caller: check_physpt
wangjianchangdx2011-08-04 23:10:56
呵呵,之前跟start_kernel的时候,跟到setup_arch的时候,只注意到最开始的early_cpu_init(),却没有注意到之后的prefill_possible_map();
这次从系统上电的流程大致的跟,想着如果要对cpu_possible_bits赋值的话,一定要到jump to protected mode之后了,跟到arch/x86/kernel/head_32.S时,搜索了一下possible_cpu,搜到了smpboot.c中的
static int __init _setup_possible_cpus(char *str)
{
get_option(&str, &setup_possible_cpus);
return 0;
}
early_param("possible_cpus", _setu
wangjianchangdx2011-08-04 22:01:54
setup_per_cpu_areas()在start_kernel函数很早的地方,这就说明cpu_possible_map在之前就已经被set好了,要么在start_kernel中,要么在之前的汇编代码中;
cpu_possible_map虽然有可能包括MC/SMT对应的logical CPU,但是它的设置却很可能与CONFIG_MC/SMT无关,而与SMP有点关系,也有可能根据NR_CPUS直接全部设置为possible,再跟一跟看看是如何discovery的
wangjianchangdx2011-08-04 21:50:11
Documentation/cpu-hotplug.txt:
cpu_possible_map: Bitmap of possible CPUs that can ever be available in the
system. This is used to allocate some boot time memory for per_cpu variables
that aren't designed to grow/shrink as CPUs are made available or removed.
_Once set during boot time discovery phase_, the map is static, i.e no bits
are added or removed anytime. Trimming it accurately for your system needs
upfront can save some boot time memor
wangjianchangdx2011-08-04 16:04:46
arch/x86/kernel/smpboot.c:
cpu_possible_mask should be static, it cannot change as cpu's
* are onlined, or offlined. The reason is per-cpu data-structures
* are allocated by some modules at init time, and dont expect to
* do this dynamically on cpu arrival/departure.