CFS中vruntime的概念是什么 [英] What is the concept of vruntime in CFS

查看:280
本文介绍了CFS中vruntime的概念是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关内核中的Linux内核和CFS调度程序的信息.我遇到了 vruntime (虚拟运行时),它是CFS调度程序背后的核心概念.我从" Linux内核开发"以及互联网上的其他博客中读到,但无法理解 vruntime 的基本计算方法. vruntime 是属于特定进程还是属于具有相同 nice值的一组进程.什么是加权因子,如何计算?我经历了所有这些概念,但听不懂. vruntime 和* min_vruntime *有什么区别?

I have been reading about Linux Kernel and CFS scheduler in the kernel. I came across vruntime (virtual runtime) that is the core concept behind CFS scheduler. I read from "Linux Kernel Development" and also from other blogs on internet but could not understand the basic calculations behind the vruntime. Does vruntime belong to a particular process or does it belong to a group of process with same nice values. What is the weighting factor and how is it calculated? I went through all these concepts but could not understand. Also what is the difference between vruntime and *min_vruntime*?

推荐答案

vruntime是每个线程的;它是嵌套在task_struct中的成员.

vruntime is per-thread; it is a member nested within the task_struct.

本质上,vruntime是线程运行时"的量度-线程在处理器上花费的时间.粮安委的重点是对所有人公平.因此,这种算法归结为一个简单的事情:(在给定运行队列中的任务中)具有最低vruntime的任务是最值得运行的任务,因此将其选择为"next". (为了提高效率,实际的实现是使用rbtree完成的.)

Essentially, vruntime is a measure of the "runtime" of the thread - the amount of time it has spent on the processor. The whole point of CFS is to be fair to all; hence, the algo kind of boils down to a simple thing: (among the tasks on a given runqueue) the task with the lowest vruntime is the task that most deserves to run, hence select it as 'next'. (The actual implementation is done using an rbtree for efficiency).

考虑到各种因素,例如优先级,精确值,cgroups等,vruntime的计算不像简单的增量那样简单.我建议阅读专业Linux内核体系结构"中的相关部分,Mauerer,Wrox出版社-对其进行了详细说明.

Taking into account various factors - like priority, nice value, cgroups, etc - the calculation of vruntime is not as straight-forward as a simple increment. I'd suggest reading the relevant section in "Professional Linux Kernel Architecture", Mauerer, Wrox Press - it's explained in great detail.

请在下面快速总结一下其中的一些内容.

Pl see below a quick attempt at summarizing some of this.

其他资源: Documentation/scheduler/sched-design-CFS.txt

快速摘要-vruntime计算: (基于本书)

  • 大部分工作都在kernel/sched_fair.c:__ update_curr()

  • Most of the work is done in kernel/sched_fair.c:__update_curr()

调用计时器滴答声

更新当前"在处理器上花费的物理和虚拟时间

Updates the physical and virtual time 'current' has just spent on the processor

对于以默认优先级(即好值0)运行的任务,花费的物理和虚拟时间是相同的

For tasks that run at default priority, i.e., nice value 0, the physical and virtual time spent is identical

对于其他优先级(不错)的任务则不是这样;因此,使用负载权重因子会影响电流优先级,从而影响vruntime的计算

Not so for tasks at other priority (nice) levels; thus the calculation of vruntime is affected by the priority of current using a load weight factor

delta_exec =(无符号长)(现在– curr-> exec_start); //... delta_exec_weighted = calc_delta_fair(delta_exec,curr); curr-> vruntime + = delta_exec_weighted;

delta_exec = (unsigned long)(now – curr->exec_start); // ... delta_exec_weighted = calc_delta_fair(delta_exec, curr); curr->vruntime += delta_exec_weighted;

忽略一些舍入和溢出检查,calc_delta_fair的作用是 计算以下公式给出的值:

Neglecting some rounding and overflow checking, what calc_delta_fair does is to compute the value given by the following formula:

delta_exec_weighed = delta_exec * (NICE_0_LOAD / curr->load.weight)

问题是,更重要的任务(具有较低的漂亮值的任务)将具有更大的任务 重量;因此,通过以上等式,占它们的vruntime会更小 (因此,让他们在rbtree上排到更多的位置!).

The thing is, more important tasks (those with a lower nice value) will have larger weights; thus, by the above equations, the vruntime accounted to them will be smaller (thus having them enqueued more to the left on the rbtree!).

这篇关于CFS中vruntime的概念是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