linux内核实时补丁

继续整理,在ubuntu的系统上安装了KVM。给KVM基础的其中一个ubuntu虚拟机安装实时补丁,来测试KVM是否能支持实时系统,做为一个real-time hypervisor。


方法一

直接安装packages, 包括real time image之类的。

sudo add-apt-repository ppa:abogani/realtime

sudo apt-get update

在命令行输入 sudo apt-get install linux-realtime 会自动安装。

这样安装的不需要reboot,但是configuration是默认的,Timer Frequency是 250Hz。



方法二

与原贴稍有不同:http://www.cnblogs.com/jvpy/archive/2010/04/12/1710543.html

在给虚拟机安装的时候,内核编译需要比较大的空间,如20G以上。安装完以后有可能会出现一个bug

https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/712878 

据说是和SMP的内核有关系,我感觉是虚拟空间太大的虚拟机就会运行不起来。

但是如果是用GUI,virtual manager 创建和运行的就没问题。


编译内核

在没有打上这个补丁时,编译内核时就会有这些选项可供选择,它们位于:
Processor type and features ---> Preemption Model (Preemptible Kernel (Low-Latency Desktop)) --->
说明:抢占模式:
No Forced Preemption (Server),这种模式等同于没有使能抢占选项的标准内核,主要适用于科学计算等服务器环境。

Voluntary Kernel Preemption (Desktop),这种模式使能了自愿抢占,但仍然失效抢占内核选项,它通过增加抢占点缩减了抢占延迟,因此适用于一些需要较好的响应性的环境,如桌面环境,当然这种好的响应性是以牺牲一些吞吐率为代价的。

Preemptible Kernel (Low-Latency Desktop),这种模式既包含了自愿抢占,又使能了可抢占内核选项,因此有很好的响应延迟,实际上在一定程度上已经达到了软实时性。它主要适用于桌面和一些嵌入式系统,但是吞吐率比模式2更低。


在打上这个补丁后再编译,就会出现一个Fully Preemption Mode(Real-Time)的选项,这种模式使能了所有实时功能,因此完全能够满足软实时需求,它适用于延迟要求为100微秒或稍低的实时系统。


网上的实时补丁有很多,这里用Ingo的RT patch:http://www.kernel.org/pub/linux/kernel/projects/rt/

RT Kernel - why?

   The main goal in audio-processing is the latency. The latency is the delay beetween signal-creating and reaching the processing in the system (e.g time between pressing a key on the keyboard and hearing the tone). The standard kernels have the disadvantage that the processing is slower (~11ms) as in Windows or using a MAC . The faster the system, means the lower the latency, the more things can happen simular on a the system Ingo Molnar, a RedHat developer and some others have started a project to minimize the latency in Linux: Realtime Preemption. By using excellent audio-hardware the JACK demon (Jack Audio Connection Kit) reach latency < 1ms, similar to the MacOS X "coreaudio" system. 


patch kernel
----------------------------
# cd /usr/src
# ls
linux-3.2.23.tar.bz2 patch-3.2.23-rt36.patch
# tar jxf linux-3.2.23.tar.bz2
# cd linux-3.2.23
# patch -p1 < ../patch-3.2.23-rt36.patch


配置

# make menuconfig
----------------------------
Processor type and features --->
    [*] High Resolution Timer Support

    Preemption Mode (Complete Preemption (Real-Time)) --->
        ( ) No Forced Preemption (Server)
        ( ) Voluntary Kernel Preemption (Desktop)
        ( ) Preemptible Kernel (Low-Latency Desktop)
        (X) Fully Preemption (Real-Time)

    Timer frequency (1000 HZ) --->
        ( ) 100 HZ
        ( ) 250 HZ
        ( ) 300 HZ
        (X) 1000 HZ

Kernel hacking --->
    [*] Magic SysRq key
    [ ] Kernel debugging
(note: need to look at a -rt kernel config for a full list)


下来配置默认配置已经能够满足要求:
----------------------------------
Note that since kernel 2.6.18-rt8, you may have to activate ACPI option to activate high resolution timer.

Power management options (ACPI, APM) --->
    ACPI (Advanced Configuration and Power Interface) Support --->
         [*] ACPI Support
         [*] Power Management Timer Support (2.6.21没有此项)
要加上linux kernel原本需要的配置。

activate realtime-lsm (deprecated)
----------------------------------
Note that the kernel config option is only available when the kernel is patched with rt-lsm patch. If it isn't, you can emerge realtime-lsm to get the module after the kernel is compiled an installed. Only activate "Default Linux Capabilities" in that case.

Security options --->
    [*] Enable different security models

Leave the menu with "Exit" and save configuration.

然后按照内核编译的步骤继续编译。编译后可以reboot, 使用uname -a来查看版本是否更新。


你可能感兴趣的:(linux)