文章目录
【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]

文章详细解析了Linux4.9内核中WALT算法的update_history函数,涉及任务历史数据处理、demand和pred_demand计算,以及如何将这些值应用于CPU负载管理和任务信息更新。
最低0.47元/天 解锁文章
748





