为什么linux中的CFS调度程序会减少正在运行的进程的运行时间?
我在探索CFS调度程序。根据CFS,vruntime是进程在CPU上运行的时间量。因此,一旦一个进程消耗了一些CPU,它的vruntime就会增加 为了深入理解上下文切换的概念,我研究了kernel/sched/core.c文件的上下文切换方法实现为什么linux中的CFS调度程序会减少正在运行的进程的运行时间?,linux,debugging,linux-kernel,performance-testing,cfs,Linux,Debugging,Linux Kernel,Performance Testing,Cfs,我在探索CFS调度程序。根据CFS,vruntime是进程在CPU上运行的时间量。因此,一旦一个进程消耗了一些CPU,它的vruntime就会增加 为了深入理解上下文切换的概念,我研究了kernel/sched/core.c文件的上下文切换方法实现 context_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next) 为了了解上下文切换所涉及的进程,特别是要知道哪个进程被调度出去
context_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)
为了了解上下文切换所涉及的进程,特别是要知道哪个进程被调度出去,哪个进程被调度进来,我添加了
trace_printk(KERN_INFO "**$$,traceme,%d,%llu,%llu,%d,%llu,%llu\n", (int)(prev->pid),prev->se.vruntime,prev->se.sum_exec_runtime, (int)(next->pid),next->se.vruntime,next->se.sum_exec_runtime);
在kernel/sched/core.c文件的context_switch()函数中
context_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)
清理后的一些示例数据
//(prev->pid),prev->se.vruntime,prev->se.sum_exec_runtime, (int)(next->pid),next->se.vruntime,next->se.sum_exec_runtime
Line-1 : 7560,24498429469681,823155565,7566,24498418258892,1637962
Line-2 : 7566,24498418261234,1640304,7580,24498417733416,1018016
Line-3 : 7580,24498417752807,1037407,686,24498429468802,48339928895
Line-4 : 686,24498429469817,48339929910,7566,24498418261234,1640304
Line-5 : 7566,24498418263610,1642680,7581,24498417762357,1038126
Line-6 : 7581,24498417781339,1057108,7560,24498429469681,823155565
Line-7 : 7560,24498429470724,823156608,7566,24498418263610,1642680
Line-8 : 7566,24498418265980,1645050,7582,24498418395747,1202608
Line-9 : 7582,24498418414400,1221261,686,24498429469817,48339929910
Line-10: 686,24498429470804,48339930897,7566,24498418265980,1645050
Line-11: 7566,24498418268334,1647404,7583,24498417826636,1168325
Line-12: 7583,24498417845297,1186986,7560,24498429470724,823156608
Line-13: 7560,24498429471802,823157686,7566,24498418268334,1647404
Line-14: 7566,24498418270800,1649870,686,24498429470804,48339930897
// Up to this line vruntime of all process increased in each run as expected.
Line-15: 686,24498438028365,48348488458,7560,24498429471802,823157686
Line-16: 0,0,0,7,918077230457,2930949708
Line-17: 7,918077232097,2930951348,0,0,0
Line-18: 7560,6056741110796,823305719,7584,24498429478909,1156272 <---- Here vruntime of process 7560 is decreased . Why?
一切看起来都很完美-每次运行都会增加流程的运行时间
令我惊讶的是,在最后一行,运行进程的运行时间缩短了