【WALT】update_history() 代码详解

WALT算法update_history函数详解:历史窗口更新与负载预测
文章详细解析了Linux4.9内核中WALT算法的update_history函数,涉及任务历史数据处理、demand和pred_demand计算,以及如何将这些值应用于CPU负载管理和任务信息更新。

【WALT】update_history() 代码详解

代码版本:Linux4.9 android-msm-crosshatch-4.9-android12

代码展示

static void update_history(struct rq *rq, struct task_struct *p,
			 u32 runtime, int samples, int event)
{
   
   
	u32 *hist = &p->ravg.sum_history[0];
	int ridx, widx;
	u32 max = 0, avg, demand, pred_demand;
	u64 sum = 0;
	u64 prev_demand;

	// ⑴ 判断是否更新任务信息
	if (!runtime || is_idle_task(p) || exiting_task(p) || !samples)
		goto done;
	
	// ⑵ 更新历史窗口数据
	prev_demand = p->ravg.demand;
	
	widx = sched_ravg_hist_size - 1;
	ridx = widx - samples;
	for (; ridx >= 0; --widx, --ridx) {
   
   
		hist[widx] = hist[ridx];
		sum += hist[widx];
		if (hist[widx] > max)
			max = hist[widx];
	}
	for (widx = 0; widx < samples && widx < sched_ravg_hist_size; widx++) {
   
   
		hist[widx] 
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值