This fork tracks upstream closely and adds some spice on top.
Note
New to linux-tkg? Start with the upstream project README to get familiar with the general concept, the available options and the build workflow. Come back here once you know the basics.
Please do not report bugs to the upstream repository when using this fork.
All on top of what upstream already offers — knobs live in customization.cfg.
- Linux-tkg
- This fork tracks upstream closely and adds some spice on top.
- Extra knobs in
customization.cfg_nvidia_pkg— builds the open-source NVIDIA kernel modules_module_pkg— build third-party out-of-tree (e.g. motherboard chipset)_aggressive_glitched_base— aggressive MM/scheduler tuning defaults_aggressive_misc_adds— aggressive misc additions_aggressive_more_opts— CPU/scheduler misc optimizations_clang_polly— Clang Polly loop optimizer support_autofdo/_autofdo_profile_path— Clang AutoFDO_vanilla— build a pure vanilla kernel without any modifications_docs_pkg— split kernel documentation package_nvidia_sign— sign NVIDIA open modules_module_sign— out-of-tree module signing_RESIGN_AFTER_STRIP— re-sign all modules after stripping_install_signing_keys— keep signing key in headers package
- Install procedure
| Value | Description |
|---|---|
"false" |
Disable (skips prompt) |
"595.58.03" |
Default NVIDIA open driver version |
"595.44.05" |
Vulkan developer beta version |
"580.142" |
Legacy/LTS NVIDIA open driver version |
Examples:
_nvidia_pkg="595.44.05"
_nvidia_pkg="default"
_nvidia_pkg="vulkan"
_nvidia_pkg="latest"
_nvidia_pkg="false"Driver versions and supported kernels are pinned in linux-tkg-config/prepare. Numeric versions are the canonical config format; alias values are accepted for backward compatibility.
Examples:
# enable modules
_module_pkg="nct6687 v4l2loopback"
# disable all — skips prompt
_module_pkg="false"Builds selected out-of-tree kernel modules into the main kernel package at build time. Supported modules:
| Module | Chip / Controller | Description | Source |
|---|---|---|---|
nct6687 |
Nuvoton NCT6687-R (common on MSI & Gigabyte boards) | Hardware monitoring driver (fans, temps, voltages) | Fred78290/nct6687d |
it87 |
ITE IT8689E / IT8792E / IT87xx series (common on ASUS & ASRock boards) | Hardware monitoring driver (fans, temps, voltages) | frankcrawford/it87 |
v4l2loopback |
Virtual (no physical chip; kernel-level loopback) | Creates virtual video devices usable as webcam sources (e.g. OBS → Zoom) | v4l2loopback/v4l2loopback |
Companion options (all ignored when _module_pkg is empty):
| Option | Description |
|---|---|
_module_extpkg |
Package layout for Arch PKGBUILD builds: "internal" installs selected modules into the main kernel package, "external" creates one extra package per selected module. Empty defaults to "internal" when _module_pkg is set. Ignored when _module_pkg is empty. |
_module_autoload |
Space-separated subset of modules to autoload at boot via /usr/lib/modules-load.d/. v4l2loopback is autoloaded by default for compatibility. |
_module_options_<name> |
Per-module modprobe options written to /usr/lib/modprobe.d/. Available for nct6687, it87, and v4l2loopback. |
_module_git_<name> |
Pin a specific git ref (branch, tag, or commit) for a module, or set a full URL (https://… / git@…) to clone from a different fork entirely. Leave empty to use the default upstream repository at its default branch. |
Examples:
# Enable two modules
_module_pkg="nct6687 v4l2loopback"
# Keep module artifacts inside the main kernel package (default when _module_pkg is set)
_module_extpkg="internal"
# Autoload nct6687 at boot
_module_autoload="nct6687"
# modprobe options for nct6687 (space-separated, produces a single "options" line)
_module_options_nct6687="fan_config=msi_alt1 msi_fan_brute_force=1"
# Pin nct6687 to a specific commit
_module_git_nct6687="abc1234"
# Or switch to a completely different fork URL
_module_git_nct6687="https://github.com/otherfork/nct6687d.git"_aggressive_glitched_base=""Applies 0014-aggressive-glitched-base.patch: workingset protection ratios, extended readahead, adjusted writeback and dirty thresholds, scheduler base slice and migration cost tuning, hugepage compaction tweaks — all gated behind CONFIG_TKG. Targets reduced stuttering on some workloads by keeping more file caches in memory. Requires _glitched_base="true". Leave empty to be asked at build time.
_aggressive_misc_adds=""Applies 0014-aggressive-misc-additions.patch: may contain temporary fixes pending upstream or distro-specific compatibility fixes. Leave empty to be asked at build time.
_aggressive_more_opts=""Applies 0014-aggressive-more-opts.patch: reduces timer_slack_ns, avoids sched_move_task lock contention, removes schedutil dependency, disables split-lock mitigation. Most noticeable on high core-count CPUs. Leave empty to be asked at build time.
_clang_polly=""Applies 0014-clang-polly.patch when available, enabling LLVM Polly for additional loop optimizations at compile time. Only meaningful when building with _compiler="llvm". Leave empty to be asked at build time.
_autofdo=""
_autofdo_profile_path="~/.config/frogminer/kernel.afdo"Two-pass PGO-like optimization using CPU hardware branch sampling. Requires _compiler="llvm", kernel >= 6.11, and a CPU with LBR (Intel Haswell+) or (AMD Zen4+).
BUILD a profilable kernel
_autofdo="true"
_autofdo_profile_path="~/.config/frogminer/kernel.afdo"
build & install kernel, then boot into it
PROFILE COLLECTION
sudo echo 0 > /proc/sys/kernel/kptr_restrict
sudo echo 0 > /proc/sys/kernel/perf_event_paranoid
OR (via systemd):
sudo sysctl -w kernel.kptr_restrict=0
sudo sysctl -w kernel.perf_event_paranoid=0
Intel (LBR):
perf record -e BR_INST_RETIRED.NEAR_TAKEN:k -a -N -b -c 500009 -o \
kernel.data -- <workload>
AMD Zen4:
perf record --pfm-events RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c 500009 -o \
kernel.data -- <workload>
CONVERT perf data (.afdo profile)
mkdir -p ~/.config/frogminer
llvm-profgen --kernel --binary=/usr/lib/modules/<kver>/build/vmlinux \
--perfdata=kernel.data -o ~/.config/frogminer/kernel.afdo
Merge multiple profiles (optional):
llvm-profdata merge -o ~/.config/frogminer/kernel.afdo profile1.afdo profile2.afdo ...
SET _autofdo_profile_path to the .afdo file path, then rebuild the kernel.| Value | Description |
|---|---|
"false" |
Disable — normal TKG build (default) |
"true" |
Enable — build a stock kernel without any TKG patches or modifications |
Examples:
_vanilla="true"When enabled, all TKG-specific patches, config modifications and kernel config fragments (.myfrag) are skipped. The CPU scheduler is set to the kernel default without prompting, the compiler is forced to gcc, and the kernel is named -vanilla.
_docs_pkg="false"When set to "true", an extra ${pkgbase}-docs package is built on Arch PKGBUILD builds. It installs the kernel Documentation/ tree under /usr/lib/modules/<version>/build/Documentation and adds a symlink at /usr/share/doc/${pkgbase}.
These options below were added for personal testing and are left in for anyone who might find it useful.
_nvidia_sign="false"When set to "true", all nvidia*.ko files in the NVIDIA open modules package are signed using the kernel's module signing key after building.
Useful in combination with _RESIGN_AFTER_STRIP to prevent unsigned-module taint messages. Requires CONFIG_MODULE_SIG=y. Has no effect when _nvidia_pkg is "false" or empty.
_module_sign="false"When set to "true", all active out-of-tree modules are signed using the kernel's module signing key after building. Alternatively, pass a space-separated subset of module names to sign only those selectively. Requires CONFIG_MODULE_SIG=y. Has no effect when _module_pkg is empty.
_RESIGN_AFTER_STRIP="false"When set to "true", all .ko files are re-signed with the kernel's module signing key after stripping. Prevents "module verification failed" taint messages caused by INSTALL_MOD_STRIP=1 removing embedded signatures. Requires CONFIG_MODULE_SIG=y. Has no effect when _STRIP is not "true".
_install_signing_keys="false"When set to "true", the kernel module signing key and certificate are installed into the linux-headers package (useful for Secure Boot workflows or to prevent unsigned-module taint messages). Requires CONFIG_MODULE_SIG=y. Has no effect when is "false" or empty.
Warning
The key is stored unencrypted on disk. It is installed with permissions 400 (root-readable only), but anyone with root or physical access to the machine can extract it and sign arbitrary modules. If security is a concern, use full-disk encryption (e.g. LUKS) to protect the key against physical access.
Tip
Recommended: Use tkginstaller for an interactive guided build experience with fzf menus, automatic dependency handling, and config management.
# install tkginstaller (AUR)
yay -S tkginstaller-git
# Use fzf-finder TUI mode, simply run
tkginstaller
# Use direct command with package name, for example
tkginstaller linux # or shortcut l
tkginstaller linux-nvidia # or shortcut ln(Arch & derivatives)
git clone https://github.com/damachine/linux-tkg.git
cd linux-tkg
makepkg -si(Generic / Gentoo)
git clone https://github.com/damachine/linux-tkg.git
cd linux-tkg
./install.sh install
_module_pkgand its companion options should also work on Generic and Gentoo. Untested, use at your own risk.
install.shhas no effect when using on Debian, Ubuntu, Fedora.