Linux 2.6.31内核优化指南

post by rocdk890 / 2012-7-18 17:59 Wednesday linux技术

介绍

本文档是一篇关于Linux Kernel 2.6.31的最简优化指南。作者旨在编译一份性能最佳且适合普通Application/Server开发用的内核。(非生产环境)
本文提及的内核调优,主要是通过选择最佳编译选项,删除无用驱动,减少内核尺寸,关闭部分安全特性等方式来进行的。

优化后的效果,主要体现在OS启动时间,启动后的内存占用以及应用程序运行性能。

由于作者水平有限,如果描述错误,还请不吝指教。

 

运行环境

虚拟机

Virtualbox 3.1.4

CPU

Core 2 Duo P9500 2.53G 双核 开启 vt-x, APIC

磁盘

虚拟 10GSATA磁盘

内存

分了1G物理内存

网卡

虚拟 AMD PCNet32 100M

其他

USB,串口,显卡,声卡全关

作者是在虚拟机中编译的内核,如果你与作者的运行环境不同,则本文档中的部分描述可能会与你的实际情况有一定出入。

不过,相信大部分用户在看到选项释义时,能做出适合自己的选择。

 

说明

下列选项中,通过 "// " 注释的行,代表金国步写的内核选项简介中未提及的选项释义。

通过红色 "<===" 注释的行,代表内核默认开启,本文档推荐关闭的选项,释义部分会给出关闭的理由。

 

参考资料

金国步写的内核选项简介

Linux Kernel Database

Linuxsir BBS

 

优化前后性能对比

项目

优化前

优化后

内核尺寸

4.1M

1.6M

