更改 linux 内核定时器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4956206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:47:24  来源:igfitidea点击:

Change linux kernel timer

linuxtimerlinux-kernel

提问by apoorv020

I have to run a latency sensitive application and I have been asked to change the timer resolution to 1000 Hz or more. I searched on the net a bit and found pages about CONFIG_HZ etc.

我必须运行一个延迟敏感的应用程序,我被要求将计时器分辨率更改为 1000 Hz 或更高。我在网上搜索了一下,找到了关于 CONFIG_HZ 等的页面。

However, there are what seem to be several other related settings in the file as well, so I want to be sure that I don't mess the settings up. I am posting some output here

但是,文件中似乎还有其他几个相关设置,所以我想确保我不会弄乱设置。我在这里发布一些输出

$cat /boot/config-2.6.28-11-generic | grep HZ
# CONFIG_HZ_1000 is not set
# CONFIG_HZ_300 is not set
CONFIG_MACHZ_WDT=m
CONFIG_NO_HZ=y
CONFIG_HZ=250
# CONFIG_HZ_100 is not set
CONFIG_HZ_250=y

So does the second line, "# CONFIG_HZ_1000 is not set", mean that 1000Hz is not supported? Do I have to change just CONFIG_HZ and not CONFIG_HZ-250?

那么第二行“#CONFIG_HZ_1000 未设置”是否表示不支持 1000Hz?我是否只需要更改 CONFIG_HZ 而不是 CONFIG_HZ-250?

PS: I'm using the 2.6 kernel (ubuntu jaunty) on a Geode processor.

PS:我在 Geode 处理器上使用 2.6 内核(ubuntu jaunty)。

EDIT1: I ran some code from http://www.advenage.com/topics/linux-timer-interrupt-frequency.phpon my desktop machine and the development machine. The code supposedly is an accurate measure of how fast a timer the system can sustain. The output was approximately 183 Hz (on the development machine). So will changing the timer be meaningful?

EDIT1:我在台式机和开发机上从http://www.advenage.com/topics/linux-timer-interrupt-frequency.php运行了一些代码。据称,该代码可以准确衡量系统可以维持多快的计时器。输出约为 183 Hz(在开发机器上)。那么改变定时器有意义吗?

采纳答案by bdonlan

Don't edit .configdirectly, unless you're a Kbuild expert (and if you're asking this, you're not a Kbuild expert). Instead run make menuconfigor make xconfigto load the menu-based configuration system. Alternately, make configwill do a line-based configuration process (where it asks you several hundred questions about what to configure - not recommended). The relevant option is under "Processor type and features" as "Timer frequency".

不要.config直接编辑,除非你是 Kbuild 专家(如果你问这个,你不是 Kbuild 专家)。而是运行make menuconfigmake xconfig加载基于菜单的配置系统。或者,make config将执行基于行的配置过程(它会询问您数百个关于配置内容的问题 - 不推荐)。相关选项在“处理器类型和功能”下作为“定时器频率”。

That said, this may not be necessary. Modern Linux can use high-resolution event timers (CONFIG_HIGH_RES_TIMERS) to acheive low-latency timers even without increasing the timer frequency. With a tickless system (CONFIG_NO_HZ) , the timer frequency has little effect at all.

也就是说,这可能没有必要。CONFIG_HIGH_RES_TIMERS即使不增加计时器频率,现代 Linux 也可以使用高分辨率事件计时器 ( ) 来实现低延迟计时器。对于无滴答系统 ( CONFIG_NO_HZ) ,定时器频率几乎没有影响。

On the other hand, I'm not sure what timer support Geode CPUs have. You may want to run cyclictestwith various kernel configurations to see what you need to get low latency performance. The test you ran tests maximum dispatch frequency, not dispatch latency, so comparing with cyclictest results would be interesting. If you need reallylow latency, the CONFIG_PREEMPT_RT patchsetmay also be of interest.

另一方面,我不确定 Geode CPU 有什么计时器支持。您可能希望使用各种内核配置运行cyclictest以查看获得低延迟性能所需的条件。您运行的测试测试的是最大调度频率,而不是调度延迟,因此与循环测试结果进行比较会很有趣。如果您需要非常低的延迟,则CONFIG_PREEMPT_RT 补丁集也可能有用。

回答by viraptor

To change the timer setting you need to recompile the kernel. Change the option in some standard menu configuration tool, rather than the text file.

要更改计时器设置,您需要重新编译内核。更改某些标准菜单配置工具中的选项,而不是文本文件。

/boot/config...files only tell you what is installed in the specific kernel binary. This is not a configuration file you can change.

/boot/config...文件只告诉您特定内核二进制文件中安装了什么。这不是您可以更改的配置文件。