免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1409 | 回复: 4
打印 上一主题 下一主题

cfs问题 [复制链接]

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-08 14:33 |只看该作者 |倒序浏览
有人对__update_curr做如下分析:
  1. static inline void
  2. __update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr,
  3.           unsigned long delta_exec)
  4. {
  5.     /*更新cfs_rq->min_vruntime,它近似等于rb_tree中最左侧节点的vruntime.
  6. *实际情况是要比它稍微大一点.
  7. */
  8.     update_min_vruntime(cfs_rq);
  9. }
复制代码
update_min_vruntime源码如下:
  1. 450static void update_min_vruntime(struct cfs_rq *cfs_rq)
  2. 451{
  3. 452        u64 vruntime = cfs_rq->min_vruntime;
  4. 453
  5. 454        if (cfs_rq->curr)
  6. 455                vruntime = cfs_rq->curr->vruntime;
  7. 456
  8. 457        if (cfs_rq->rb_leftmost) {
  9. 458                struct sched_entity *se = rb_entry(cfs_rq->rb_leftmost,
  10. 459                                                   struct sched_entity,
  11. 460                                                   run_node);
  12. 461
  13. 462                if (!cfs_rq->curr)
  14. 463                        vruntime = se->vruntime;
  15. 464                else
  16. 465                        vruntime = min_vruntime(vruntime, se->vruntime);
  17. 466        }
  18. 467
  19. 468        cfs_rq->min_vruntime = max_vruntime(cfs_rq->min_vruntime, vruntime);
  20. 469#ifndef CONFIG_64BIT
  21. 470        smp_wmb();
  22. 471        cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
  23. 472#endif
  24. 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大啊
请指点~


论坛徽章:
1
拜羊年徽章
日期:2015-03-03 16:15:43
2 [报告]
发表于 2012-04-08 20:16 |只看该作者
初始化的值给大一点。 一般求min值时,初始化的值都给得比较高;这样按照上面的算法作下来,就不会有你担心的情况。

论坛徽章:
0
3 [报告]
发表于 2012-04-09 09:58 |只看该作者
回复 1# embeddedlwp

并不一定要比leftmost大,如果curr->vruntime < se_of(leftmost)->vruntime,那就不需要进程切换,curr会继续执行;
update_curr会在每一个时钟中断执行,而一个进程至少要运行多个时钟中断;

   

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
4 [报告]
发表于 2012-04-09 18:11 |只看该作者
linuxfellow 发表于 2012-04-08 20:16
初始化的值给大一点。 一般求min值时,初始化的值都给得比较高;这样按照上面的算法作下来,就不会有你担心 ...



从哪里看出初始化的值会大一些?

论坛徽章:
0
5 [报告]
发表于 2012-04-10 13:51 |只看该作者
/*更新cfs_rq->min_vruntime,它近似等于rb_tree中最左侧节点的vruntime.
*实际情况是要比它稍微大一点.
*/

我感觉作者说这句话的意思想要说明cfs_rq->min_vruntime“只增不减”的特质。但是表述和代码略有偏差。
实际上,update_min_vruntime会试图将cfs_rq->min_vruntime更新为rq中最小的那个vruntime,但是有个前提,cfs_rq->min_vruntime只增不减。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP