Kernel Configuration Pseudo Guide
This aims to be a guide for configuring a Linux kernel for a modern
x86_64 machine containing hardware commonly found in laptops, desktops,
and other consumer computers. Note, this guide will sway more minimally,
meaning some features that are not strictly required will not be enabled.
All features will be built directly into kernel, no modules. This article
will not attempt to cover all possible configuration options, as it omits
entire sections that are not relevant on such systems, as well as some
hardware-specific configuration. Please also refer to the kernel's help text
for further information on respective options. I am not a kernel developer
and nothing here is guaranteed to be functionally accurate. If you feel
anything mentioned is wrong or should be switched around, please contact
me. This article assumes some prior knowledge of your system (eg. lspci,
lscpu, lsusb, dmidecode, /proc/devices
, etc.) and general
kernel configuration/installation, such as obtaining source, generating and
maintaining .config
, methods of configuration, compilation,
and installation. Throughout, the following acronyms will be used
- STD: recommended/standard feature that generally should be enabled
- DEV: useful for kernel development/debugging. not for general user
- VIRT: virtulalisation related options (vhost/vguest)
- OLD: modern systems generally won't need these options
- SEC: security related options that either implicate or strengthen system security
general setup
General setup
- Compile Also drivers which will not load (
CONFIG_COMPILE_TEST
): N, DEV
- Compile the kernel with warnings as errors (
CONFIG_WERROR
): Y, STD
- Local version - append to kernel release (
CONFIG_LOCALVERSION
): empty, useful for git bisect
- Automatically append version information (
CONFIG_LOCALVERSION_AUTO
): N, DEV
- Build ID Salt (
CONFIG_BUILD_SALT
): empty, SEC
- Kernel compression mode: ZSTD or Gzip for compatibility
- Default init path (
CONFIG_DEFAULT_INIT
): empty, EMB
- Default hostnam (
CONFIG_DEFAULT_HOSTNAME
): empty, entre your machine's name if you'd like
- System V IPC (
CONFIG_SYSVIPC
): Y, STD
- POSIX Message Queues (
CONFIG_POSIX_MQUEUE
): N, not strictly necessary
- General notification queue (
CONFIG_WATCH_QUEUE
): N, not strictly necessary
- Enable process_vm_readv/writev syscalls (
CONFIG_CROSS_MEMORY_ATTACH
): N, not strictly necessary
- uselib syscall (
CONFIG_USELIB
): N, OLD
- Auditing support (
CONFIG_AUDIT
): N, not strictly necessary
-
Timers subsystem
- Timer tick handling: Idle dynticks system (tickless idle)
- Old Idle dynticks config (
CONFIG_NO_HZ
): N, OLD
- High Resolution Timer Support (
CONFIG_HIGH_RES_TIMERS
): Y, STD
- Clocksource watchdog maximum allowable skew (
CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US
): 100
-
BPF subsystem
- Enable bpf() system call (
CONFIG_BPF_SYSCALL
): N, not necessary if you do not have any programs that utilise
- Preemption Model: Preemptible Kernel (Low-Latency Desktop)
- Preemption behaviour defined on boot (
CONFIG_PREEMPT_DYNAMIC
): N
- Core Scheduling for SMT (
CONFIG_SCHED_CORE
): Y, STD
-
CPU/Task time and stats accounting
- Cputime accounting: Simple tick based cputime accounting
- Ftine granularity task level IRQ time accounting (
CONFIG_IRQ_TIME_ACCOUNTING
): N, DEV
- BSD Process Accounting (
CONFIG_BSD_PROCESS_ACCT
): N
- Export task/process statistics through netlink (
CONFIG_TASKSTATS
): N
- Pressure stall information tracking (
CONFIG_PSI
): N
- CPU isolation (
CONFIG_CPU_ISOLATION
): N, EMB
-
RCU subsystem
- Make expert-level adjustments to RCU configuration (
CONFIG_RCU_EXPERT
): N, DEV
- Kernel .config support (
CONFIG_IKCONFIG
): Y, STD
- Enable access to .config through /proc/config.gz (
CONFIG_IKCONFIG_PROC
): Y, STD
- Enable kernel headers through /sys/kernel/kheaders.tar.xz (
CONFIG_IKHEADERS
): N
- Kernel log buffer size (
CONFIG_LOG_BUF_SHIFT
): 18
- CPU kernel log buffer size contribution (
CONFIG_LOG_CPU_MAX_BUF_SHIFT
): 12
-
Scheduler features
- Enable utilization clamping for RT/FAIR tasks (
CONFIG_UCLAMP_TASK
): N, DEV
-
Control Group support (
CONFIG_CGROUPS
): Y, STD
- Favor dynamic modification latency reduction (
CONFIG_CGROUP_FAVOR_DYNMODS
): N
- Memory controller (
CONFIG_MEMCG
): Y, STD
- IO controller (
CONFIG_BLK_CGROUP
): Y, STD
-
CPU controller (
CONFIG_CGROUP_SCHED
): Y, STD
- Group scheduling for SCHED_OTHER (
FAIR_GROUP_SCHED
): Y, STD
- CPU bandwidth provisioning for FAIR_GROUP_SCHED (
CONFIG_CFS_BANDWIDTH
): N
- Group scheduling for SCHED_RR/FIFO (
CONFIG_RT_GROUP_SCHED
): N
- PIDs controller (
CONFIG_CGROUP_PIDS
): N
- RDMA controller (
CONFIG_CGROUP_RDMA
): N
- Freezer controller (
CONFIG_CGROUP_FREEZER
): N
- Cpuset controller (
CONFIG_CPUSETS
): N, only useful on NUMA machine
- Device Controller (
CONFIG_CGROUP_DEVICE
): N
- Simple CPU accounting controller (
CONFIG_CGROUP_CPUACCT
): Y, STD
- Perf controller (
CONFIG_CGROUP_PERF
): N
- Misc resource controller (
CONFIG_CGROUP_MISC
): Y
- Debug controller (
CONFIG_CGROUP_DEBUG
): N, DEV
-
Namespaces support (
CONFIG_NAMESPACES
): Y, STD, used heavily by web browsers
- UTS namespace (
CONFIG_UTS_NS
): Y
- TIME namespace (
CONFIG_TIME_NS
): Y
- IPC namespace (
CONFIG_IPC_NS
): Y
- User namespace (
CONFIG_USER_NS
): Y
- PID Namespaces (
CONFIG_PID_NS
): Y
- Network namespace (
CONFIG_NET_NS
): Y
- Checkpoint/restore support (
CONFIG_CHECKPOINT_RESTORE
): N, VIRT
- Automatic process group scheduling (
CONFIG_SCHED_AUTOGROUP
): N, OLD, Systemd/OpenRC handle this
- Kernel -> userspace relay support (
CONFIG_RELAY
): Y, STD
- Initial RAM filesystem and RAM disk (
CONFIG_BLK_DEV_INITRD
): N, not strictly necessary
- Boot config support (
CONFIG_BOOT_CONFIG
): N, EMB
- Preserve cpio archive mtimes in initramfs (
CONFIG_INITRAMFS_PRESERVE_MTIME
): N, without initramfs...
- Compiler optimization level: Optimize for performance (-O2)
- Configure standard kernel features (
CONFIG_EXPERT
): N, DEV/EMB, mostly syscalls
- Enable kcmp() system call (
CONFIG_KCMP
): Y
- Enable rseq() system call (
CONFIG_RSEQ
): Y
- Enable cachestat() system call (
CONFIG_CACHESTAT_SYSCALL
): Y
- Enabled debugging of rseq() system call (
CONFIG_DEBUG_RSEQ
): N, DEV
- PC/104 support (
CONFIG_PC104
): N, EMB
-
Kernel Performance Events and Counters
- Kernel Performance events and counters (
CONFIG_PERF_EVENTS
): Y, STD
- Debug: use vmalloc to back perf mmap() buffers (
CONFIG_DEBUG_PERF_USE_VMALLOC
): N, DEV
- Profiling support (
CONFIG_PROFILING
): N, DEV
- Kexec and crash features: None
This is a WIP...