启动时间(含dhcp+默认init service

22s

14s

启动后的内存占用

25M

22M

APP SPEC测试成绩

待测

待测

 

General setup  --->

[ ] Prompt for development and/or incomplete code/drivers <=== 显示尚在开发中或尚未完成的代码和驱动. 我不是内核或驱动开发人员。

()  Local version - append to kernel release

[ ] Automatically append version information to the version string

Kernel compression mode (Bzip2)  ---> <=== 对比默认的GzipBzip2拥有更高的压缩比

[*] Support for paging of anonymous memory (swap)

[*] System V IPC

[*] BSD Process Accounting

[ ]  BSD Process Accounting version 3 file format

[ ] Export task/process statistics through netlink (EXPERIMENTAL) <=== 体验类选项一律关

[ ] Auditing support <=== SELinux提供支持。我的使用场景主要是开发应用程序,不需要那么高的安全性,另外安全总是以牺牲性能为代价

RCU Subsystem  ---> // 非对称读写锁系统 是一种新的kernel锁机制,适用于读多写少环境

RCU Implementation (Classic RCU)  ---> <=== 选择标准的RCU系统, tree-base是给拥有大规模CPU集群的SMP系统用的

< > Kernel .config support

(18) Kernel log buffer size (16 => 64KB, 17 => 128KB)

[] Control Group support  ---><=== cgroups支持,文档资料cgroups主要作用是给进程分组,并可以动态调控进程组的CPU占用率。比如A进程分到apple组,给予20%CPU占用率,E进程分easy组,给予50%CPU占用率,最高100%。我目前没有此类应用场景,用到时会选择将其编译进去。

[] Kernel->user space relay support (formerly relayfs) <===在某些文件系统上(比如debugfs)提供从内核空间向用户空间传递大量数据的接口,我目前没有此类应用场景

-*- Namespaces support

[]   UTS namespace <=== 我没有已安装的应用程序要用到 UTS ns

[]   IPC namespace <=== 我没有已安装的应用程序要用到 IPC ns

[] Initial RAM filesystem and RAM disk (initramfs/initrd) support <=== 用于在真正内核装载前,做一些操作(俗称两阶段启动),比如加载modulemount一些非root分区,提供灾难恢复shell环境等,资料,我是期望直接从kernel image直接启动,所以没选它

[*] Optimize for size

[ ] Configure standard kernel features (for small systems)  --->

-*-   Load all symbols for debugging/ksymoops

[ ]     Do an extra kallsyms pass <===除非你在kallsyms中发现了bug并需要报告这个bug才打开该选项

Performance Counters  ---> 

[*] Kernel Performance Counters // CPU 性能监听器,包括 CPU同一时间执行指令数,cache miss数,分支预测失败次数(Branch misprediction)。调优其他程序时或许会用到,比如JVM

[ ] Strip assembler-generated symbols during link

[ ] Disable heap randomization

Choose SLAB allocator (SLUB (Unqueued Allocator))  --->

[ ] Profiling support (EXPERIMENTAL) <=== 我不是内核开发人员,不需要profile内核

[] Activate markers <=== 一种运行时状态分析诊断工具,类似 instrumentation资料,我用不到

[ ] Kprobes <=== 我不是内核开发人员,不需要调试内核

GCOV-based kernel profiling  --->

[ ] Enable gcov-based kernel profiling

 

[*] Enable loadable module support  ---> // 我很少使用dynamic module loading,所以,下面的选项只留一个unloading即可(默认)

--- Enable loadable module support

[ ]   Forced module loading

[*]   Module unloading

[ ]   Module versioning support

[ ]   Source checksum for all modules

 

-*- Enable the block layer  --->

--- Enable the block layer

[*]   Support for large (2TB+) block devices and files // 大硬盘支持,SATA设备如果不选,会发生 kernel panic,具体原因未知

[ ]   Block layer SG support v4 <=== 支持通用scsi块设备第4版,我用的是SATA

[ ]   Block layer data integrity support

IO Schedulers  ---> // IO调度器支持,不同程序可以会选用不同的调度策略,这里我们不要动他

<*> Anticipatory I/O scheduler

<*> Deadline I/O scheduler

<*> CFQ I/O scheduler

    Default I/O scheduler (CFQ)  --->

 

Processor type and features  --->

[*] Tickless System (Dynamic Ticks) // CPU节能,动态时间片意思是当CPU处于空闲时,降低内核定时器的轮询频率

[*] High Resolution Timer Support // 我有的时候要测试 Real Time JVM,希望内核能支持这种高响应速度的内核定时器,一般用户可关闭

[*] Symmetric multi-processing support

[ ] Support sparse irq numbering <=== 如果你想支持大量CPU,又想使用较低的内核内存占用,请启用它。我只有单块CPU

[*] Enable MPS table // 让多核/CPU系统支持ACPI

[ ] Support for big SMP systems with more than 8 CPUs

[ ] Support for extended (non-PC) x86 platforms <=== 我是X86平台,不需要再支持其他平台

[*] Single-depth WCHAN output // proc 相关的最好不要关

[ ] Paravirtualized guest support  --->

--- Paravirtualized guest support

[ ] Memtest

Processor family (Core 2/newer Xeon)  ---> <=== 这里请选择对应的CPU,我是 core 2 duo

[ ] Generic x86 support <=== 通用x86支持, 如果你的CPU能够在上述"Processor family"中找到就别选了

[*] HPET Timer Support

(4) Maximum number of CPUs <=== 我的CPU是双核,算上超线程HT最多虚拟4颗逻辑CPU,所以我选4 ,默认是8

[*] SMT (Hyperthreading) scheduler support

[*] Multi-core scheduler support

Preemption Model (Voluntary Kernel Preemption (Server))  ---> <=== 这里我选择了Server,它最贴近我的使用场景

[*] Reroute for broken boot IRQs // 防止同时收到多个boot IRQ(中断)时,系统混乱

[*] Machine Check Exception

[ ]   Use legacy machine check code (will go away)

[*]   Intel MCE features

[ ]   AMD MCE features <=== 我是intel CPU

[ ] Support for old Pentium 5 / WinChip machine checks

< > Machine check injector support

< > Toshiba Laptop support

< > Dell laptop support

[ ] Enable X86 board specific fixups for reboot <=== 修正某些旧x86主板的重起bug,这种主板基本绝种了

<*> /dev/cpu/microcode - microcode support

[*]   Intel microcode patch loading support

[ ]   AMD microcode patch loading support <===我是intel CPU

<*> /dev/cpu/*/msr - Model-specific register support

<*> /dev/cpu/*/cpuid - CPU information support

< > /sys/kernel/debug/x86/cpu/* - CPU Debug support

High Memory Support (4GB)  --->

(4096) Low address space to protect from user allocation

[*] Allocate 3rd-level pagetables from highmem <=== 在内存很多(大于4G)的机器上将用户空间的页表放到高位内存区,以节约宝贵的低端内存 ,我只虚拟了1G

[ ] Check for low memory corruption <=== 低位内存脏数据检查,默认是每60秒检查一次。一般这种脏数据是因某些Bios处理不当引起的。资料链接。我信任我目前的虚拟bios版本

[] Reserve low 64K of RAM on AMI/Phoenix BIOSen <=== 我不是 AMI/Phoenix BIOS

[ ] Math emulation

[ ] MTRR (Memory Type Range Register) support <=== 我没用 X windows

[ ]   MTRR cleanup support

[ ]   x86 PAT support <=== 我没用 X windows

[ ] EFI runtime service support <=== 我机器是BIOS引导的,用不到EFI(Extensible Firmware Interface),如果你有兴趣体验EFI,可以在Virtualbox中开启

[] Enable seccomp to safely compute untrusted bytecode <=== 只有嵌入式系统可以不选

[ ] Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)

Timer frequency (300 HZ)  ---> <=== Server场景建议设为300hz,减少内核事件响应速度,提高程序吞吐量,桌面场景可以保持不变

[ ] kexec system call <=== 我没有运行时替换内核的需求

[ ] kernel crash dumps <=== 内核崩溃时,dump运行时信息。就算crash了,我也不会去调试内核的core dump

[ ] Build a relocatable kernel <=== 官方说明 (建立一个移动的内核,并增加10%的内核尺寸,运行时会被丢弃),我认为没实质性的作用

(0x1000000) Physical address where the kernel is loaded

[] Support for hot-pluggable CPUs <=== 热拔插CPU,我用不到

[ ] Compat VDSO support

[ ] Built-in kernel command line

 

Power management and ACPI options  --->

[*] Power Management support

[ ]   Power Management Debug Support <=== 不想调试ACPI

[ ]     Verbose Power Management debugging

[ ] Suspend to RAM and standby <=== 我是用来跑server,一般不需要待机

[ ] Hibernation (aka 'suspend to disk')  <=== 我是用来跑server,一般不需要休眠

[*] ACPI (Advanced Configuration and Power Interface) Support  --->

[*]   Deprecated /proc/acpi files

[*]   Deprecated power /proc/acpi directories

[*]   Future power /sys interface

[*]   Deprecated /proc/acpi/event support

< >   AC Adapter <=== 我不需要从ACBattery之间做切换

< >   Battery <=== 没有电池

< >   Button <=== 没有Fn快捷键

-*-   Video

<*>   Fan

<*>   Processor

<*>     Thermal Zone

(0)   Disable ACPI for systems before Jan 1st this year

[ ]   Debug Statements

< >   PCI slot detection driver

< >   Smart Battery System

    CPU Frequency scaling  --->

[*] CPU Frequency scaling

[ ]   Enable CPUfreq debugging <=== 我不需要调试 CPUfreq

< >   CPU frequency translation statistics

Default CPUFreq governor (performance)  ---> <=== 默认用 performance高性能的CPU调频方式

<*>   'performance' governor

< >   'powersave' governor

<>   'userspace' governor for userspace frequency scaling <=== 既允许手动调整cpu频率,也允许用户空间的程序动态的调整cpu频率(需要额外的调频软件,比如cpufreqd)  我只用 performance

<>   'ondemand' cpufreq policy governor <=== "周期性的考察CPU负载并自动的动态调整cpu频率",我只用 performance

<>   'conservative' cpufreq governor

*** CPUFreq processor drivers ***

<*>   ACPI Processor P-States driver

< >   AMD Mobile K6-2/K6-3 PowerNow!

< >   AMD Mobile Athlon/Duron PowerNow!

< >   AMD Opteron/Athlon64 PowerNow!

< >   Cyrix MediaGX/NatSemi Geode Suspend Modulation

< >   Intel Enhanced SpeedStep (deprecated)

< >   Intel Speedstep on ICH-M chipsets (ioport interface)

< >   Intel Pentium 4 clock modulation

< >   Transmeta LongRun

< >   VIA Cyrix III Longhaul

 

Bus options (PCI etc.)  --->

[*] PCI support

PCI access mode (Any)  --->

[*] PCI Express support

[*]   Root Port Advanced Error Reporting support // 硬件驱动会负责发送错误信息

[ ]     PCI Express ECRC settings control

< >     PCIE AER error injector support

[*] Message Signaled Interrupts (MSI and MSI-X)

[ ] Enable deprecated pci_find_* API

[ ] PCI Debugging

< > PCI Stub driver

[*] Interrupts on hypertransport devices

[ ] PCI IOV support

[ ] ISA support

[ ] MCA support

< > NatSemi SCx200 support

[ ] One Laptop Per Child support

< > PCCard (PCMCIA/CardBus) support  ---> <===一般笔记本电脑会配备PCCard接口(无线网卡之类的),看你的硬件和使用场景吧。虽然我也是NB,但我从来不用PCMCIA

< > Support for PCI Hotplug  ---> <=== 我没有要热拔插PCI设备的需求

 

Executable file formats / Emulations  --->

[*] Kernel support for ELF binaries

[*] Write ELF core dumps with partial segments

< > Kernel support for a.out and ECOFF binaries

<*> Kernel support for MISC binaries

 

[*] Networking support  --->

Networking options  --->

<*> Packet socket

[*]   Packet socket: mmapped IO

<*> Unix domain sockets

<*> Transformation user configuration interface

< > PF_KEY sockets

[*] TCP/IP networking

[*]   IP: multicasting

[*]   IP: advanced router

Choose IP: FIB lookup algorithm (choose FIB_HASH if unsure) (FIB_HASH)  --->

[*]   IP: policy routing

[*]   IP: equal cost multipath

[*]   IP: verbose route monitoring

[ ]   IP: kernel level autoconfiguration <===我很少用网络引导OS,内核级别的网络配置对我无用。

[ ]     IP: DHCP support

[ ]     IP: BOOTP support

[ ]     IP: RARP support

< >   IP: tunneling

< >   IP: GRE tunnels over IP

[*]   IP: multicast routing

[*]     IP: PIM-SM version 1 support

[*]     IP: PIM-SM version 2 support

[ ]   IP: ARP daemon support

[ ]   IP: TCP syncookie support (disabled per default) <=== 抵抗SYN flood攻击,我是开发机,暂不考虑安全特性

< >   IP: AH transformation

< >   IP: ESP transformation

 < >   IP: IPComp transformation

< >   IP: IPsec transport mode

< >   IP: IPsec tunnel mode

< >   IP: IPsec BEET mode

[*]   Large Receive Offload (ipv4/tcp)

< >   INET: socket monitoring interface

[ ]   TCP: advanced congestion control  ---> <=== 高级拥塞控制,如果没有特殊需求(比如无线网络)就别选了

< >   The IPv6 protocol  ---> <=== 我暂时没有要支持IPV6的需求

[ ]   NetLabel subsystem support <=== NetLabel子系统, 为诸如CIPSORIPSO之类能够在分组信息上添加标签的协议提供支持,我用不到

[ ] Security Marking <=== 对网络包进行安全标记,类似于nfmark,但主要是为安全目的而设计, 安全特性,我暂时不考虑

[ ] Network packet filtering framework (Netfilter)  ---> <=== 我不打算使用防火墙,要用到时再编译进去

< > Asynchronous Transfer Mode (ATM)

< > 802.1d Ethernet Bridging

< > 802.1Q VLAN Support

< > DECnet Support

< > ANSI/IEEE 802.2 LLC type 2 Support

< > The IPX protocol

< > Appletalk protocol support

< > Phonet protocols family

[ ] QoS and/or fair queueing  --->  <=== 通过IPRoute切换网络设备上的Qos策略,我不打算使用IP路由

[ ] Data Center Bridging support

Network testing  --->

[ ]   Amateur Radio support  ---> <===我没有无线电

< >   CAN bus subsystem support  --->

< >   IrDA (infrared) subsystem support  --->

< >   Bluetooth subsystem support  --->

[ ]   Wireless  ---> <=== 我没有使用无线网卡

< >   RF switch subsystem support  ---> <=== 我没有RF切换设备

 

Device Drivers  --->

Generic Driver Options  --->

(/sbin/hotplug) path to uevent helper

[*] Prevent firmware from being built

-*- Userspace firmware loading support

[*]   Include in-kernel firmware blobs in kernel binary

()    External firmware blobs to build into the kernel binary

[ ] Driver Core verbose debug messages

[ ] Managed device resources verbose debug messages <===管理设备资源的冗长调试信息,我不需要

<*> Connector - unified userspace <-> kernelspace linker  --->// 内核空间与用户空间的信道

[*]   Report process events to userspace // 报告处理时间给用户空间

< > Memory Technology Device (MTD) support  --->

< > Parallel port support  --->

-*- Plug and Play support  --->

[ ]   PNP debugging messages <=== 调试信息,老规矩

[ ] Block devices  ---> <=== 我没有想要支持的块设备,比如ramdisk, 磁盘阵列,CD/DVD刻录等,详见内部选项

[ ] Misc devices  ---> <=== 没有需要支持的杂项设备

< > ATA/ATAPI/MFM/RLL support  --->

SCSI device support  --->

< > RAID Transport Class

-*- SCSI device support

[] legacy /proc/scsi/ support <=== 我没有SCSI设备

*** SCSI support type (disk, tape, CD-ROM) ***

<*> SCSI disk support // 就算你用SATA,此选项也必选

< > SCSI tape support

< > SCSI OnStream SC-x0 tape support

<> SCSI CDROM support <=== 我没有SCSI设备

<> SCSI generic support <=== 我没有SCSI设备

< > SCSI media changer support

[ ] Probe all LUNs on each SCSI device

[] Verbose SCSI error reporting (kernel size +=12K) <===我没有SCSI设备

[ ] SCSI logging facility

[ ] Asynchronous SCSI scanning

SCSI Transports  --->

<> Parallel SCSI (SPI) Transport Attributes <=== 我没有SCSI设备

< > FiberChannel Transport Attributes

< > iSCSI Transport Attributes

< > SAS Domain Transport Attributes

< > SRP Transport Attributes

[ ] SCSI low-level drivers  --->

< > SCSI Device Handlers  --->

< > OSD-Initiator library

Serial ATA (prod) and Parallel ATA (experimental) drivers  --->

[*]   ATA ACPI Support

[ ]   SATA Port Multiplier support <=== 我只有一枚SATA设备,没有使用 多路SATA/SATA Hub 的需求。Port Multiplier是南桥芯片提供的一种支持多块SATA设备,并共享总带宽的技术。

<*>   AHCI SATA support

< >   Silicon Image 3124/3132 SATA support

[*]   ATA SFF support

< >     ServerWorks Frodo / Apple K2 SATA support

<*>     Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support // Intel ICHG系列chipset driver

< >     Marvell SATA support 

< >     NVIDIA SATA support  

< >     Pacific Digital ADMA support                  

< >     Pacific Digital SATA QStor support            

< >     Promise SATA TX2/TX4 support                  

< >     Silicon Image SATA support                    

< >     SiS 964/965/966/180 SATA support              

< >     ULi Electronics SATA support                  

< >     VIA SATA support     

< >     VITESSE VSC-7174 / INTEL 31244 SATA support   

< >     Initio 162x SATA support                      

< >     ACPI firmware driver for PATA                 

< >     ALi PATA support     

< >     AMD/NVidia PATA support <===我用的是SATA,取消PATA支持

< >     ARTOP 6210/6260 PATA support                  

< >     ATI PATA support     

< >     CMD64x PATA support  

< >     CS5510/5520 PATA support                      

< >     CS5530 PATA support

< >     CS5536 PATA support                           

< >     EFAR SLC90E66 support                         

< >     Generic ATA support                           

< >     HPT 366/368 PATA support                      

< >     HPT 343/363 PATA support                      

< >     IT8211/2 PATA support                         

< >     JMicron PATA support                           

< >     Compaq Triflex PATA support                   

< >     Marvell PATA support via legacy mode          

<>     Intel PATA MPIIX support <=== 我用的是SATA,取消PATA支持

< >     Intel PATA old PIIX support <=== 我用的是SATA,取消PATA支持

< >     NETCELL Revolution RAID support               

< >     Nat Semi NS87410 PATA support                 

< >     Nat Semi NS87415 PATA support                 

< >     Older Promise PATA controller support         

< >     PC Tech RZ1000 PATA support                   

< >     SC1200 PATA support                           

< >     SERVERWORKS OSB4/CSB5/CSB6/HT1000 PATA support

< >     Promise PATA 2027x support                    

< >     CMD / Silicon Image 680 PATA support          

< >     SiS PATA support                              

< >     VIA PATA support                              

< >     Winbond SL82C105 PATA support                 

< >     Intel SCH PATA support <===我用的是SATA,取消PATA支持

[ ] Multiple devices driver support (RAID and LVM)  ---> <=== 暂时没有要使用Raid(磁盘阵列)和LVM(逻辑卷管理器,添加,删除逻辑分区)的需求

[ ] Fusion MPT device support  --->

IEEE 1394 (FireWire) support  --->

< > I2O device support  --->

[ ] Macintosh device drivers  ---> <=== Mac系统硬件设备驱动,没什么好说的,关

[*] Network device support  --->

< >   Dummy net driver support                        

< >   Bonding driver support                          

< >   EQL (serial line load balancing) support        

< >   Universal TUN/TAP device driver support         

< >   Virtual ethernet pair device                    

< >   General Instruments Surfboard 1000              

< >   ARCnet support  ---> 

<>   PHY Device support and infrastructure  ---> <=== PHY (物理层控制芯片,里面没有我对应的硬件

[*]   Ethernet (10 or 100Mbit)  --->

-*-   Generic Media Independent Interface device support

< >   Sun Happy Meal 10/100baseT support              

< >   Sun GEM support                                 

< >   Sun Cassini support                             

[ ]   3COM cards <=== 我不是3COM网卡

[]   "Tulip" family network device support  ---> <=== 不是 Tulip 系列

< >   HP 10/100VG PCLAN (ISA, EISA, PCI) support      

[*]   EISA, VLB, PCI and on board controllers

<*>     AMD PCnet32 PCI support  // 这是我的网卡驱动                     

< >     AMD 8111 (new PCI lance) support              

< >     Adaptec Starfire/DuraLAN support              

< >   Broadcom 440x/47xx ethernet support             

< >   nForce Ethernet support  <=== 不是 nForce 网卡       

< >   Intel(R) PRO/100+ support  <===不是 Intel 网卡            

< >   Myson MTD-8xx PCI Ethernet support              

< >   National Semiconductor DP8381x series PCI Ethernet support

<>   PCI NE2000 and clones support (see help) <=== NE2000无关

<>   RealTek RTL-8129/8130/8139 PCI Fast Ethernet Adapter support <=== 不是 RealTek 网卡

[ ]     Use PIO instead of MMIO                       

[ ]     Support for uncommon RTL-8139 rev. K (automatic channel equalization)

[ ]     Support for older RTL-8129/8130 boards        

[ ]     Use older RX-reset method

< >   RDC R6040 Fast Ethernet Adapter support         

< >   SiS 900/7016 PCI Fast Ethernet Adapter support  

< >   SMC EtherPower II                               

< >   SMSC LAN9420 PCI ethernet adapter support       

< >   Sundance Alta support                           

< >   TI ThunderLAN support                           

< >   Micrel KSZ8842                                  

< >   VIA Rhine support                               

< >   Atheros L2 Fast Ethernet support

[]   Ethernet (1000 Mbit)  ---> <=== 如果你是千M卡,请自行选择

[]   Ethernet (10000 Mbit)  ---> <=== 如果你是万M卡,请自行选择

<>   Token Ring driver support  ---> <=== IBM的令牌环网,用以太网的忽略

      Wireless LAN  --->                              

      *** Enable WiMAX (Networking options) to see the WiMAX drivers *** 

      USB Network Adapters  --->                      

[ ]   Wan interfaces support  --->                    

<>   FDDI driver support <=== 光纤卡驱动,相信没几个人能用上这玩意

< >   PPP (point-to-point protocol) support            

< >   SLIP (serial line) support                      

[ ]   Fibre Channel driver support

[ ] ISDN support  --->       

< > Telephony support  --->  

Input device support  --->

-*- Generic input layer (needed for keyboard, mouse, ...)

-*-   Support for memoryless force-feedback devices   

<>   Polled input device skeleton  <=== 一种周期性轮询硬件状态的驱动,去掉后没什么副作用

      *** Userland interfaces ***                     

-*-   Mouse interface

[ ]     Provide legacy /dev/psaux device 

(1024)  Horizontal screen resolution                  

(768)   Vertical screen resolution                    

< >   Joystick interface                              

<>   Event interface  <=== 将输入设备的事件存储到/dev/input/eventX供应用程序读取,没相关需求

< >   Event debugging                                 

      *** Input Device Drivers ***                    

-*-   Keyboards  --->

[]   Mice  ---> <=== 我是用纯字符终端,如果你想用X window,请自行选择                             

[]   Joysticks/Gamepads  --->  <=== 游戏设备

[]   Tablets  ---> <=== 平板PC

[]   Touchscreens  --->  <=== 触摸屏

[]   Miscellaneous devices  ---> <=== 杂七杂八的驱动,扬声器,笔记本扩展按键等

Hardware I/O ports  --->

Character devices  ---> 

-*- Virtual terminal         

[]   Support for binding and unbinding console drivers // 在某些系统上可以使用多个控制台驱动程序(framebuffer控制台驱动程序),该选项使得你可以选择其中之一 ,我一般只用默认的虚拟终端

[] /dev/kmem virtual device support  <=== 支持/dev/kmem设备,很少用    

[] Non-standard serial port support  <=== 我没有非标准的串口设备

 Serial drivers  --->

< > 8250/16550 and compatible serial support <=== 兼容一些老式的串口设备,我一般不用

    *** Non-8250 serial port support ***

< > Digi International NEO PCI Support

-*- Unix98 PTY support       

[ ]   Support multiple instances of devpts            

[ ] Legacy (BSD) PTY support 

< > IPMI top-level message handler  --->              

<*> Hardware Random Number Generator Core support     

< >   Timer IOMEM HW Random Number Generator support  

<*>   Intel HW Random Number Generator support    

<>   AMD HW Random Number Generator support  <=== 我是intel主板

 < >   AMD Geode HW Random Number Generator support <=== 我是intel主板

<>   VIA HW Random Number Generator support <=== 我是intel主板    

<> /dev/nvram support  <=== 直接存取CMOS,太危险,关

< > Siemens R3964 line discipline

< > Applicom intelligent fieldbus card support         

< > ACP Modem (Mwave) support

< > NatSemi PC8736x GPIO Support                      

< > NatSemi Base GPIO Support

< > AMD CS5535/CS5536 GPIO (Geode Companion Device)   

< > RAW driver (/dev/raw/rawN)

[*] HPET - High Precision Event Timer               

[ ]   Allow mmap of HPET     

< > Hangcheck timer

-*- I2C support  ---> // 感知硬件状态,比如温度,风扇转速

[ ] SPI support  --->        

    PPS support  --->        

[ ] GPIO Support  --->       

< > Dallas's 1-wire support  --->                     

-*- Power supply class support  --->                  

<*> Hardware Monitoring support  --->      

-*- Generic Thermal sysfs driver  --->                

[*] Watchdog Timer Support  --->                      

    Sonics Silicon Backplane  --->                    

    Multifunction device drivers  --->                

[ ] Voltage and Current Regulator Support  --->       

< > Multimedia support  ---> 

Graphics support  --->

<> /dev/agpgart (AGP Support)  ---> <=== 用字符终端的忽略            

<> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  ---> <=== 用字符终端的忽略

<> Lowlevel video output switch controls  <=== 用字符终端的忽略

<> Support for frame buffer devices  --->  <===用字符终端的忽略

[] Backlight & LCD device support  --->  <===用字符终端的忽略

    Display device support  ---> 

    Console display driver support  --->  

[*]   Enable Scrollback Buffer in System RAM

(64)    Scrollback Buffer Size (in KB)

<> Sound card support  --->  <=== 用不到声卡

[] HID Devices  --->  <=== 用不到人力工程学设备

[] USB support  --->  <=== 这个选项,对于跑物理机建议开启,因为有可能你的键盘是USB的,我是跑虚拟机的,所以关了

< > MMC/SD/SDIO card support  --->  

< > Sony MemoryStick card support (EXPERIMENTAL)  --->

[] LED Support  --->  <=== 发光二级管,应该是跟显示器相关的驱动,由于我运行的是虚拟机,所以我选择关闭

[ ] Accessibility support  --->

< > InfiniBand support  ---> 

[*] EDAC (Error Detection And Correction) reporting  ---> // 硬件故障repoting

<*> Real Time Clock  --->

[*] DMA Engine support  ---> 

[ ] Auxiliary Display support  --->                   

< > Userspace I/O drivers  --->                       

    TI VLYNQ  --->           

[ ] Staging drivers  --->    

[] X86 Platform Specific Device Drivers  ---> <===一些笔记本的驱动,我没有相关设备

 

Firmware Drivers  --->

< > BIOS Enhanced Disk Drive calls determine boot disk

< > BIOS update support for DELL systems via sysfs    

< > Dell Systems Management Base Driver               

[*] Export DMI identification via sysfs to userspace   // BIOS里的DMI区信息导出到用户空间,部分系统管理工具可能会用到

[ ] iSCSI Boot Firmware Table Attributes

 

File systems  --->

< > Second extended fs support

<> Ext3 journalling file system support <=== 我使用的是ext4 FS

<*> The Extended 4 (ext4) filesystem

[ ]   Enable ext4dev compatibility                    

[*]   Ext4 extended attributes

[*]     Ext4 POSIX Access Control Lists

[]     Ext4 Security Labels  <=== 取消 SELinux 支持

[ ] JBD (ext3) debugging support

[ ] JBD2 (ext4) debugging support                     

< > Reiserfs support         

< > JFS filesystem support   

< > XFS filesystem support   

< > OCFS2 file system support

[*] Dnotify support          

[*] Inotify file change notification support          

[*] Inotify support for userspace                     

[] Quota support <=== 磁盘配额支持,限制某个用户或者某组用户的磁盘占用空间,暂时没这个需求,你可以把它编译成模块

< > Kernel automounter support

<*> Kernel automounter version 4 support (also supports v3)  <=== 我没有要挂载远程文件系统的需求

< > FUSE (Filesystem in Userspace) support

    Caches  ---> 

    CD-ROM/DVD Filesystems  ---> 

<> ISO 9660 CDROM file system support  <=== 在虚拟机内,我不用CDROM              

< > UDF file system support

    DOS/FAT/NT Filesystems  --->

< > MSDOS fs support <=== 我没有微软fs的设备

< > VFAT (Windows-95) fs support  <=== 我没有微软fs的设备

< > NTFS file system support

    Pseudo filesystems  ---> 

[] Miscellaneous filesystems  ---> <=== 如果你没有其他FS的支持需求,关

[] Network File Systems  ---> <=== 如果你没有其他NFS的支持需求,关

    Partition Types  --->    

[ ] Advanced partition selection <=== 如果不是和其他系统共存,可以不选

-*- Native language support  ---> // 选上Chinese

 

Kernel hacking  --->

[] Show timing information on printks  <=== printk的输出中包含时间信息,可以用来分析内核启动过程各步骤所用时间 , 我不需要debug内核

[ ] Enable __deprecated logic                         

[*] Enable __must_check logic                         

(2048) Warn for stack frames larger than (needs gcc 4.4)

[] Magic SysRq key <=== 一种通过快捷键控制系统方式,除非你非常清楚这个选项,官方不推荐选择

[ ] Enable unused/obsolete exported symbols           

-*- Debug Filesystem

[ ] Run 'make headers_check' when building vmlinux    

[] Kernel debugging <=== 内核调试,关                   

[ ] Enable SLUB performance statistics                                                                            

[] Compile the kernel with frame pointers  <=== 还是跟内核开发有关

[ ] Delay each boot printk message by N milliseconds  

< > torture tests for RCU                             

[ ] Check for stalled CPUs delaying RCU grace periods 

< > Self test for the backtrace code                  

[ ] Force extended block device numbers and spread them

[ ] Fault-injection framework                         

[ ] Latency measuring infrastructure                   

[*] Sysctl checks

[] Tracers  ---> <=== 内核跟踪分析器

[] Remote debugging over FireWire early on boot  <===启动过程中,允许远程调试内核

[ ] Enable dynamic printk() support

[ ] Enable debugging of DMA-API usage

[ ] Sample kernel code  --->                          

[ ] Filter access to /dev/mem

[] Enable verbose x86 bootup info messages <=== 在内核镜像解压缩阶段输出启动信息,关闭后相当于无声启动(Slient Bootup)

-*- Early printk 

[]   Early printk via EHCI debug port  <=== 允许printk通过EHCI调试端口输出内核日志,调试的一律关

[ ] Use 4Kb for kernel stacks instead of 8Kb

[ ] Enable IOMMU stress-test mode

    IO delay type (port 0x80 based port-IO delay [recommended])  --->  

[*] Allow gcc to uninline functions marked 'inline'

 

Security options  --->  <=== 安全特性,我选择全关,当然,这些选项不会影响你的日常开发,办公

[] Enable access key retention support <=== 关闭

[] Enable different security models <=== 关闭

[ ] Enable the securityfs filesystem

[] File POSIX Capabilities <=== 关闭

[ ] Integrity Measurement Architecture(IMA)

 

<*> Cryptographic API  ---> // 加密API,这部分选项会根据此前的优化自动调整,默认即可

[] Virtualization  ---> <=== 我的系统已经运行在虚拟机中,不需要再支持虚拟化

Library routines  ---> //库子程序,这部分选项会根据此前的优化自动调整,默认即可

ps:本文转自http://kenwublog.com/docs/linux-kernel-2-6-31-optimization.htm

夜空- 本站版权
1、本站所有主题由该文章作者发表,该文章作者与夜空享有文章相关版权
2、其他单位或个人使用、转载或引用本文时必须同时征得该文章作者和夜空的同意
3、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
4、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
5、原文链接:blog.slogra.com/post-227.html

标签: 优化 linux kernel 内核 编译 2.6内核

评论: