Skip to content

Latest commit

Β 

History

History
92 lines (87 loc) Β· 2.54 KB

sched_lb.md

File metadata and controls

92 lines (87 loc) Β· 2.54 KB
start_kernel()
  -> rest_init()
       -> kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);

kernel_init()
  -> kernel_init_freeable()
     -> smp_init()
        -> idle_threads_init()
     -> sched_init_smp()
        -> sched_init_numa()
        -> init_sched_domains(cpu_active_mask)
           -> alloc_sched_domains(ndoms_cur = 1)
           -> build_sched_domains(doms_cur[0], NULL)
              -> __visit_domain_allocation_hell()
                 -> __sdt_alloc(cpu_map)
           -> register_sched_domain_sysctl()
  -> run_init_process()
  • kernel/sched/core.c
struct sd_data {
        struct sched_domain **__percpu sd;
        struct sched_domain_shared **__percpu sds;
        struct sched_group **__percpu sg;
        struct sched_group_capacity **__percpu sgc;
};

struct sched_domain_topology_level {
        sched_domain_init_f init;
        sched_domain_mask_f mask;
        int                 flags;
        int                 numa_level;
        struct sd_data      data;
};
...
/*
 * Topology list, bottom-up.
 */
static struct sched_domain_topology_level default_topology[] = {
#ifdef CONFIG_SCHED_SMT
        { sd_init_SIBLING, cpu_smt_mask, },
#endif
#ifdef CONFIG_SCHED_MC
        { sd_init_MC, cpu_coregroup_mask, },
#endif
#ifdef CONFIG_SCHED_BOOK
        { sd_init_BOOK, cpu_book_mask, },
#endif
        { sd_init_CPU, cpu_cpu_mask, },
        { NULL, },
};

static struct sched_domain_topology_level *sched_domain_topology = default_topology;

#define for_each_sd_topology(tl)                        \
        for (tl = sched_domain_topology; tl->mask; tl++)
...**```
  • 每δΈͺηΊ§εˆ«ηš„θ°ƒεΊ¦εŸŸε’Œθ°ƒεΊ¦η»„δΌšεœ¨__sdt_alloc()用kzalloc_node()εˆ†ι…ε‡Ίζ₯
  • register_sched_domain_sysctl() 建立如下 sysctl 控刢鑹
proc/sys/kernel/sched_domain/
β”œβ”€β”€ cpu0
β”‚Β Β  β”œβ”€β”€ domain0
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ busy_factor
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ busy_idx
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cache_nice_tries
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ flags
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ forkexec_idx
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ idle_idx
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ imbalance_pct
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ max_interval
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ min_interval
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ name
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ newidle_idx
β”‚Β Β  β”‚Β Β  └── wake_idx
β”‚Β Β  └── domain1
β”œβ”€β”€ cpu1
β”‚Β Β  β”œβ”€β”€ domain0
β”‚Β Β  └── domain1
β”œβ”€β”€ cpu2
β”‚Β Β  β”œβ”€β”€ domain0
β”‚Β Β  └── domain1
β”œβ”€β”€ cpu3
β”‚Β Β  β”œβ”€β”€ domain0
β”‚Β Β  └── domain1
└── cpu4
 Β Β  β”œβ”€β”€ domain0
 Β Β  └── domain1