调度器38—cpumask

//include/linux/cpumask.h
#define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
#define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask)
#define cpu_present_mask ((const struct cpumask *)&__cpu_present_mask)
#define cpu_active_mask ((const struct cpumask *)&__cpu_active_mask)

MTk 5.10 BSP中:
/sys/devices/system/cpu/sched_ctl/sched_core_pause_info 打印 cpu_active_mask 的值,offline和isolate都会从中删除cpu对应的bit
/sys/devices/system/cpu/online 打印 cpu_online_mask 的值,只打印online的cpu,是否被isolate不影响

 

补充:

1. cpumask、cpumask_t 和 cpumask_var_t:https://www.cnblogs.com/hellokitty2/p/16919268.html

2. bitmap.c中提供了解析cpumask的函数

static int __init rcu_nocb_setup(char *str)
{
    cpulist_parse(str, rcu_nocb_mask); //从用户字符串中提取cpumask
}
__setup("rcu_nocbs=", rcu_nocb_setup); //rcu_nocbs=0-7

3. cpu_active_mask 的赋值路径

static inline void set_cpu_active(unsigned int cpu, bool active) //include/linux/cpumask.h
{
    if (active)
        cpumask_set_cpu(cpu, &__cpu_active_mask);
    else
        cpumask_clear_cpu(cpu, &__cpu_active_mask);
}

调用路径:

        cpuhp_hp_states[CPUHP_AP_ACTIVE].startup.single //kernel/cpu.c cpu hotplug回调
resume_cpus(struct cpumask *cpus) //kernel/cpu.c GPL导出的接口,目前只在core_ctl模块中使用
    sched_cpus_activate(struct cpumask *cpus) //sched/core.c
        for_each_cpu(cpu, cpus)
            sched_cpu_activate(cpu) //sched/core.c
                set_cpu_active(cpu, true);

    pause_cpus //kernel/cpu.c GPL导出的接口,目前只在core_ctl模块中使用
        sched_cpus_deactivate_nosync //sched/core.c
    cpuhp_hp_states[CPUHP_AP_ACTIVE].teardown.single //kernel/cpu.c cpu hotplug回调
        sched_cpu_deactivate //sched/core.c
            _sched_cpu_deactivate //sched/core.c
                set_cpu_active(cpu, false);

            pause_cpus(struct cpumask *cpus) //kernel/cpu.c 如上
                for_each_cpu(cpu, cpus)
                    set_cpu_active(cpu, false);

            resume_cpus(struct cpumask *cpus) //kernel/cpu.c 如上
                for_each_cpu(cpu, cpus)
                    set_cpu_active(cpu, true);

 

posted on 2022-08-31 15:51  Hello-World3  阅读(560)  评论(0编辑  收藏  举报

导航