linux/Documentation/process
Lorenzo Stoakes (ARM) 48ebe1cbbe
kbuild: compress the kernel with pigz if available
The gzip step of a kernel build is very lengthy, especially for larger
builds such as allmodconfig.

gzip itself cannot be run in parallel, however an alternative tool exists
that can, providing the same feature set as gzip itself - pigz - which
works as a drop-in replacement.

On a 128-core Threadripper, gzip -9 of a 36 MiB x86-64 vmlinux.bin takes
1.6s, and with pigz it takes 0.09s, so the performance increase is
significant.

Therefore introduce the KPGZIP build variable which specifies the
compressor to use for the kernel image and default it to pigz if available,
or KGZIP otherwise (which itself defaults to gzip).

Modules, packaging and the embedded kernel configuration (CONFIG_IKCONFIG)
continue to use KGZIP which defaults to a single-threaded gzip instance.

Module compression is run in parallel by make, so pigz offers no benefit
there, packaging sits outside the build and the embedded configuration is
too small to matter.

pigz is executed using scripts/jobserver-exec, which reserves the job slots
make has free - necessary, as otherwise pigz would just grab unbounded
CPUs.

The kernel image compression step is always performed at the end of the
build so should typically have all job slots available.

pigz always provides byte-for-byte identical output across runs regardless
of thread count, but pigz and gzip are not guaranteed to generate the same
binary output, so reproducible builds must use the same tools consistently.

Also update Documentation/kbuild/kbuild.rst to describe KPGZIP and
Documentation/process/changes.rst to list the optional pigz dependency.

While there, add entries for the other compressor programs.

Finally, update scripts/ver_linux to include the pigz version there.

Every x86 build ends with the compression of vmlinux.bin, 36MB for
defconfig and over 200MB for allmodconfig, no-op builds are unchanged.

Whole build, 128-thread Threadripper 9980X, best of N runs:

                                         before   after     delta
                                         -------------------------------
  x86 defconfig, touch mm/vma.c, gcc        7.7s     6.0s     -1.7s (-22%)
  x86 defconfig, touch mm/vma.c, clang      6.9s     5.4s     -1.5s (-21%)
  x86 defconfig, clean, gcc                28.2s    26.3s     -1.8s (-6%)
  x86 defconfig, clean, clang              28.7s    27.2s     -1.5s (-5%)
  x86 allmodconfig, touch mm/vma.c, gcc    23.7s    15.4s     -8.3s (-35%)
  x86 allmodconfig, touch mm/vma.c, clang  22.5s    15.6s     -7.0s (-31%)
  x86 allmodconfig, clean, gcc            294.1s   278.6s     -15.5s (-5%)
  x86 allmodconfig, clean, clang          283.9s   266.8s     -17.1s (-6%)

