Linux的内核级task_h_load [英] Linux Kernel- task_h_load

查看:491
本文介绍了Linux的内核级task_h_load的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解 LOAD_BALANCE 函数中会发生什么。结果
我检查版本3.14,但我也看了一下4.3版本,因为我被告知,该机制被改变,有点更清晰的这个版本。

I'm trying to understand what happens during the load_balance function.
I'm checking version 3.14 but I also took a look at version 4.3 since I was told that the mechanism was changed and a bit more clear in this version.

v3.14 呼叫来自<一个href=\"http://lxr.free-electrons.com/source/kernel/sched/fair.c?v=3.14#L4980\"><$c$c>move_tasks

V4.3 呼叫来自 detach_tasks

in v4.3 the call is from detach_tasks

从我看到它是相同的功能,但只是用不同的名称。

from what I see it is the same function but only with a different name.

此功能是根据 env-&GT运动从一个队列的任务​​放到另一个;平衡参数结果
我不明白的是什么/如何加载在 task_h_load

This function is moving tasks from one queue to another according to the env->balance parameter.
What I don't understand is what/how the load is calculated in task_h_load.

有谁知道负荷件再present什么,以及它是如何在 task_h_load 函数计算?

Does anyone know what the load member represent and how it is calculated in the task_h_load function?

推荐答案

CFS 持有一棵树的调度实体。每一个调度实体可以有它自己的树,等等以递归方式...
(这是有用的,例如,为特定用户的所有进程分组为一个调度实体;因此preventing具有从消耗更多的CPU的时间比用较少的工序的用户的许多任务的用户)

CFS holds a tree of "scheduling entities". Each scheduling entity can have its own tree, and so on in a recursive way... (This is useful, for example, for grouping all the processes of a specific user into one scheduling entity; thus preventing a user that has many tasks from consuming more cpu time than users with fewer processes)

task_h_load - 表示任务分层负载

task_h_load - stands for "task hierarchical load"

由于任务可以嵌套在几棵树,然后计算其负载不是那么简单......

Since a task can be nested in a few trees, then calculating its load is not so simple...

static unsigned long task_h_load(struct task_struct *p){
    struct cfs_rq *cfs_rq = task_cfbs_rq(p);
    update_cfs_rq_h_load(cfs_rq);
    return div64_ul(p->se.avg.load_avg * cfs_rq->h_load,
                           cfs_rq_load_avg(cfs_rq) + 1);
}

目前初 cfs_rq 指向在其中p是在发现直接树如果我们只有两个嵌套树木然后计算p的负载将是简单:

At the beginning cfs_rq points to the immediate tree at which p is found in. If we had only two nested trees then calculating the load of p would have been simple:

task_h_load = task_load_in_its_tree *(load_of_immediate_tree /
  load_of_containing_tree);

task_h_load = task_load_in_its_tree * ( load_of_immediate_tree / load_of_containing_tree);

(而immediate_tree是指包含该任务的树中,
  和containing_tree指包含包含该任务的树的树。)

(while immediate_tree refers to the tree that contains the task, and containing_tree refers to the tree that contains the tree that contains the task.)

但是,这并非如此。我们的树可能是调度实体内嵌套的树,这本身就是刚刚在另一棵树上的一页。

But this is not the case. Our tree might be a nested tree inside a scheduling entity, which is itself just a leaf in another tree.

所以,我们要做的第一件事就是打电话给 update_cfs_rq_h_load(cfs_rq)后者计算的层次客座率为 cfs_rq 及其所有祖先(祖先):这个功能,从根本上上升树层次一路根,了我们的 cfs_rq 在每个层次树。

So, the first thing we do is to call update_cfs_rq_h_load(cfs_rq) which computes the hierarchical load factor for cfs_rq and all its ascendants (ancestors): this function goes up the tree hierarchy all the way to the root, and down from the root to our cfs_rq while computing the hierarchical load factor for each tree in the hierarchy.

的计算被以类似的方式完成的:

The computation is done in a similar way:

cfs_rq_h_load = cfs_rq_load_in_its_tree *(load_of_immediate_tree /
  load_of_containing_tree)

cfs_rq_h_load = cfs_rq_load_in_its_tree * (load_of_immediate_tree / load_of_containing_tree)

所以,最后我们有 cfs_rq 的轻载和所有我们要做的是使用相同的公式来计算h_load。

So, finally we have the fractional load of cfs_rq and all we have to do is to calculate the h_load using the same formula.

task_h_load = task_load_in_its_tree *(load_of_immediate_tree /
  load_of_containing_tree)

task_h_load = task_load_in_its_tree * (load_of_immediate_tree / load_of_containing_tree)

这篇关于Linux的内核级task_h_load的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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