CFS抢占式调度可能出现无限循环调度问题 #53
Replies: 4 comments
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
关于CFS - task_tick检查机制的改进修改scheduler中的cfs调度的task_tick这个检查机制。 fn task_tick(&mut self, current: &Self::SchedItem) -> bool {
current.task_tick();
+ if self.ready_queue.is_empty() {
+ return false;
+ }
self.min_vruntime.is_none()
|| current.get_vruntime() > self.min_vruntime.as_mut().unwrap().load(Ordering::Acquire)
}这种无效调度的情况在目前的测试用例中经常出现,即就绪队列为空,而其它任务都在waitq中,只有一个当前任务经常处于运行状态。 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
问题现象
OSCamp下的u_7_0、u_6_0、u_6_1的日志级别从Info改为Trace之后,有一定概率出现下面的输出后无限循环。在WSL+Qemu环境下出现的概率较高,物理机+Qemu环境下概率低。

日志分析
当前ArceOS在启用CFS抢占式调度后,时钟中断的响应流程。如下

通过增加trace日志,看出第3阶段(蓝线)占时钟触发间隔(红线)的大部分时间,留给任务执行的时间为0,
导致所有的时间都消耗在任务切换上,而任务没有执行机会。
可能的解决方法
共三种,但是倾向第3种。

从当前现象看,CFS调度不应该给出允许调度的pending, 因为当前任务就没有获得运行时间。
后面的设想
参考Linux CFS的机制,在解决问题的情况下,尽可能少改动。
后面需要考虑:
1)多个任务的情况
2)SMP的情况
Beta Was this translation helpful? Give feedback.
All reactions