了解在rt_rq(实时runqueue)内核中使用数据成员

以下是v3.5.4中的实时运行队列结构

struct rt_rq { struct rt_prio_array active; unsigned int rt_nr_running; #if defined CONFIG_SMP || defined CONFIG_RT_GROUP_SCHED struct { int curr; /* highest queued rt task prio */ #ifdef CONFIG_SMP int next; /* next highest */ #endif } highest_prio; #endif #ifdef CONFIG_SMP unsigned long rt_nr_migratory; unsigned long rt_nr_total; int overloaded; struct plist_head pushable_tasks; #endif int rt_throttled; u64 rt_time; u64 rt_runtime; /* Nests inside the rq lock: */ raw_spinlock_t rt_runtime_lock; #ifdef CONFIG_RT_GROUP_SCHED unsigned long rt_nr_boosted; struct rq *rq; struct list_head leaf_rt_rq_list; struct task_group *tg; #endif }; 

我已经理解了一些数据成员代表什么,但是我不完全确定下面的数据成员:

a) rt_nr_migratory :(我认为)这是一个计数器,以保持有多less任务可以推送到其他CPU

b) pushable_tasks是可以被推送到其他运行队列的任务列表,如果他们没有任何运行的话。

请纠正我,如果我错了上述条目。

c) rt_throttledrt_timert_runtimert_nr_totalrt_nr_boosted :我不明白这是什么用法。

另外为什么是struct rq *rq; 只有在组排定时才需要。 我的意思是什么意思。

这是一个难以回答的问题,部分是因为这个问题真的是一次又一个复杂的问题。 所以为了帮助你理解这些部分,我已经查阅了每个字段的添加。 阅读提交消息,并可能引入每个领域的补丁应该让你更接近理解为什么他们在那里。

rt_nr_migratory在提交rt_nr_migratory中添加:添加RT-balance cpu-weight 。

pushable_tasks被添加到提交调度中:创建“pushable_tasks”列表来限制推送到一个尝试 。

rt_throttledrt_time被添加到提交rt_time :rt时间限制 。

rt_runtime是在提交rt_runtime中添加的:rt-group:smp balancing 。

rt_nr_total在提交rt_nr_total中添加:修复了rt组调度的过载错误 。

rt_nr_boosted被添加到提交rt_nr_boosted中:rt-group:处理PI 。 (我相信这里的“PI”意思是“优先倒置”)。

在调度中添加了rq :rt组调度 。


我用git blame来了解每一行何时被引入,但是在这种情况下它非常复杂,因为调度程序的源代码在完成所有这些工作之后经历了两次重大的重组。 所以当我用git blame sched.h ,它告诉我整个结构都是一次添加的,但是它提交的commit实际上是当结构移出sched.c 。 然后我用git blame <commit>~ -- sched.c来看看sched.c看起来像是在改变之前。 最后,对于我认为可能很重要的每个提交,我使用git show <commit>进行了双重检查。