2.8.5 触发时机
2.8.5.1. 周期性负载均衡
/* file: kernel/sched/core.c */
void scheduler_tick(void)
{
int cpu = smp_processor_id();
struct rq *rq = cpu_rq(cpu);
/* 删除其他代码 */
#ifdef CONFIG_SMP
rq->idle_balance = idle_cpu(cpu);
trigger_load_balance(rq);
#endif
}/* file: kernel/sched/fair.c */
void trigger_load_balance(struct rq *rq)
{
/*
* Don't need to rebalance while attached to NULL domain or
* runqueue CPU is not active
*/
if (unlikely(on_null_domain(rq) || !cpu_active(cpu_of(rq))))
return;
/* 检查负载均衡的时间,如果当前时间已经过了可以进行下次负载均衡的时间点,那么就产生 SCHED_SOFTIRQ 软中断,
* 该中软信号的处理函数在函数 init_sched_fair_class 中注册,为 run_rebalance_domains */
if (time_after_eq(jiffies, rq->next_balance))
raise_softirq(SCHED_SOFTIRQ);
/* 触发 nohz 负载均衡 */
nohz_balancer_kick(rq);
}2.8.5.2. NOHZ负载均衡
5.3. newidle balance
Last updated