- 论坛徽章:
- 16
|
有人对__update_curr做如下分析:- static inline void
- __update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr,
- unsigned long delta_exec)
- {
- /*更新cfs_rq->min_vruntime,它近似等于rb_tree中最左侧节点的vruntime.
- *实际情况是要比它稍微大一点.
- */
- update_min_vruntime(cfs_rq);
- }
复制代码 update_min_vruntime源码如下:- 450static void update_min_vruntime(struct cfs_rq *cfs_rq)
- 451{
- 452 u64 vruntime = cfs_rq->min_vruntime;
- 453
- 454 if (cfs_rq->curr)
- 455 vruntime = cfs_rq->curr->vruntime;
- 456
- 457 if (cfs_rq->rb_leftmost) {
- 458 struct sched_entity *se = rb_entry(cfs_rq->rb_leftmost,
- 459 struct sched_entity,
- 460 run_node);
- 461
- 462 if (!cfs_rq->curr)
- 463 vruntime = se->vruntime;
- 464 else
- 465 vruntime = min_vruntime(vruntime, se->vruntime);
- 466 }
- 467
- 468 cfs_rq->min_vruntime = max_vruntime(cfs_rq->min_vruntime, vruntime);
- 469#ifndef CONFIG_64BIT
- 470 smp_wmb();
- 471 cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
- 472#endif
- 473}
复制代码 如果cfs_rq->curr->vruntime为3,cfs_rq->rb_leftmost的vruntime为4,那么update_min_vruntime中的vruntime应该为3
cfs_rq->min_vruntime = max_vruntime(cfs_rq->min_vruntime, vruntime);
这句话中之前的cfs_rq->min_vruntime可能会比3小吧,这样结果的cfs_rq->min_vruntime就应该是3了,并不比leftmost大啊
请指点~
|
|