kernel对支持smt的cpu的启动

有一个疑问,支持smt的cpu,bios 传递给os的cpu的个数是开了smt后的还是没有开smt的呢?
这里举个例子,例如支持smt2的cpu,其实还有支持smt4,smt8的cpu,例如ibm的power系列
假如支持smt2,没有开smt的时候是16核,开了smt就是32核,那在开了smt后,bios就要告诉kernel 当前
的cpu 核数是32,这点可以从下面的函数中发现端倪.
static int cpu_up(unsigned int cpu, enum cpuhp_state target)
{
	int err = 0;

	if (!cpu_possible(cpu)) {
		pr_err("can't online cpu %d because it is not configured as may-hotadd at boot time\n",
		       cpu);
#if defined(CONFIG_IA64)
		pr_err("please check additional_cpus= boot parameter\n");
#endif
		return -EINVAL;
	}

	err = try_online_node(cpu_to_node(cpu));
	if (err)
		return err;

	cpu_maps_update_begin();

	if (cpu_hotplug_disabled) {
		err = -EBUSY;
		goto out;
	}
#从这里可以看到smt2也是被当成一个独立cpu的,其次即使bios开了smt,os也可以通过命令行参数禁止掉smt
	if (!cpu_smt_allowed(cpu)) {
		err = -EPERM;
		goto out;
	}

	err = _cpu_up(cpu, 0, target);
out:
	cpu_maps_update_done();
	return err;
}

猜你喜欢

转载自blog.csdn.net/tiantao2012/article/details/113843875