Suggested-by: Kees Cook <kees@kernel.org>
Link: https://zlib.net/pigz/
Assisted-by: LLM
Reviewed-by: Manuel Ebner <manuelebnerli@mailbox.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Link: https://patch.msgid.link/20260923-build-speedup-v4-22-73128809a4a4@kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-09-26 00:16:36 +01:00
..
debugging docs: kgdb: Fix path of driver options 2026-06-23 14:35:50 -06:00
1.Intro.rst Doc: correct spelling and wording mistakes 2026-01-06 14:39:58 -07:00
2.Process.rst linux-next: update maintainer info. 2026-02-23 14:36:11 -07:00
3.Early-stage.rst
4.Coding.rst coccinelle: update Coccinelle website URL 2026-08-23 22:12:10 +02:00
5.Posting.rst doc: development-process: add notice on testing 2026-02-02 10:02:05 -07:00
6.Followthrough.rst docs: remove the tips on how to submit patches from MAINTAINERS 2023-07-03 08:35:23 -06:00
7.AdvancedTopics.rst Doc: correct spelling and wording mistakes 2026-01-06 14:39:58 -07:00
8.Conclusion.rst
adding-syscalls.rst docs: fix 're-use' -> 'reuse' in documentation 2026-02-02 09:54:15 -07:00
applying-patches.rst
backporting.rst Documentation: process: backporting: fix missing subject 2026-03-03 10:24:17 -07:00
botching-up-ioctls.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
changes.rst kbuild: compress the kernel with pigz if available 2026-09-26 00:16:36 +01:00
code-of-conduct-interpretation.rst Documentation/CoC: Spell out the TAB role in enforcement decisions 2025-03-12 16:31:48 -06:00
code-of-conduct.rst
coding-assistants.rst It has been a not-too-busy cycle for docs; here's the highlights: 2026-08-20 10:31:50 -07:00
coding-style.rst Documentation: Fix syntax of kmalloc_objs example in coding style doc 2026-06-01 12:48:20 -06:00
conclave.rst Documentation: Project continuity 2026-01-24 16:16:47 -08:00
contribution-maturity-model.rst
cve.rst Documentation: Document the Linux Kernel CVE process 2024-02-17 14:46:39 +01:00
deprecated.rst string: Remove strncpy() from the kernel 2026-06-18 16:39:31 -07:00
development-process.rst docs: use toctree :caption: and move introduction 2023-11-17 13:05:26 -07:00
email-clients.rst docs: process: email-client: add Thunderbird "Toggle Line Wrap" extension 2026-01-06 14:38:28 -07:00
embargoed-hardware-issues.rst MAINTAINERS: update ndesaulniers 2026-07-06 15:49:29 -07:00
generated-content.rst docs: link AI coding assistants and tool-generated content pages 2026-07-22 14:36:03 -06:00
handling-regressions.rst docs: handling-regressions: add, trim, and sort quotes from Linus 2026-03-03 11:11:01 -07:00
howto.rst Documentation: fix links to mailing list services 2024-07-03 16:52:54 -06:00
index.rst Documentation: security-bugs: explain what is and is not a security bug 2026-05-12 11:09:14 -06:00
kernel-docs.rst kernel-docs: Add book to process/kernel-docs.rst 2025-02-18 13:24:01 -07:00
kernel-driver-statement.rst
kernel-enforcement-statement.rst
license-rules.rst LICENSES: Explicitly allow SPDX-FileCopyrightText 2026-03-20 11:42:50 +01:00
maintainer-devicetree.rst docs: dt: maintainer: Add Devicetree and OF maintainer profile document 2026-08-07 09:38:47 -05:00
maintainer-handbooks.rst docs: maintainers_include: Only show main entry for profiles 2026-05-03 09:24:30 -06:00
maintainer-kvm-x86.rst Documentation/process: Add a maintainer handbook for KVM x86 2023-06-22 14:25:38 -07:00
maintainer-netdev.rst docs: netdev: clarify expected interactions with LLMs 2026-07-27 18:03:26 -07:00
maintainer-pgp-guide.rst docs: maintainer-pgp-guide.rst: add a reference for kernel.org sign 2026-02-27 06:34:06 +01:00
maintainer-soc-clean-dts.rst docs: process: maintainer-soc-clean-dts: linux-next is decisive 2025-02-26 13:15:57 -06:00
maintainer-soc.rst Documentation/process: maintainer-soc: Mention expectation about dt-check-style 2026-08-10 11:25:09 +02:00
maintainer-tip.rst Documentation/maintainer-tip: Fix grammar 2026-03-03 09:59:23 -07:00
maintainers.rst docs: maintainers: add SPDX license to the file 2026-05-03 09:24:30 -06:00
management-style.rst
programming-language.rst A handful of small, late-arriving documentation fixes. 2026-02-15 10:47:59 -08:00
researcher-guidelines.rst Documentation: update mailing list addresses 2024-02-21 13:44:21 -07:00
security-bugs.rst docs: security-bugs: clarify some mandatory steps for AI reports 2026-08-04 16:24:50 +02:00
stable-api-nonsense.rst
stable-kernel-rules.rst docs: stable-kernel-rules: fix typo sent->send 2024-05-02 10:20:27 -06:00
submit-checklist.rst docs/.../submit-checklist: Use Documentation/admin-guide/abi.rst for cross-ref of README 2025-03-12 16:41:56 -06:00
submitting-patches.rst docs: submitting-patches: Fix section structure around DCO 2026-07-15 10:51:28 -06:00
threat-model.rst A handful of late-arriving fixes, a Japanese translation that was ready 2026-08-26 09:25:12 -07:00
volatile-considered-harmful.rst