【内核调度、负载计算】【WALT】【update_cpu_busy_time】

这篇博客详细介绍了Linux内核调度中如何计算任务的繁忙时间,特别是通过WALT(Windowed Average Load Tracking)机制。内容涉及初始化变量、根据不同任务类型判断是否计算繁忙时间,以及在不同场景下如何更新busy time,包括任务在当前窗口内外的情况,特别是当任务在运行队列(rq)中执行时的中断处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 根据不同Task类型做不同busytime时间的计算;
  2. 核心计算方式均相同,只是具体数值差异;
  3. 更新数据为
    Task中prev_window、curr_window
    rq中prev_runable_sum、curr_runnable_sum

 

在这里插入图片描述

1、获取初始化变量

	new_window = mark_start < window_start;
	if (new_window) {//包含多个窗口
		nr_full_windows = div64_u64((window_start - mark_start),
						window_size);
		if (p->ravg.active_windows < USHRT_MAX)
			p->ravg.active_windows++;
	}

	/* Handle per-task window rollover. We don't care about the idle
	 * task or exiting tasks. */
	if (new_window && !is_idle_task(p) && !exiting_task(p)) {
		u32 curr_window = 0;

		if (!nr_full_windows)
			curr_window = p->ravg.curr_window;

		p->ravg.prev_window = curr_window;
		p->ravg.curr_window = 0;
	}

2、根据task的类别判断是否需要计算busy time

2.1不需要更新busy time

	if (!account_busy_for_cpu_time(rq, p, irqtime, event)) {
		/* account_busy_for_cpu_time() = 0, so no update to the
		 * task's current window needs to be made. This could be
		 * for example
		 *
		 *   - a wakeup event on a task within the current
		 *     window (!new_window below, no action required),
		 *   - switching to a new task from idle (PICK_NEXT_TASK)
		 *     in a new window where irqtime is 0 and we aren't
		 *     waiting on IO */

		if (!new_window)
			return;

		/* A new window has started. The RQ demand must be rolled
		 * over i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值