免费注册 查看新帖 |

Chinaunix

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

怎么有三种抢占选择? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-09 15:30 |只看该作者 |倒序浏览

配置内核在选择抢占方式时发现有三个选项:

No forced preemption (server)
voluntary kernel preemption (desktop)
preemptible kernel (low-latency desktop)

这三项有何区别?

论坛徽章:
6
金牛座
日期:2013-10-08 10:19:10技术图书徽章
日期:2013-10-14 16:24:09CU十二周年纪念徽章
日期:2013-10-24 15:41:34狮子座
日期:2013-11-24 19:26:19未羊
日期:2014-01-23 15:50:002015年亚洲杯之阿联酋
日期:2015-05-09 14:36:15
2 [报告]
发表于 2012-04-10 11:59 |只看该作者
本帖最后由 瀚海书香 于 2012-04-10 12:36 编辑

回复 1# xparmenides
说白了就是允许抢占的时机点的不同。
PREEMPT_NONE 禁止优先级抢占
PREEMPT_VOLUNTARY 增加自愿抢占的时机,但是禁止内核态抢占
PREEMPT  允许内核态抢占


   6config PREEMPT_NONE
   7        bool "No Forced Preemption (Server)"
   8        help
   9          This is the traditional Linux preemption model, geared towards
  10          throughput. It will still provide good latencies most of the
  11          time, but there are no guarantees and occasional longer delays
  12          are possible.
  13
  14          Select this option if you are building a kernel for a server or
  15          scientific/computation system, or if you want to maximize the
  16          raw processing power of the kernel, irrespective of scheduling
  17          latencies.
  18
  19config PREEMPT_VOLUNTARY
  20        bool "Voluntary Kernel Preemption (Desktop)"
  21        help
  22          This option reduces the latency of the kernel by adding more
  23          "explicit preemption points" to the kernel code. These new
  24          preemption points have been selected to reduce the maximum
  25          latency of rescheduling, providing faster application reactions,
  26          at the cost of slightly lower throughput.
  27
  28          This allows reaction to interactive events by allowing a
  29          low priority process to voluntarily preempt itself even if it
  30          is in kernel mode executing a system call. This allows
  31          applications to run more 'smoothly' even when the system is
  32          under load.
  33
  34          Select this if you are building a kernel for a desktop system.
  35
  36config PREEMPT
  37        bool "Preemptible Kernel (Low-Latency Desktop)"
  38        select PREEMPT_COUNT
  39        help
  40          This option reduces the latency of the kernel by making
  41          all kernel code (that is not executing in a critical section)
  42          preemptible.  This allows reaction to interactive events by
  43          permitting a low priority process to be preempted involuntarily
  44          even if it is in kernel mode executing a system call and would
  45          otherwise not be about to reach a natural preemption point.
  46          This allows applications to run more 'smoothly' even when the
  47          system is under load, at the cost of slightly lower throughput
  48          and a slight runtime overhead to kernel code.
  49
  50          Select this if you are building a kernel for a desktop or
  51          embedded system with latency requirements in the milliseconds
  52          range.
  53

   

论坛徽章:
22
丑牛
日期:2014-08-15 14:32:0015-16赛季CBA联赛之同曦
日期:2017-12-14 15:28:14黑曼巴
日期:2017-08-10 08:14:342017金鸡报晓
日期:2017-02-08 10:39:42黑曼巴
日期:2016-11-15 15:48:38CU十四周年纪念徽章
日期:2016-11-09 13:19:1015-16赛季CBA联赛之同曦
日期:2016-04-08 18:00:03平安夜徽章
日期:2015-12-26 00:06:30程序设计版块每日发帖之星
日期:2015-12-03 06:20:002015七夕节徽章
日期:2015-08-21 11:06:17IT运维版块每日发帖之星
日期:2015-08-09 06:20:002015亚冠之吉达阿赫利
日期:2015-07-03 08:39:42
3 [报告]
发表于 2012-04-13 17:07 |只看该作者
配置的时候按H可以看说明,也可以像LS一样直接读Kconfig。再搞不明白就去看Makefile里面需要读的源码吧。

论坛徽章:
2
CU十二周年纪念徽章
日期:2013-10-24 15:41:34处女座
日期:2013-12-27 22:22:41
4 [报告]
发表于 2012-04-15 12:44 |只看该作者
本帖最后由 tempname2 于 2012-04-15 14:39 编辑

真没注意中间那种情况,搜索一下,还是有历史的。2.6的早期PREEMPT_VOLUNTARY和PREEMPT似乎不是互斥的,而且可以动态的独立开启关闭,排列组合。

如果选中了,就是传统非内核抢占,加上新增might_sleep作为主动调度点。显式用sched调度那因为没别的事做了,而用might_sleep调度时则有是事可做但调度无害,但为了低lantency,还是调度了。


==========

理解有偏差,might_sleep不仅是睡眠无害,而且是极有可能睡眠。这个东西的初衷应该是检测在中断上下文中调用某些函数,而非(如我之前所想)暗示可以被抢占。

论坛徽章:
9
程序设计版块每日发帖之星
日期:2016-02-13 06:20:00数据库技术版块每日发帖之星
日期:2016-06-15 06:20:00数据库技术版块每日发帖之星
日期:2016-06-16 06:20:00数据库技术版块每日发帖之星
日期:2016-06-18 06:20:00程序设计版块每日发帖之星
日期:2016-06-27 06:20:00程序设计版块每日发帖之星
日期:2016-07-09 06:20:00IT运维版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-07-27 06:20:00程序设计版块每日发帖之星
日期:2016-08-18 06:20:00
5 [报告]
发表于 2014-01-24 14:16 |只看该作者
怎么自愿抢占,进程不会自己加自愿抢占,是不是基于时间片?

