Linux-ck (简体中文)
Linux-ck and headers
- 当前版本:3.7.6-2
- BFS CPU 调度器: v0.427
- CK 补丁集: 3.7-ck1
- 发行日期: 07-Feb-2013
Contents
通用包细节
Linux-ckAUR 是 AUR 中的一个包,在非官方 linux-ck 源中允许用户运行一个定制的内核/头文件,基于 Con Kolivas 的 ck1 补丁集,包括 Brain Fuck Scheduler (BFS)。许多 Archer 选择使用这个包,因为 BFS 在任意负载状况下都具有优异的桌面交互性能和敏捷反应特性。
发布周期
Linux-ck大致跟随官方Arch内核的发布周期。 但受以下要求的限制:
- 上游代码
- CK的补丁集
- BFQ补丁集
- ARCH config/config.x86_64只为主要版本设置
包默认信息
默认对config文件有三个修改:
- ck补丁集的开启或禁用选项。
- 不需要人工干预的编译BFQ补丁集选项。
- 应用 GCC 补丁 来启用编译时可选 CPU 优化 (这些选项不是标准 linux-ck 软件包的选项,只有用户启用自定义选项时编译才可用)。
所有其他选项都和ARCH官方默认内核的主要内核config文件一致!当然,用户可以自由地修改它们。linux-ck包包括一个选项切换nconfigconfig编辑器 (详细见下一节). 从CK的BFS 设置 FAQ获取一些建议。
安装选项
用户有两个选项得到这些内核包。
1. 从源代码编译
AUR 包含了上面提到的各个包。根据需要下载并安装其他的 AUR 包。
用户通过调整 PKGBUILD 中的选项可以自定义 linux-ck 包:
- 可选的 nconfig 可以提供用户指定的调节选项(Optional nconfig for user specific tweaking.)
- 选择通过一个 make localmodconfig 编译一个最小模块集合(Option to compile a minimal set of modules via a make localmodconfig.)
- 选择传递标准的 ARCH 配置选项或者简单的使用当前内核的 .config 文件
- 可选设置BFQ I/O 调度器为默认值
更多细节可见 PKGBUILD 文件中的注释。如果从 AUR 编译一定要仔细阅读。
2. 使用编译好的包
如果用户不想花费时间自己编译,一个由 graysky 维护的非官方源可以使用。
Graysky 的公钥被用来为包签名。Pacman v4 会自动请求这个公钥服务器,但是如果你想手动下载和添加这个公钥,从上面的链接下载。
通用和优化的内核包
这个源包含了通用的包以及针对 CPU 的包。许多 ARCH 用户很熟悉通用包的概念。官方的 ARCH 内核包含两种口味(i686 或者 x86_64),它们都是通用的包,i686 可以在任何兼容的 x86 CPU 上使用,x86_64 可以在任何兼容的 x86_64 CPU 上使用。
这个源为用户提供了在通用的 linux-ck 包和针对 CPU 优化过的包之间的选择:
通用的
- ck-generic ==> 使用通用的优化选项编译,适合任何兼容的 CPU,与官方的 ARCH linux 包一样。这对于 Intel 和 AMD 芯片都是适用的。
针对 CPU 优化的
- ck-atom ==> Intel Atom 平台针对性优化。 Intel Atom CPUs 有一个按顺序的流水线架构,因此会从据此优化过的代码获益。
- ck-corex ==> Intel Core 2 系列,包括 Dual 和 Quads (Core 2/新 Xeon/基于 Core2 的 Mobile Celeron) 以及 Core i3/i5/i7 系列针对性的优化 (Gulftown, Bloomfield, Lynnfield, Clarksfield, Arrendale, 和 Sandy/Ivybridge CPU).
- ck-kx ==> AMD K7 (Athlon/Athlon XP)/K8 (Athlon 64, Athlon 64 X2, 23xx Quad-Core Barcelona, Sempron, Sempron 64)/K10 系列 (Athlon X2 7x50, Phenom X3/X4, Phenom II, Athlon II X2/X3/X4, Sempron 64 (Socket AM3 only), 61xx Eight-Core Magny-Cours) 针对性的优化。允许使用一些扩展的指令集,同时向 GCC 传递了合适的优化标志。
- ck-p4 ==> Intel Pentium-4 针对性的优化 (P4/基于 P4 的 Celeron/Pentium-4 M/旧 Xeon).
- ck-pentm ==> Intel Pentium-M 针对性的优化 (Pentium-M 笔记本芯片/非 Pentium-4 M).
CPU-specific optimization are invoked at compilation by selecting the corresponding option under Processor type and features>Processor family or by setting-up the .config file accordingly. These changes setup make specific gcc options including the $CFLAGS. For more, see the following files:
- $srcdir/linux-$pkgver/arch/x86/Makefile
- $srcdir/linux-$pkgver/arch/x86/Makefile_32
添加源到 /etc/pacman.conf
1) 添加下面的代码到 /etc/pacman.conf
(我把这个条目放在文件末尾):
[repo-ck] Server = http://repo-ck.com/$arch
2) 添加验证Key(本项目来自ck内核官网 ,原条目没有此项,导致无法通过签名验证,无法安装。)
# pacman-key -r 5EE46C4C && pacman-key --lsign-key 5EE46C4C
3) 通过 pacman -Syy 刷新
完成了。想查看这个源的内容,这样搜索:
# pacman -Sl repo-ck
安装范例
使用 ck-X 组,然后选择想要安装的包。有6个组包含了6个包集合。ck-generic, ck-atom, ck-corex, ck-kx, ck-p4, 和 ck-pentm.
# pacman -S ck-generic :: There are 4 members in group ck-generic: :: Repository repo-ck 1) broadcom-wl-ck 2) linux-ck 3) linux-ck-headers 4) nvidia-ck Enter a selection (default=all):
另外,也可以直接用 Pacman 安装包:
# pacman -S linux-ck linux-ck-headers
怎样启用 BFQ I/O 调度器
从版本 3.0.4-2 开始,BFQ 补丁集默认被应用到包中。用户必须启用 BFQ 调度器才能使用它,默认是处于休眠状态。
全局(对所有设备)
追加 "elevator=bfq" 到 /boot/grub/menu.lst
内核启动行中(如果你使用 grub)或者在 /etc/default/grub
中的GRUB_CMDLINE_LINUX_DEFAULT="quiet" 一行下面,然后通过标准的 "grub-mkconfig -o /boot/grub/grub.cfg" 命令,重新编译 /boot/grub/grub.cfg
选择(对指定设备)
设定内核逐个设备使用。例如,如果想为 /dev/sda
启用只需要:
# echo bfq > /sys/block/sda/queue/scheduler
想验证一下,只需要 cat 同一个文件:
# cat /sys/block/sda/queue/scheduler noop deadline cfq [bfq]
疑难解答
与 Linux-ck 运行 Virtualbox
Virtualbox works just fine with custom kernels such as Linux-ck without the need to keep any of the official ARCH kernel packages on the system (i.e. linux and linux-headers from [core]). The trick to keeping pacman from bringing down the ARCH kernel packages is to install virtualbox with the virtualbox-source package. Why? Wonder kindly responded to FS#26721.
# pacman -S virtualbox virtualbox-source
After pacman finishes, simply generate the kernel modules (for linux-ck) like this (assuming the system is booted into the linux-ck kernel):
# /usr/bin/vboxbuild
论坛支持
Please use this discussion thread to voice comments, questions, suggestions, requests, etc. Note from graysky, "I can add other CPU-specific builds upon request. I just wanna be sure people will actually use them if I take the time to compile them."
Package Trivia/Repo Statistics
- Various package sets are compiled via a Bash wrapper script for makepkg. The script is publicly accessible at graysky's github repo.
- Repo statistics are available (popularity of packages, which CPU is most popular, # of downloads, etc.).
一点关于 BFS 的说明
BFS 设计目标
BFS 有两个主要的设计目标:
- 获得极佳的桌面交互和响应性能,同时不使用启发式的,或者是难以理解、无法建模和预测效果、当调度到一个任务时会影响到另一个任务的调度机制。
- 完全抛弃传统的cpu进程调度器的复杂设计,实现一个从底层就很简洁的调度器。
参见本文的 #更多关于 BFS 和 CK 补丁集的内容 部分获取更多信息。
一个排队论的视频
See this video about queuing theory for an interesting parallel with supermarket checkouts. Quote from CK, "the relevance of that video is that BFS uses a single queue, whereas the mainline Linux kernel uses a multiple queue design. The people are tasks, and the checkouts are CPUs. Of course there's a lot more to a CPU scheduler than just the queue design, but I thought this video was very relevant."
Some Performance-Based Metrics: BFS vs. CFS
A major benefit of using the BFS is increased responsiveness. The benefits however, are not limited to desktop feel. Graysky put together some non-responsiveness based benchmarks to compare it to the CFS contained in the "stock" linux kernel. Recognize however, that it was not implicitly designed to provide superior performance. The purpose of the benchmarks was to evaluate the CPU scheduler in the stock Linux kernel against the BFS in the corresponding kernel patched with the ck1 patchset on different machines to see if differences exist and to what degree they scale using performance based metrics even though these end points were never within the scope of primary design goals of the BFS.
It is noteworthy to mention that this is not a novel idea, Phoronix also benchmarking using non-latency based endpoints about which Con subsequently blogged.
Benchmark results are available for download in pdf format.
For those not wanting to see the data and just wanting the highlights:
- 7 different machines ranging from 1 to 16 cores were benchmark using both a make and a x264-based video benchmark.
- Each machine ran both the "standard" linux kernel (linux-3.0.1-2 from [core]) and the ck1-patched version of this kernel (linux-ck-3.0.6-2 from graysky's unofficial repo).
- All 7 machines preformed better using the linux-ck package on the make benchmark.
- x264 encoding results were mixed. 4 machines performed better on the BFS scheduler; 1 gave same results; and 3 performed worse. It should be noted that an experimental version (svn) of handbrake was used for these tests.