日期 | 内核版本 | CPU架构 | 作者 |
2019.04.06 | Linux-4.4 | PowerPC | LoneHugo |
系列文章:https://blog.csdn.net/Vince_/article/details/89070001
初始化过程
- 在start_kernel中cgroup_init之前调用cpuset_init进行初始化;
- 初始化struct cpuset top_cpuset,主要是各个mask参数分配和初始化;
- 初始化fmeter信息;
- 注册文件系统cpuset(struct file_system_type cpuset_fs_type);
- 初始化cpus_attach信息;
cgroup_mount
cpuset文件系统注册之后可以进行mount操作,cpuset_mount处理对应的mount
调用,实际上简单地调用了cgroup的mount操作cgroup_mount:
/*
* This is ugly, but preserves the userspace API for existing cpuset
* users. If someone tries to mount the "cpuset" filesystem, we
* silently switch it to mount "cgroup" instead
*/
static struct dentry *cpuset_mount(struct file_system_type *fs_type,
int flags, const char *unused_dev_name, void *data)
{
struct file_system_type *cgroup_fs = get_fs_type("cgroup");
struct dentry *ret = ERR_PTR(-ENODEV);
if (cgroup_fs) {
char mountopts[] =
"cpuset,noprefix,"
"release_agent=/sbin/cpuset_release_agent";
ret = cgroup_fs->mount(cgroup_fs, flags,
unused_dev_name, mountopts);
put_filesystem(cgroup_fs);
}
return ret;
}
cpuset_init
/**
* cpuset_init - initialize cpusets at system boot
*
* Description: Initialize top_cpuset and the cpuset internal file system,
**/
int __init cpuset_init(void)
{
int err = 0;
if (!alloc_cpumask_var(&top_cpuset.cpus_allowed, GFP_KERNEL))
BUG();
if (!alloc_cpumask_var(&top_cpuset.effective_cpus, GFP_KERNEL))
BUG();
#ifdef CONFIG_DYNAMIC_ISOLATION
if (!alloc_cpumask_var(&top_cpuset.cpus_original, GFP_KERNEL))
BUG();
if (!alloc_cpumask_var(&top_cpuset.cpus_isolated, GFP_KERNEL))
BUG();
#endif
cpumask_setall(top_cpuset.cpus_allowed);
#ifdef CONFIG_DYNAMIC_ISOLATION
cpumask_setall(top_cpuset.cpus_original);
cpumask_clear(top_cpuset.cpus_isolated);
#endif
nodes_setall(top_cpuset.mems_allowed);
cpumask_setall(top_cpuset.effective_cpus);
nodes_setall(top_cpuset.effective_mems);
fmeter_init(&top_cpuset.fmeter);
set_bit(CS_SCHED_LOAD_BALANCE, &top_cpuset.flags);
top_cpuset.relax_domain_level = -1;
err = register_filesystem(&cpuset_fs_type);
if (err < 0)
return err;
if (!alloc_cpumask_var(&cpus_attach, GFP_KERNEL))
BUG();
return 0;
}