cgroups相关的isolators
src/slave/containerizers/mesos/isolators/cgroups
常量定义
constants.hpp
// CPU subsystem constants.
const uint64_t CPU_SHARES_PER_CPU = 1024;
const uint64_t CPU_SHARES_PER_CPU_REVOCABLE = 10;
const uint64_t MIN_CPU_SHARES = 2; // Linux constant.
const Duration CPU_CFS_PERIOD = Milliseconds(100); // Linux default.
const Duration MIN_CPU_CFS_QUOTA = Milliseconds(1);
// Memory subsystem constants.
const Bytes MIN_MEMORY = Megabytes(32);
相关命令行参数
见src/slave/flags.cpp
标志名称 | 缺省值 |
---|---|
cgroups_hierarchy | "/sys/fs/cgroup" |
cgroups_root | "mesos" |
cgroups_enable_cfs | false |
cgroups_limit_swap | false |
cgroups_cpu_enable_pids_and_tids_count | false |
cgroups_net_cls_primary_handle | |
cgroups_net_cls_secondary_handles |
控制CPU资源份额
class CgroupsCpushareIsolatorProcess : public MesosIsolatorProcess
CgroupsCpushareIsolatorProcess::CgroupsCpushareIsolatorProcess
创建CgroupsCpushareIsolatorProcess对象
- 58-64:根据参数初始化本对象的私有变量
CgroupsCpushareIsolatorProcess::create
参数:
- flags:是启动agent时命令行传递的参数
Try<string> hierarchyCpu = cgroups::prepare(
flags.cgroups_hierarchy,
"cpu",
flags.cgroups_root);
flags.cgroups_hierarchy
flags.cgroups_root 是在哪里赋值的?????????
- 72-75:调用cgroups::prepare,这是调用的OS功能???????