zoukankan      html  css  js  c++  java
  • cgroup

    参考: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;
    };
  • 相关阅读:
    配置iis 8.0 遇到的问题
    easy ui datagrid 下拉框级联绑定
    Flutter
    Flutter
    mingw
    Flutter 配置windows桌面开发环境
    Flutter -- 输入法键盘盖住控件出现A RenderFlex overflowed by 27 pixels on the bottom
    PowerBuilder -- 连接sqlite
    idea
    PowerBuilder -- 事件与函数的触发
  • 原文地址:https://www.cnblogs.com/yangjiguang/p/8343770.html
Copyright © 2011-2022 走看看