【内核调度、负载均衡】【scheduler_tick】

本文探讨了Linux内核中的scheduler_tick函数,它在系统软中断触发下周期执行,负责更新WALT负载统计、系统时钟、PELT CPU负载、系统级负载统计,并触发负载均衡过程。rebalance_domains函数用于处理负载均衡,由run_rebalance_domains软中断处理函数执行。配置中已定义CONFIG_NO_HZ_COMMON宏。
摘要由CSDN通过智能技术生成

scheduler_tick

系统的软中断触发会周期性的调度scheduler_tick函数,每个cpu都有一个时钟中断,都会被周期性的调度到scheduler_tick函数

/*
 * This function gets called by the timer code, with HZ frequency.
 * We call it with interrupts disabled.
 */
void scheduler_tick(void)
{
	int cpu = smp_processor_id();
	struct rq *rq = cpu_rq(cpu);
	struct task_struct *curr = rq->curr;
	struct rq_flags rf;

	sched_clock_tick();

	rq_lock(rq, &rf);

	walt_set_window_start(rq, &rf);
	walt_update_task_ravg(rq->curr, rq, TASK_UPDATE,
			walt_ktime_clock(), 0);
	update_rq_clock(rq);
	curr->sched_class->task_tick(rq, curr, 0);
	cpu_load_update_active(rq);
	calc_global_load_tick(rq);
	psi_task_tick(rq);

	rq_unlock(rq, &rf);

	perf_event_task_tick();

#ifdef CONFIG_SMP
	rq->idle_balance = idle_cpu(cpu);
	trigger_load_balance(rq);
#endif
	rq_last_tick_reset(rq);

	if (curr->sched_class == &fair_sched_class)
		check_for_migration(rq, curr);
}

scheduler_tick主要完成的任务如下:

1、更新WALT统计的load

https://blog.csdn.net/feifei_csdn/article/details/107459819

2、更新系统时钟

3、更新PELT方式统计的cpu级别的负载统计

4、更新系统级的负载统计

5、触发负载均衡

trigger_load_balance

/*
 * Trigger the SCHED_SOFTIRQ if it is time to do periodic load balancing.
 */
void trigger_load_balance(struct rq *rq)
{
	/* Don't need to rebalance while attached to NULL doma
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值