论坛徽章:
15
射手座
日期:2014-02-26 13:45:082015年迎新春徽章
日期:2015-03-04 09:54:452015年辞旧岁徽章
日期:2015-03-03 16:54:15羊年新春福章
日期:2015-02-26 08:47:552015年亚洲杯之卡塔尔
日期:2015-02-03 08:33:45射手座
日期:2014-12-31 08:36:51水瓶座
日期:2014-06-04 08:33:52天蝎座
日期:2014-05-14 14:30:41天秤座
日期:2014-04-21 08:37:08处女座
日期:2014-04-18 16:57:05戌狗
日期:2014-04-04 12:21:33技术图书徽章
日期:2014-03-25 09:00:29
6 [报告]
发表于 2014-01-24 15:36 |只看该作者
mordorwww 发表于 2014-01-24 14:16
怎么自愿抢占,进程不会自己加自愿抢占,是不是基于时间片?

这个应该只是一个概念而已,本质上只是增加了调度时机。

论坛徽章:
9
程序设计版块每日发帖之星
日期:2016-02-13 06:20:00数据库技术版块每日发帖之星
日期:2016-06-15 06:20:00数据库技术版块每日发帖之星
日期:2016-06-16 06:20:00数据库技术版块每日发帖之星
日期:2016-06-18 06:20:00程序设计版块每日发帖之星
日期:2016-06-27 06:20:00程序设计版块每日发帖之星
日期:2016-07-09 06:20:00IT运维版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-07-27 06:20:00程序设计版块每日发帖之星
日期:2016-08-18 06:20:00
7 [报告]
发表于 2014-01-24 16:04 |只看该作者
humjb_1983 发表于 2014-01-24 15:36
这个应该只是一个概念而已,本质上只是增加了调度时机。


应该不仅仅是增加了调度时机。如果三次调度间隔为1ms和10分钟,虽然多了最后一次调度,但是间隔太长

论坛徽章:
15
射手座
日期:2014-02-26 13:45:082015年迎新春徽章
日期:2015-03-04 09:54:452015年辞旧岁徽章
日期:2015-03-03 16:54:15羊年新春福章
日期:2015-02-26 08:47:552015年亚洲杯之卡塔尔
日期:2015-02-03 08:33:45射手座
日期:2014-12-31 08:36:51水瓶座
日期:2014-06-04 08:33:52天蝎座
日期:2014-05-14 14:30:41天秤座
日期:2014-04-21 08:37:08处女座
日期:2014-04-18 16:57:05戌狗
日期:2014-04-04 12:21:33技术图书徽章
日期:2014-03-25 09:00:29
8 [报告]
发表于 2014-01-24 16:14 |只看该作者
mordorwww 发表于 2014-01-24 16:04
应该不仅仅是增加了调度时机。如果三次调度间隔为1ms和10分钟,虽然多了最后一次调度,但是间隔太长

还是没怎么看明白,呵呵,调度不一定是在时钟中断来的时候发生的,普通的中断返回也有调度点的,当然还有其他的调度点,比如系统调用返回,wake_up进程等。

论坛徽章:
9
程序设计版块每日发帖之星
日期:2016-02-13 06:20:00数据库技术版块每日发帖之星
日期:2016-06-15 06:20:00数据库技术版块每日发帖之星
日期:2016-06-16 06:20:00数据库技术版块每日发帖之星
日期:2016-06-18 06:20:00程序设计版块每日发帖之星
日期:2016-06-27 06:20:00程序设计版块每日发帖之星
日期:2016-07-09 06:20:00IT运维版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-07-27 06:20:00程序设计版块每日发帖之星
日期:2016-08-18 06:20:00
9 [报告]
发表于 2014-01-24 16:28 |只看该作者
humjb_1983 发表于 2014-01-24 16:14
还是没怎么看明白,呵呵,调度不一定是在时钟中断来的时候发生的,普通的中断返回也有调度点的,当然还有 ...



我是说内核线程怎么办?只有时钟中断是可靠的啊,其它的中断和系统调用返回啥时有,根本就不确定啊,也可能很长时间没有啊

论坛徽章:
15
射手座
日期:2014-02-26 13:45:082015年迎新春徽章
日期:2015-03-04 09:54:452015年辞旧岁徽章
日期:2015-03-03 16:54:15羊年新春福章
日期:2015-02-26 08:47:552015年亚洲杯之卡塔尔
日期:2015-02-03 08:33:45射手座
日期:2014-12-31 08:36:51水瓶座
日期:2014-06-04 08:33:52天蝎座
日期:2014-05-14 14:30:41天秤座
日期:2014-04-21 08:37:08处女座
日期:2014-04-18 16:57:05戌狗
日期:2014-04-04 12:21:33技术图书徽章
日期:2014-03-25 09:00:29
10 [报告]
发表于 2014-01-24 16:35 |只看该作者
mordorwww 发表于 2014-01-24 16:28
我是说内核线程怎么办?只有时钟中断是可靠的啊,其它的中断和系统调用返回啥时有,根本就不确定啊, ...

是的,时钟中断(在没有nohz)的情况下是固定的,默认1ms一次,如果配置了抢占,那至少每次时钟中断的时候调度,这个应该是最高待遇了~
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP