码迷,mamicode.com
首页 > 其他好文 > 详细

cgroup

时间:2018-01-25 00:25:49      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:文件   target   ems   源码   art   html   its   不同   pop   

参考:Linux资源管理之cgroups简介

      linux源码分析(四)-start_kernel-cgroup

   从cgroup_init_early函数学习cgroup——框架

          cgroup中的cgroup_subsys[]数组解析

 

/*
* 系统中共有多少个cgroup_subsys_state结构体?include/linux/cgroup.h
* 
*/
/* Define the enumeration of all cgroup subsystems */
#define SUBSYS(_x) _x ## _subsys_id,
/*
cgroup_subsys.h内容如下

SUBSYS(cpuset)         cpuset_subsys_id
SUBSYS(debug)          debug_subsys_id
SUBSYS(ns)             ns_subsys_id
SUBSYS(cpu_cgroup)     cpu_cgroup_subsys_id
SUBSYS(cpuacct)        cpuacct_subsys_id
SUBSYS(mem_cgroup)     mem_cgroup_subsys_id
SUBSYS(devices)           devices_subsys_id
SUBSYS(freezer)        freezer_subsys_id
SUBSYS(net_cls)        net_cls_subsys_id
*/
enum cgroup_subsys_id {
#include <linux/cgroup_subsys.h>
    CGROUP_SUBSYS_COUNT
};
#undef SUBSYS

/*以上枚举量展开为*/
enum cgroup_subsys_id {
    cpuset_subsys_id
    debug_subsys_id
    ns_subsys_id
    cpu_cgroup_subsys_id
    cpuacct_subsys_id
    mem_cgroup_subsys_id
    devices_subsys_id
    freezer_subsys_id
    net_cls_subsys_id
    CGROUP_SUBSYS_COUNT
};

/*系统中定义的全局cgroup_subsys数组*/
/* Generate an array of cgroup subsystem pointers */
#define SUBSYS(_x) &_x ## _subsys,

static struct cgroup_subsys *subsys[] = {
#include <linux/cgroup_subsys.h>
};
/*以上数组展开为*/
static struct cgroup_subsys *subsys[] = {
    cpuset_subsys,
    debug_subsys,
    ns_subsys,
    cpu_cgroup_subsys,
    cpuacct_subsys,
    mem_cgroup_subsys,
    devices_subsys,
    freezer_subsys,
    net_cls_subsys,
};
/*以上数组中的成员在不同的C文件中定义,例如kernel/cpuset.c*/
struct cgroup_subsys cpuset_subsys = {
    .name = "cpuset",
    .create = cpuset_create,
    .destroy = cpuset_destroy,
    .can_attach = cpuset_can_attach,
    .attach = cpuset_attach,
    .populate = cpuset_populate,
    .post_clone = cpuset_post_clone,
    .subsys_id = cpuset_subsys_id,
    .early_init = 1,
};

static int cpuset_mems_generation;

static struct cpuset top_cpuset = {
    .flags = ((1 << CS_CPU_EXCLUSIVE) | (1 << CS_MEM_EXCLUSIVE)),
};
struct cpuset {
    struct cgroup_subsys_state css;

    unsigned long flags;        /* "unsigned long" so bitops work */
    cpumask_var_t cpus_allowed;    /* CPUs allowed to tasks in cpuset */
    nodemask_t mems_allowed;    /* Memory Nodes allowed to tasks */

    struct cpuset *parent;        /* my parent */

    /*
     * Copy of global cpuset_mems_generation as of the most
     * recent time this cpuset changed its mems_allowed.
     */
    int mems_generation;

    struct fmeter fmeter;        /* memory_pressure filter */

    /* partition number for rebuild_sched_domains() */
    int pn;

    /* for custom sched domain */
    int relax_domain_level;

    /* used for walking a cpuset heirarchy */
    struct list_head stack_list;
};

 

cgroup

标签:文件   target   ems   源码   art   html   its   不同   pop   

原文地址:https://www.cnblogs.com/yangjiguang/p/8343770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!