Linux内核编译记录

2017-04-13
2分钟阅读时长

Gentoo Linux — >

Gentoo 选项

[*] Gentoo Linux support
[*]   Linux dynamic and persistent device naming (userspace devfs) support
[*]   Select options required by Portage features

Support for init systems, system and service managers —>

选择 OpenRC 或者 systemd

[*] OpenRC, runit and other script based systems and managers
[ ] systemd

[*] 64-bit kernel

General setup —>

默认 /etc/issue 输出大概是这样

This is ${HOSTNAME}.(kugui/Gentoo) Linux x86_64 ${VERSION}-sirat

其中 ${HOSTNAME}/etc/conf.d/hostname 中定义 ${VERSION} 为 内核的版本号, 形式类似 4.9.16-gentoo

()  Cross-compiler tool prefix
[ ] Compile also drivers which will not load
(-sirat) Local version - append to kernel release
[*] Automatically append version information to the version string
Kernel compression mode (Gzip)  --->
((kugui/Gentoo)) Default hostname
[*] Support for paging of anonymous memory (swap)
-*- System V IPC
[*] POSIX Message Queues
[*] Enable process_vm_readv/writev syscalls
[] uselib syscall
[*] Auditing support

IRQ subsystem —>

[ ] Expose hardware/virtual IRQ mapping via debugfs

Timers subsystem —>

Timer tick handling (Idle dynticks system (tickless idle))  --->
  ( ) Periodic timer ticks (constant rate, no dynticks)
  强制按照频率触发时钟中断
  (X) Idle dynticks system (tickless idle)
  空闲时间不产生不必要的时钟中断
  ( ) Full dynticks system (tickless)
  尽可能不产生中断(使用与单任务)
[ ] Old Idle dynticks config
[*] High Resolution Timer Support

CPU/Task time and stats accounting —>

Cputime accounting (Simple tick based cputime accounting)  --->
[ ] Fine granularity task level IRQ time accounting
[ ] BSD Process Accounting
[*] Export task/process statistics through netlink
[*]   Enable per-task delay accounting
[ ]   Enable extended accounting over taskstats

RCU Subsystem —>

[ ] Make expert-level adjustments to RCU configuration
< > Kernel .config support
(18) Kernel log buffer size (16 => 64KB, 17 => 128KB)
内核日志缓冲区长度 (dmesg 的最大长度)
(12) CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)
(13) Temporary per-CPU NMI log buffer size (12 => 4KB, 13 => 8KB)
[ ] Memory placement aware NUMA scheduler

-*- Control Group support —>

-*- Namespaces support —>

[ ] Automatic process group scheduling
[ ] Enable deprecated sysfs features to support old userspace tools
-*- Kernel->user space relay support (formerly relayfs)
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
()    Initramfs source file(s)
[*]   Support initial ramdisks compressed using gzip
[ ]   Support initial ramdisks compressed using bzip2
[ ]   Support initial ramdisks compressed using LZMA
[ ]   Support initial ramdisks compressed using XZ
[ ]   Support initial ramdisks compressed using LZO
[ ]   Support initial ramdisks compressed using LZ4
Compiler optimization level (Optimize for performance)  --->
[ ] Configure standard kernel features (expert users)  ----
[ ] Enable bpf() system call
[ ] Enable userfaultfd() system call
[ ] Embedded system

Kernel Performance Events And Counters —>

[ ] Disable heap randomization
Choose SLAB allocator (SLUB (Unqueued Allocator))  --->
[ ] SLAB freelist randomization
[*] SLUB per cpu partial cache
[ ] Profiling support
[ ] Kprobes
[*] Optimize very unlikely/likely branches
[ ]   Static key selftest
[ ] GCC plugins  ----
Stack Protector buffer overflow detection (Strong)  --->
  • Regular 需要 gcc-4.2 以上
  • Strong 需要 gcc-4.9 以上
  • -fstack-protector-all
[*] Use a virtually-mapped stack

GCOV-based kernel profiling —>

ntfs 不需要内核支持(emerge ntfs3g, 需要FUSE_FS)

File systems
[*] FUSE Support

编译安装内核

make && make modules_install
make install