Troubleshooting and recovery
Single-page view · as markdown
Bisecting a regression
Peios Kernel / Administration / System administration / Troubleshooting and recovery
This document describes how to use a git bisect to find the source code change that broke something -- for example when some functionality stopped working after upgrading from Linux 6.0 to 6.1.
The text focuses on the gist of the process. If you are new to bisecting the kernel, better follow Documentation/admin-guide/verify-bugs-and-bisect-regressions.rst instead: it depicts everything from start to finish while covering multiple aspects even kernel developers occasionally forget. This includes detecting situations early where a bisection would be a waste of time, as nobody would care about the result -- for example, because the problem happens after the kernel marked itself as 'tainted', occurs in an abandoned version, was already fixed, or is caused by a .config change you or your Linux distributor performed.
Finding the change causing a kernel issue using a bisection #
Note: the following process assumes you prepared everything for a bisection. This includes having a Git clone with the appropriate sources, installing the software required to build and install kernels, as well as a .config file stored in a safe place (the following example assumes '~/prepared_kernel_.config') to use as pristine base at each bisection step; ideally, you have also worked out a fully reliable and straight-forward way to reproduce the regression, too.
-
Preparation: start the bisection and tell Git about the points in the history you consider to be working and broken, which Git calls 'good' and 'bad':
git bisect start git bisect good v6.0 git bisect bad v6.1Instead of Git tags like 'v6.0' and 'v6.1' you can specify commit-ids, too.
-
Copy your prepared .config into the build directory and adjust it to the needs of the codebase Git checked out for testing:
cp ~/prepared_kernel_.config .config make olddefconfig -
Now build, install, and boot a kernel. This might fail for unrelated reasons, for example, when a compile error happens at the current stage of the bisection a later change resolves. In such cases run
git bisect skipand go back to step 1. -
Check if the functionality that regressed works in the kernel you just built.
If it works, execute:
git bisect goodIf it is broken, run:
git bisect badNote, getting this wrong just once will send the rest of the bisection totally off course. To prevent having to start anew later you thus want to ensure what you tell Git is correct; it is thus often wise to spend a few minutes more on testing in case your reproducer is unreliable.
After issuing one of these two commands, Git will usually check out another bisection point and print something like 'Bisecting: 675 revisions left to test after this (roughly 10 steps)'. In that case go back to step 1.
If Git instead prints something like 'cafecaca0c0dacafecaca0c0dacafecaca0c0da is the first bad commit', then you have finished the bisection. In that case move to the next point below. Note, right after displaying that line Git will show some details about the culprit including its patch description; this can easily fill your terminal, so you might need to scroll up to see the message mentioning the culprit's commit-id.
In case you missed Git's output, you can always run
git bisect logto print the status: it will show how many steps remain or mention the result of the bisection.
-
Recommended complementary task: put the bisection log and the current .config file aside for the bug report; furthermore tell Git to reset the sources to the state before the bisection:
git bisect log > ~/bisection-log cp .config ~/bisection-config-culprit git bisect reset -
Recommended optional task: try reverting the culprit on top of the latest codebase and check if that fixes your bug; if that is the case, it validates the bisection and enables developers to resolve the regression through a revert.
To try this, update your clone and check out latest mainline. Then tell Git to revert the change by specifying its commit-id:
git revert --no-edit cafec0cacaca0Git might reject this, for example when the bisection landed on a merge commit. In that case, abandon the attempt. Do the same, if Git fails to revert the culprit on its own because later changes depend on it -- at least unless you bisected a stable or longterm kernel series, in which case you want to check out its latest codebase and try a revert there.
If a revert succeeds, build and test another kernel to check if reverting resolved your regression.
With that the process is complete. Now report the regression as described by Documentation/admin-guide/reporting-issues.rst.
Bisecting linux-next #
If you face a problem only happening in linux-next, bisect between the linux-next branches 'stable' and 'master'. The following commands will start the process for a linux-next tree you added as a remote called 'next':
git bisect start
git bisect good next/stable
git bisect bad next/master
The 'stable' branch refers to the state of linux-mainline that the current linux-next release (found in the 'master' branch) is based on -- the former thus should be free of any problems that show up in -next, but not in Linus' tree.
This will bisect across a wide range of changes, some of which you might have used in earlier linux-next releases without problems. Sadly there is no simple way to avoid checking them: bisecting from one linux-next release to a later one (say between 'next-20241020' and 'next-20241021') is impossible, as they share no common history.
Additional reading material #
-
The man page for 'git bisect' and fighting regressions with 'git bisect' in the Git documentation.
-
Working with git bisect from kernel developer Nathan Chancellor.
-
Using Git bisect to figure out when brokenness was introduced.
Bug hunting
Peios Kernel / Administration / System administration / Troubleshooting and recovery
Kernel bug reports often come with a stack dump like the one below:
------------[ cut here ]------------
WARNING: CPU: 1 PID: 28102 at kernel/module.c:1108 module_put+0x57/0x70
Modules linked in: dvb_usb_gp8psk(-) dvb_usb dvb_core nvidia_drm(PO) nvidia_modeset(PO) snd_hda_codec_hdmi snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_timer snd soundcore nvidia(PO) [last unloaded: rc_core]
CPU: 1 PID: 28102 Comm: rmmod Tainted: P WC O 4.8.4-build.1 #1
Hardware name: MSI MS-7309/MS-7309, BIOS V1.12 02/23/2009
00000000 c12ba080 00000000 00000000 c103ed6a c1616014 00000001 00006dc6
c1615862 00000454 c109e8a7 c109e8a7 00000009 ffffffff 00000000 f13f6a10
f5f5a600 c103ee33 00000009 00000000 00000000 c109e8a7 f80ca4d0 c109f617
Call Trace:
[<c12ba080>] ? dump_stack+0x44/0x64
[<c103ed6a>] ? __warn+0xfa/0x120
[<c109e8a7>] ? module_put+0x57/0x70
[<c109e8a7>] ? module_put+0x57/0x70
[<c103ee33>] ? warn_slowpath_null+0x23/0x30
[<c109e8a7>] ? module_put+0x57/0x70
[<f80ca4d0>] ? gp8psk_fe_set_frontend+0x460/0x460 [dvb_usb_gp8psk]
[<c109f617>] ? symbol_put_addr+0x27/0x50
[<f80bc9ca>] ? dvb_usb_adapter_frontend_exit+0x3a/0x70 [dvb_usb]
[<f80bb3bf>] ? dvb_usb_exit+0x2f/0xd0 [dvb_usb]
[<c13d03bc>] ? usb_disable_endpoint+0x7c/0xb0
[<f80bb48a>] ? dvb_usb_device_exit+0x2a/0x50 [dvb_usb]
[<c13d2882>] ? usb_unbind_interface+0x62/0x250
[<c136b514>] ? __pm_runtime_idle+0x44/0x70
[<c13620d8>] ? __device_release_driver+0x78/0x120
[<c1362907>] ? driver_detach+0x87/0x90
[<c1361c48>] ? bus_remove_driver+0x38/0x90
[<c13d1c18>] ? usb_deregister+0x58/0xb0
[<c109fbb0>] ? SyS_delete_module+0x130/0x1f0
[<c1055654>] ? task_work_run+0x64/0x80
[<c1000fa5>] ? exit_to_usermode_loop+0x85/0x90
[<c10013f0>] ? do_fast_syscall_32+0x80/0x130
[<c1549f43>] ? sysenter_past_esp+0x40/0x6a
---[ end trace 6ebc60ef3981792f ]---
Such stack traces provide enough information to identify the line inside the Kernel's source code where the bug happened. Depending on the severity of the issue, it may also contain the word Oops, as on this one:
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<c06969d4>] iret_exc+0x7d0/0xa59
*pdpt = 000000002258a001 *pde = 0000000000000000
Oops: 0002 [#1] PREEMPT SMP
...
Despite being an Oops or some other sort of stack trace, the offended line is usually required to identify and handle the bug. Along this chapter, we'll refer to "Oops" for all kinds of stack traces that need to be analyzed.
If the kernel is compiled with CONFIG_DEBUG_INFO, you can enhance the quality of the stack trace by using scripts/decode_stacktrace.sh.
Modules linked in #
Modules that are tainted or are being loaded or unloaded are marked with "(...)", where the taint flags are described in Documentation/admin-guide/tainted-kernels.rst, "being loaded" is annotated with "+", and "being unloaded" is annotated with "-".
Where is the Oops message is located? #
Normally the Oops text is read from the kernel buffers by klogd and handed to syslogd which writes it to a syslog file, typically /var/log/messages (depends on /etc/syslog.conf). On systems with systemd, it may also be stored by the journald daemon, and accessed by running journalctl command.
Sometimes klogd dies, in which case you can run dmesg > file to read the data from the kernel buffers and save it. Or you can cat /proc/kmsg > file, however you have to break in to stop the transfer, since kmsg is a "never ending file".
If the machine has crashed so badly that you cannot enter commands or the disk is not available then you have three options:
-
Hand copy the text from the screen and type it in after the machine has restarted. Messy but it is the only option if you have not planned for a crash. Alternatively, you can take a picture of the screen with a digital camera - not nice, but better than nothing. If the messages scroll off the top of the console, you may find that booting with a higher resolution (e.g.,
vga=791) will allow you to read more of the text. (Caveat: This needsvesafb, so won't help for 'early' oopses.) -
Boot with a serial console (see Documentation/admin-guide/serial-console.rst), run a null modem to a second machine and capture the output there using your favourite communication program. Minicom works well.
-
Use Kdump (see Documentation/admin-guide/kdump/kdump.rst), extract the kernel ring buffer from old memory with using dmesg gdbmacro in Documentation/admin-guide/kdump/gdbmacros.txt.
Finding the bug's location #
Reporting a bug works best if you point the location of the bug at the Kernel source file. There are two methods for doing that. Usually, using gdb is easier, but the Kernel should be pre-compiled with debug info.
gdb #
The GNU debugger (gdb) is the best way to figure out the exact file and line number of the OOPS from the vmlinux file.
The usage of gdb works best on a kernel compiled with CONFIG_DEBUG_INFO. This can be set by running:
$ ./scripts/config -d COMPILE_TEST -e DEBUG_KERNEL -e DEBUG_INFO
On a kernel compiled with CONFIG_DEBUG_INFO, you can simply copy the EIP value from the OOPS:
EIP: 0060:[<c021e50e>] Not tainted VLI
And use GDB to translate that to human-readable form:
$ gdb vmlinux
(gdb) l *0xc021e50e
If you don't have CONFIG_DEBUG_INFO enabled, you use the function offset from the OOPS:
EIP is at vt_ioctl+0xda8/0x1482
And recompile the kernel with CONFIG_DEBUG_INFO enabled:
$ ./scripts/config -d COMPILE_TEST -e DEBUG_KERNEL -e DEBUG_INFO
$ make vmlinux
$ gdb vmlinux
(gdb) l *vt_ioctl+0xda8
0x1888 is in vt_ioctl (drivers/tty/vt/vt_ioctl.c:293).
288 {
289 struct vc_data *vc = NULL;
290 int ret = 0;
291
292 console_lock();
293 if (VT_BUSY(vc_num))
294 ret = -EBUSY;
295 else if (vc_num)
296 vc = vc_deallocate(vc_num);
297 console_unlock();
or, if you want to be more verbose:
(gdb) p vt_ioctl
$1 = {int (struct tty_struct *, unsigned int, unsigned long)} 0xae0 <vt_ioctl>
(gdb) l *0xae0+0xda8
You could, instead, use the object file:
$ make drivers/tty/
$ gdb drivers/tty/vt/vt_ioctl.o
(gdb) l *vt_ioctl+0xda8
If you have a call trace, such as:
Call Trace:
[<ffffffff8802c8e9>] :jbd:log_wait_commit+0xa3/0xf5
[<ffffffff810482d9>] autoremove_wake_function+0x0/0x2e
[<ffffffff8802770b>] :jbd:journal_stop+0x1be/0x1ee
...
this shows the problem likely is in the :jbd: module. You can load that module in gdb and list the relevant code:
$ gdb fs/jbd/jbd.ko
(gdb) l *log_wait_commit+0xa3
objdump #
To debug a kernel, use objdump and look for the hex offset from the crash output to find the valid line of code/assembler. Without debug symbols, you will see the assembler code for the routine shown, but if your kernel has debug symbols the C code will also be available. (Debug symbols can be enabled in the kernel hacking menu of the menu configuration.) For example:
$ objdump -r -S -l --disassemble net/ipv4/tcp.o
If you don't have access to the source code you can still debug some crash dumps using the following method (example crash dump output as shown by Dave Miller):
EIP is at +0x14/0x4c0
...
Code: 44 24 04 e8 6f 05 00 00 e9 e8 fe ff ff 8d 76 00 8d bc 27 00 00
00 00 55 57 56 53 81 ec bc 00 00 00 8b ac 24 d0 00 00 00 8b 5d 08
<8b> 83 3c 01 00 00 89 44 24 14 8b 45 28 85 c0 89 44 24 18 0f 85
Put the bytes into a "foo.s" file like this:
.text
.globl foo
foo:
.byte .... /* bytes from Code: part of OOPS dump */
Compile it with "gcc -c -o foo.o foo.s" then look at the output of
"objdump --disassemble foo.o".
Output:
ip_queue_xmit:
push %ebp
push %edi
push %esi
push %ebx
sub $0xbc, %esp
mov 0xd0(%esp), %ebp ! %ebp = arg0 (skb)
mov 0x8(%ebp), %ebx ! %ebx = skb->sk
mov 0x13c(%ebx), %eax ! %eax = inet_sk(sk)->opt
scripts/decodecode can be used to automate most of this, depending on what CPU architecture is being debugged.
Reporting the bug #
Once you find where the bug happened, by inspecting its location, you could either try to fix it yourself or report it upstream.
In order to report it upstream, you should identify the bug tracker, if any, or mailing list used for the development of the affected code. This can be done by using the get_maintainer.pl script.
For example, if you find a bug at the gspca's sonixj.c file, you can get its maintainers with:
$ ./scripts/get_maintainer.pl --bug -f drivers/media/usb/gspca/sonixj.c
Hans Verkuil <hverkuil@kernel.org> (odd fixer:GSPCA USB WEBCAM DRIVER,commit_signer:1/1=100%)
Mauro Carvalho Chehab <mchehab@kernel.org> (maintainer:MEDIA INPUT INFRASTRUCTURE (V4L/DVB),commit_signer:1/1=100%)
Tejun Heo <tj@kernel.org> (commit_signer:1/1=100%)
Bhaktipriya Shridhar <bhaktipriya96@gmail.com> (commit_signer:1/1=100%,authored:1/1=100%,added_lines:4/4=100%,removed_lines:9/9=100%)
linux-media@vger.kernel.org (open list:GSPCA USB WEBCAM DRIVER)
linux-kernel@vger.kernel.org (open list)
Please notice that it will point to:
-
The last developers that touched the source code (if this is done inside a git tree). On the above example, Tejun and Bhaktipriya (in this specific case, none really involved on the development of this file);
-
The driver maintainer (Hans Verkuil);
-
The subsystem maintainer (Mauro Carvalho Chehab);
-
The driver and/or subsystem mailing list (linux-media@vger.kernel.org);
-
The Linux Kernel mailing list (linux-kernel@vger.kernel.org);
-
The bug reporting URIs for the driver/subsystem (none in the above example).
If the listing contains bug reporting URIs at the end, please prefer them over email. Otherwise, please report bugs to the mailing list used for the development of the code (linux-media ML) copying the driver maintainer (Hans).
If you are totally stumped as to whom to send the report, and get_maintainer.pl didn't provide you anything useful, send it to linux-kernel@vger.kernel.org.
Thanks for your help in making Linux as stable as humanly possible.
Fixing the bug #
If you know programming, you could help us by not only reporting the bug, but also providing us with a solution. After all, open source is about sharing what you do and don't you want to be recognised for your genius?
If you decide to take this way, once you have worked out a fix please submit it upstream.
Please do read Documentation/process/submitting-patches.rst though to help your code get accepted.
Notes on Oops tracing with klogd #
In order to help Linus and the other kernel developers there has been substantial support incorporated into klogd for processing protection faults. In order to have full support for address resolution at least version 1.3-pl3 of the sysklogd package should be used.
When a protection fault occurs the klogd daemon automatically translates important addresses in the kernel log messages to their symbolic equivalents. This translated kernel message is then forwarded through whatever reporting mechanism klogd is using. The protection fault message can be simply cut out of the message files and forwarded to the kernel developers.
Two types of address resolution are performed by klogd. The first is static translation and the second is dynamic translation. Static translation uses the System.map file. In order to do static translation the klogd daemon must be able to find a system map file at daemon initialization time. See the klogd man page for information on how klogd searches for map files.
Dynamic address translation is important when kernel loadable modules are being used. Since memory for kernel modules is allocated from the kernel's dynamic memory pools there are no fixed locations for either the start of the module or for functions and symbols in the module.
The kernel supports system calls which allow a program to determine which modules are loaded and their location in memory. Using these system calls the klogd daemon builds a symbol table which can be used to debug a protection fault which occurs in a loadable kernel module.
At the very minimum klogd will provide the name of the module which generated the protection fault. There may be additional symbolic information available if the developer of the loadable module chose to export symbol information from the module.
Since the kernel module environment can be dynamic there must be a mechanism for notifying the klogd daemon when a change in module environment occurs. There are command line options available which allow klogd to signal the currently executing daemon that symbol information should be refreshed. See the klogd manual page for more information.
A patch is included with the sysklogd distribution which modifies the modules-2.0.0 package to automatically signal klogd whenever a module is loaded or unloaded. Applying this patch provides essentially seamless support for debugging protection faults which occur with kernel loadable modules.
The following is an example of a protection fault in a loadable module processed by klogd:
Aug 29 09:51:01 blizard kernel: Unable to handle kernel paging request at virtual address f15e97cc
Aug 29 09:51:01 blizard kernel: current->tss.cr3 = 0062d000, %cr3 = 0062d000
Aug 29 09:51:01 blizard kernel: *pde = 00000000
Aug 29 09:51:01 blizard kernel: Oops: 0002
Aug 29 09:51:01 blizard kernel: CPU: 0
Aug 29 09:51:01 blizard kernel: EIP: 0010:[oops:_oops+16/3868]
Aug 29 09:51:01 blizard kernel: EFLAGS: 00010212
Aug 29 09:51:01 blizard kernel: eax: 315e97cc ebx: 003a6f80 ecx: 001be77b edx: 00237c0c
Aug 29 09:51:01 blizard kernel: esi: 00000000 edi: bffffdb3 ebp: 00589f90 esp: 00589f8c
Aug 29 09:51:01 blizard kernel: ds: 0018 es: 0018 fs: 002b gs: 002b ss: 0018
Aug 29 09:51:01 blizard kernel: Process oops_test (pid: 3374, process nr: 21, stackpage=00589000)
Aug 29 09:51:01 blizard kernel: Stack: 315e97cc 00589f98 0100b0b4 bffffed4 0012e38e 00240c64 003a6f80 00000001
Aug 29 09:51:01 blizard kernel: 00000000 00237810 bfffff00 0010a7fa 00000003 00000001 00000000 bfffff00
Aug 29 09:51:01 blizard kernel: bffffdb3 bffffed4 ffffffda 0000002b 0007002b 0000002b 0000002b 00000036
Aug 29 09:51:01 blizard kernel: Call Trace: [oops:_oops_ioctl+48/80] [_sys_ioctl+254/272] [_system_call+82/128]
Aug 29 09:51:01 blizard kernel: Code: c7 00 05 00 00 00 eb 08 90 90 90 90 90 90 90 90 89 ec 5d c3
Clearing WARN_ONCE
Peios Kernel / Administration / System administration / Troubleshooting and recovery
WARN_ONCE / WARN_ON_ONCE / printk_once only emit a message once.
echo 1 > /sys/kernel/debug/clear_warn_once
clears the state and allows the warnings to print once again. This can be useful after test suite runs to reproduce problems.
Dynamic debug
Peios Kernel / Administration / System administration / Troubleshooting and recovery
Peios: References to Unix root and file modes below describe the inherited interface conventions. They are not sufficient Peios authorization: native descriptor/handle checks, the separate sysfs write gate, and mapped native privileges apply as appropriate. Debugfs additionally remains subject to integrity lockdown. See Peios kernel behaviour.
Introduction #
Dynamic debug allows you to dynamically enable/disable kernel debug-print code to obtain additional kernel information.
If /proc/dynamic_debug/control exists, your kernel has dynamic debug. Access requires authorization for that control interface; Unix UID 0 alone is not a Peios authority grant. The debugfs route also remains subject to lockdown.
Dynamic debug provides:
a Catalog of all prdbgs in your kernel.
cat /proc/dynamic_debug/controlto see them.a Simple query/command language to alter prdbgs by selecting on any combination of 0 or 1 of:
source filename
function name
line number (including ranges of line numbers)
module name
format string
class name (as known/declared by each module)
NOTE: To actually get the debug-print output on the console, you may need to adjust the kernel loglevel=, or use ignore_loglevel. Read about these kernel parameters in Documentation/admin-guide/kernel-parameters.rst.
Viewing Dynamic Debug Behaviour #
You can view the currently configured behaviour in the prdbg catalog:
:#> head -n7 /proc/dynamic_debug/control
# filename:lineno [module]function flags format
init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012
init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012"
init/main.c:1424 [main]run_init_process =_ " with arguments:\012"
init/main.c:1426 [main]run_init_process =_ " %s\012"
init/main.c:1427 [main]run_init_process =_ " with environment:\012"
init/main.c:1429 [main]run_init_process =_ " %s\012"
The 3rd space-delimited column shows the current flags, preceded by a = for easy use with grep/cut. =p shows enabled callsites.
Controlling dynamic debug Behaviour #
The behaviour of prdbg sites are controlled by writing query/commands to the control file. Example:
# grease the interface
:#> alias ddcmd='echo $* > /proc/dynamic_debug/control'
:#> ddcmd '-p; module main func run* +p'
:#> grep =p /proc/dynamic_debug/control
init/main.c:1424 [main]run_init_process =p " with arguments:\012"
init/main.c:1426 [main]run_init_process =p " %s\012"
init/main.c:1427 [main]run_init_process =p " with environment:\012"
init/main.c:1429 [main]run_init_process =p " %s\012"
Error messages go to console/syslog:
:#> ddcmd mode foo +p
dyndbg: unknown keyword "mode"
dyndbg: query parse failed
bash: echo: write error: Invalid argument
If debugfs is also enabled and mounted, dynamic_debug/control is also under the mount-dir, typically /sys/kernel/debug/.
Command Language Reference #
At the basic lexical level, a command is a sequence of words separated by spaces or tabs. So these are all equivalent:
:#> ddcmd file svcsock.c line 1603 +p
:#> ddcmd "file svcsock.c line 1603 +p"
:#> ddcmd ' file svcsock.c line 1603 +p '
Command submissions are bounded by a write() system call. Multiple commands can be written together, separated by ; or \n:
:#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p"
:#> ddcmd <<"EOC"
func pnpacpi_get_resources +p
func pnp_assign_mem +p
EOC
:#> cat query-batch-file > /proc/dynamic_debug/control
You can also use wildcards in each query term. The match rule supports * (matches zero or more characters) and ? (matches exactly one character). For example, you can match all usb drivers:
:#> ddcmd file "drivers/usb/*" +p # "" to suppress shell expansion
Syntactically, a command is pairs of keyword values, followed by a flags change or setting:
command ::= match-spec* flags-spec
The match-spec's select prdbgs from the catalog, upon which to apply the flags-spec, all constraints are ANDed together. An absent keyword is the same as keyword "*".
A match specification is a keyword, which selects the attribute of the callsite to be compared, and a value to compare against. Possible keywords are::
match-spec ::= 'func' string |
'file' string |
'module' string |
'format' string |
'class' string |
'line' line-range
line-range ::= lineno |
'-'lineno |
lineno'-' |
lineno'-'lineno
lineno ::= unsigned-int
The meanings of each keyword are:
-
func
The given string is compared against the function name of each callsite. Example:
func svc_tcp_accept func *recv* # in rfcomm, bluetooth, ping, tcp -
file
The given string is compared against either the src-root relative pathname, or the basename of the source file of each callsite. Examples:
file svcsock.c file kernel/freezer.c # ie column 1 of control file file drivers/usb/* # all callsites under it file inode.c:start_* # parse :tail as a func (above) file inode.c:1-100 # parse :tail as a line-range (above) -
module
The given string is compared against the module name of each callsite. The module name is the string as seen in
lsmod, i.e. without the directory or the.kosuffix and with-changed to_. Examples:module sunrpc module nfsd module drm* # both drm, drm_kms_helper -
format
The given string is searched for in the dynamic debug format string. Note that the string does not need to match the entire format, only some part. Whitespace and other special characters can be escaped using C octal character escape
\ooonotation, e.g. the space character is\040. Alternatively, the string can be enclosed in double quote characters (") or single quote characters ('). Examples:format svcrdma: // many of the NFS/RDMA server pr_debugs format readahead // some pr_debugs in the readahead cache format nfsd:\040SETATTR // one way to match a format with whitespace format "nfsd: SETATTR" // a neater way to match a format with whitespace format 'nfsd: SETATTR' // yet another way to match a format with whitespace -
class
The given class_name is validated against each module, which may have declared a list of known class_names. If the class_name is found for a module, callsite & class matching and adjustment proceeds. Examples:
class DRM_UT_KMS # a DRM.debug category class JUNK # silent non-match // class TLD_* # NOTICE: no wildcard in class names -
line
The given line number or range of line numbers is compared against the line number of each
pr_debug()callsite. A single line number matches the callsite line number exactly. A range of line numbers matches any callsite between the first and last line number inclusive. An empty first number means the first line in the file, an empty last line number means the last line number in the file. Examples:line 1603 // exactly line 1603 line 1600-1605 // the six lines from line 1600 to line 1605 line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file
The flags specification comprises a change operation followed by one or more flag characters. The change operation is one of the characters:
- remove the given flags
+ add the given flags
= set the flags to the given flags
The flags are:
p enables the pr_debug() callsite.
_ enables no flags.
Decorator flags add to the message-prefix, in order:
t Include thread ID, or <intr>
m Include module name
f Include the function name
s Include the source file name
l Include line number
d Include call trace
For print_hex_dump_debug() and print_hex_dump_bytes(), only the p flag has meaning, other flags are ignored.
Note the regexp ^[-+=][fslmptd_]+$ matches a flags specification. To clear all flags at once, use =_ or -fslmptd.
Debug messages during Boot Process #
To activate debug messages for core code and built-in modules during the boot process, even before userspace and debugfs exists, use dyndbg="QUERY" or module.dyndbg="QUERY". QUERY follows the syntax described above, but must not exceed 1023 characters. Your bootloader may impose lower limits.
These dyndbg params are processed just after the ddebug tables are processed, as part of the early_initcall. Thus you can enable debug messages in all code run after this early_initcall via this boot parameter.
On an x86 system for example ACPI enablement is a subsys_initcall and:
dyndbg="file ec.c +p"
will show early Embedded Controller transactions during ACPI setup if your machine (typically a laptop) has an Embedded Controller. PCI (or other devices) initialization also is a hot candidate for using this boot parameter for debugging purposes.
If foo module is not built-in, foo.dyndbg will still be processed at boot time, without effect, but will be reprocessed when module is loaded later. Bare dyndbg= is only processed at boot.
Debug Messages at Module Initialization Time #
When modprobe foo is called, modprobe scans /proc/cmdline for foo.params, strips foo., and passes them to the kernel along with params given in modprobe args or /etc/modprobe.d/*.conf files, in the following order:
-
parameters given via
/etc/modprobe.d/*.conf:options foo dyndbg=+pt options foo dyndbg # defaults to +p -
foo.dyndbgas given in boot args,foo.is stripped and passed:foo.dyndbg=" func bar +p; func buz +mp" -
args to modprobe:
modprobe foo dyndbg==pmf # override previous settings
These dyndbg queries are applied in order, with last having final say. This allows boot args to override or modify those from /etc/modprobe.d (sensible, since 1 is system wide, 2 is kernel or boot specific), and modprobe args to override both.
In the foo.dyndbg="QUERY" form, the query must exclude module foo. foo is extracted from the param-name, and applied to each query in QUERY, and only 1 match-spec of each type is allowed.
The dyndbg option is a "fake" module parameter, which means:
-
modules do not need to define it explicitly
-
every module gets it tacitly, whether they use pr_debug or not
-
it doesn't appear in
/sys/module/$module/parameters/To see it, grep the control file, or inspect/proc/cmdline.
For CONFIG_DYNAMIC_DEBUG kernels, any settings given at boot-time (or enabled by -DDEBUG flag during compilation) can be disabled later via the debugfs interface if the debug messages are no longer needed:
echo "module module_name -p" > /proc/dynamic_debug/control
Examples #
// enable the message at line 1603 of file svcsock.c
:#> ddcmd 'file svcsock.c line 1603 +p'
// enable all the messages in file svcsock.c
:#> ddcmd 'file svcsock.c +p'
// enable all the messages in the NFS server module
:#> ddcmd 'module nfsd +p'
// enable all 12 messages in the function svc_process()
:#> ddcmd 'func svc_process +p'
// disable all 12 messages in the function svc_process()
:#> ddcmd 'func svc_process -p'
// enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
:#> ddcmd 'format "nfsd: READ" +p'
// enable messages in files of which the paths include string "usb"
:#> ddcmd 'file *usb* +p'
// enable all messages
:#> ddcmd '+p'
// add module, function to all enabled messages
:#> ddcmd '+mf'
// boot-args example, with newlines and comments for readability
Kernel command line: ...
// see what's going on in dyndbg=value processing
dynamic_debug.verbose=3
// enable pr_debugs in the btrfs module (can be builtin or loadable)
btrfs.dyndbg="+p"
// enable pr_debugs in all files under init/
// and the function parse_one, #cmt is stripped
dyndbg="file init/* +p #cmt ; func parse_one +p"
// enable pr_debugs in 2 functions in a module loaded later
pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p"
Kernel Configuration #
Dynamic Debug is enabled via kernel config items:
CONFIG_DYNAMIC_DEBUG=y # build catalog, enables CORE
CONFIG_DYNAMIC_DEBUG_CORE=y # enable mechanics only, skip catalog
If you do not want to enable dynamic debug globally (i.e. in some embedded system), you may set CONFIG_DYNAMIC_DEBUG_CORE as basic support of dynamic debug and add ccflags := -DDYNAMIC_DEBUG_MODULE into the Makefile of any modules which you'd like to dynamically debug later.
Kernel prdbg API #
The following functions are cataloged and controllable when dynamic debug is enabled:
pr_debug()
dev_dbg()
print_hex_dump_debug()
print_hex_dump_bytes()
Otherwise, they are off by default; ccflags += -DDEBUG or #define DEBUG in a source file will enable them appropriately.
If CONFIG_DYNAMIC_DEBUG is not set, print_hex_dump_debug() is just a shortcut for print_hex_dump(KERN_DEBUG).
For print_hex_dump_debug()/print_hex_dump_bytes(), format string is its prefix_str argument, if it is constant string; or hexdump in case prefix_str is built dynamically.
Softlockup detector and hardlockup detector (aka nmi_watchdog)
Peios Kernel / Administration / System administration / Troubleshooting and recovery
The Linux kernel can act as a watchdog to detect both soft and hard lockups.
A 'softlockup' is defined as a bug that causes the kernel to loop in kernel mode for more than 20 seconds (see "Implementation" below for details), without giving other tasks a chance to run. The current stack trace is displayed upon detection and, by default, the system will stay locked up. Alternatively, the kernel can be configured to panic; a sysctl, "kernel.softlockup_panic", a kernel parameter, "softlockup_panic" (see "Documentation/admin-guide/kernel-parameters.rst" for details), and a compile option, "BOOTPARAM_SOFTLOCKUP_PANIC", are provided for this.
A 'hardlockup' is defined as a bug that causes the CPU to loop in kernel mode for more than 10 seconds (see "Implementation" below for details), without letting other interrupts have a chance to run. Similarly to the softlockup case, the current stack trace is displayed upon detection and the system will stay locked up unless the default behavior is changed, which can be done through a sysctl, 'hardlockup_panic', a compile time knob, "BOOTPARAM_HARDLOCKUP_PANIC", and a kernel parameter, "nmi_watchdog" (see "Documentation/admin-guide/kernel-parameters.rst" for details).
The panic option can be used in combination with panic_timeout (this timeout is set through the confusingly named "kernel.panic" sysctl), to cause the system to reboot automatically after a specified amount of time.
Implementation #
The soft and hard lockup detectors are built on top of the hrtimer and perf subsystems, respectively. A direct consequence of this is that, in principle, they should work in any architecture where these subsystems are present.
A periodic hrtimer runs to generate interrupts and kick the watchdog job. An NMI perf event is generated every "watchdog_thresh" (compile-time initialized to 10 and configurable through sysctl of the same name) seconds to check for hardlockups. If any CPU in the system does not receive any hrtimer interrupt during that time the 'hardlockup detector' (the handler for the NMI perf event) will generate a kernel warning or call panic, depending on the configuration.
The watchdog job runs in a stop scheduling thread that updates a timestamp every time it is scheduled. If that timestamp is not updated for 2*watchdog_thresh seconds (the softlockup threshold) the 'softlockup detector' (coded inside the hrtimer callback function) will dump useful debug information to the system log, after which it will call panic if it was instructed to do so or resume execution of other kernel code.
The period of the hrtimer is 2*watchdog_thresh/5, which means it has two or three chances to generate an interrupt before the hardlockup detector kicks in.
As explained above, a kernel knob is provided that allows administrators to configure the period of the hrtimer and the perf event. The right value for a particular environment is a trade-off between fast response to lockups and detection overhead.
By default, the watchdog runs on all online cores. However, on a kernel configured with NO_HZ_FULL, by default the watchdog runs only on the housekeeping cores, not the cores specified in the "nohz_full" boot argument. If we allowed the watchdog to run by default on the "nohz_full" cores, we would have to run timer ticks to activate the scheduler, which would prevent the "nohz_full" functionality from protecting the user code on those cores from the kernel. Of course, disabling it by default on the nohz_full cores means that when those cores do enter the kernel, by default we will not be able to detect if they lock up. However, allowing the watchdog to continue to run on the housekeeping (non-tickless) cores means that we will continue to detect lockups properly on those cores.
In either case, the set of cores excluded from running the watchdog may be adjusted via the kernel.watchdog_cpumask sysctl. For nohz_full cores, this may be useful for debugging a case where the kernel seems to be hanging on the nohz_full cores.
pstore block oops/panic logger
Peios Kernel / Administration / System administration / Troubleshooting and recovery
Introduction #
pstore block (pstore/blk) is an oops/panic logger that writes its logs to a block device and non-block device before the system crashes. You can get these log files by mounting pstore filesystem like:
mount -t pstore pstore /sys/fs/pstore
pstore block concepts #
pstore/blk provides efficient configuration method for pstore/blk, which divides all configurations into two parts, configurations for user and configurations for driver.
Configurations for user determine how pstore/blk works, such as pmsg_size, kmsg_size and so on. All of them support both Kconfig and module parameters, but module parameters have priority over Kconfig.
Configurations for driver are all about block device and non-block device, such as total_size of block device and read/write operations.
Configurations for user #
All of these configurations support both Kconfig and module parameters, but module parameters have priority over Kconfig.
Here is an example for module parameters:
pstore_blk.blkdev=/dev/mmcblk0p7 pstore_blk.kmsg_size=64 best_effort=y
The detail of each configurations may be of interest to you.
blkdev #
The block device to use. Most of the time, it is a partition of block device. It's required for pstore/blk. It is also used for MTD device.
When pstore/blk is built as a module, "blkdev" accepts the following variants:
-
/dev/<disk_name> represents the device number of disk
-
/dev/<disk_name><decimal> represents the device number of partition - device number of disk plus the partition number
-
/dev/<disk_name>p<decimal> - same as the above; this form is used when disk name of partitioned disk ends with a digit.
When pstore/blk is built into the kernel, "blkdev" accepts the following variants:
-
<hex_major><hex_minor> device number in hexadecimal representation, with no leading 0x, for example b302.
-
PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF represents the unique id of a partition if the partition table provides it. The UUID may be either an EFI/GPT UUID, or refer to an MSDOS partition using the format SSSSSSSS-PP, where SSSSSSSS is a zero-filled hex representation of the 32-bit "NT disk signature", and PP is a zero-filled hex representation of the 1-based partition number.
-
PARTUUID=<UUID>/PARTNROFF=<int> to select a partition in relation to a partition with a known unique id.
-
<major>:<minor> major and minor number of the device separated by a colon.
It accepts the following variants for MTD device:
-
<device name> MTD device name. "pstore" is recommended.
-
<device number> MTD device number.
kmsg_size #
The chunk size in KB for oops/panic front-end. It MUST be a multiple of 4. It's optional if you do not care about the oops/panic log.
There are multiple chunks for oops/panic front-end depending on the remaining space except other pstore front-ends.
pstore/blk will log to oops/panic chunks one by one, and always overwrite the oldest chunk if there is no more free chunk.
pmsg_size #
The chunk size in KB for pmsg front-end. It MUST be a multiple of 4. It's optional if you do not care about the pmsg log.
Unlike oops/panic front-end, there is only one chunk for pmsg front-end.
Pmsg is a user space accessible pstore object. Writes to /dev/pmsg0 are appended to the chunk. On reboot the contents are available in /sys/fs/pstore/pmsg-pstore-blk-0.
console_size #
The chunk size in KB for console front-end. It MUST be a multiple of 4. It's optional if you do not care about the console log.
Similar to pmsg front-end, there is only one chunk for console front-end.
All log of console will be appended to the chunk. On reboot the contents are available in /sys/fs/pstore/console-pstore-blk-0.
ftrace_size #
The chunk size in KB for ftrace front-end. It MUST be a multiple of 4. It's optional if you do not care about the ftrace log.
Similar to oops front-end, there are multiple chunks for ftrace front-end depending on the count of cpu processors. Each chunk size is equal to ftrace_size / processors_count.
All log of ftrace will be appended to the chunk. On reboot the contents are combined and available in /sys/fs/pstore/ftrace-pstore-blk-0.
Persistent function tracing might be useful for debugging software or hardware related hangs. Here is an example of usage:
# mount -t pstore pstore /sys/fs/pstore
# mount -t debugfs debugfs /sys/kernel/debug/
# echo 1 > /sys/kernel/debug/pstore/record_ftrace
# reboot -f
[...]
# mount -t pstore pstore /sys/fs/pstore
# tail /sys/fs/pstore/ftrace-pstore-blk-0
CPU:0 ts:5914676 c0063828 c0063b94 call_cpuidle <- cpu_startup_entry+0x1b8/0x1e0
CPU:0 ts:5914678 c039ecdc c006385c cpuidle_enter_state <- call_cpuidle+0x44/0x48
CPU:0 ts:5914680 c039e9a0 c039ecf0 cpuidle_enter_freeze <- cpuidle_enter_state+0x304/0x314
CPU:0 ts:5914681 c0063870 c039ea30 sched_idle_set_state <- cpuidle_enter_state+0x44/0x314
CPU:1 ts:5916720 c0160f59 c015ee04 kernfs_unmap_bin_file <- __kernfs_remove+0x140/0x204
CPU:1 ts:5916721 c05ca625 c015ee0c __mutex_lock_slowpath <- __kernfs_remove+0x148/0x204
CPU:1 ts:5916723 c05c813d c05ca630 yield_to <- __mutex_lock_slowpath+0x314/0x358
CPU:1 ts:5916724 c05ca2d1 c05ca638 __ww_mutex_lock <- __mutex_lock_slowpath+0x31c/0x358
max_reason #
Limiting which kinds of kmsg dumps are stored can be controlled via the max_reason value, as defined in include/linux/kmsg_dump.h's enum kmsg_dump_reason. For example, to store both Oopses and Panics, max_reason should be set to 2 (KMSG_DUMP_OOPS), to store only Panics max_reason should be set to 1 (KMSG_DUMP_PANIC). Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be controlled by the printk.always_kmsg_dump boot param: if unset, it'll be KMSG_DUMP_OOPS, otherwise KMSG_DUMP_MAX.
Configurations for driver #
A device driver uses register_pstore_device with struct pstore_device_info to register to pstore/blk.
register_pstore_device() #
int register non-block device to pstore/blk
Parameters
struct pstore_device_info *dev: non-block device information
Return
- 0 - OK
- Others - something error.
unregister_pstore_device() #
void unregister non-block device from pstore/blk
Parameters
struct pstore_device_info *dev: non-block device information
Compression and header #
Block device is large enough for uncompressed oops data. Actually we do not recommend data compression because pstore/blk will insert some information into the first line of oops/panic data. For example:
Panic: Total 16 times
It means that it's OOPS|Panic for the 16th time since the first booting. Sometimes the number of occurrences of oops|panic since the first booting is important to judge whether the system is stable.
The following line is inserted by pstore filesystem. For example:
Oops#2 Part1
It means that it's OOPS for the 2nd time on the last boot.
Reading the data #
The dump data can be read from the pstore filesystem. The format for these files is dmesg-pstore-blk-[N] for oops/panic front-end, pmsg-pstore-blk-0 for pmsg front-end and so on. The timestamp of the dump file records the trigger time. To delete a stored record from block device, simply unlink the respective pstore file.
Attentions in panic read/write APIs #
If on panic, the kernel is not going to run for much longer, the tasks will not be scheduled and most kernel resources will be out of service. It looks like a single-threaded program running on a single-core computer.
The following points require special attention for panic read/write APIs:
-
Can NOT allocate any memory. If you need memory, just allocate while the block driver is initializing rather than waiting until the panic.
-
Must be polled, NOT interrupt driven. No task schedule any more. The block driver should delay to ensure the write succeeds, but NOT sleep.
-
Can NOT take any lock. There is no other task, nor any shared resource; you are safe to break all locks.
-
Just use CPU to transfer. Do not use DMA to transfer unless you are sure that DMA will not keep lock.
-
Control registers directly. Please control registers directly rather than use Linux kernel resources. Do I/O map while initializing rather than wait until a panic occurs.
-
Reset your block device and controller if necessary. If you are not sure of the state of your block device and controller when a panic occurs, you are safe to stop and reset them.
pstore/blk supports psblk_blkdev_info(), which is defined in linux/pstore_blk.h, to get information of using block device, such as the device number, sector count and start sector of the whole disk.
pstore block internals #
For developer reference, here are all the important structures and APIs:
struct psz_buffer #
header of zone to flush to storage
Definition
;
Members
sig: signature to indicate header (PSZ_SIG xor PSZONE-type value)datalen: length of data in datastart: offset into data where the beginning of the stored bytes begindata: zone data.
struct psz_kmsg_header #
kmsg dump-specific header to flush to storage
Definition
;
Members
magic: magic num for kmsg dump headertime: kmsg dump trigger timecompressed: whether compressedcounter: kmsg dump counterreason: the kmsg dump reason (e.g. oops, panic, etc)data: pointer to log data
Description
This is a sub-header for a kmsg dump, trailing after psz_buffer.
struct pstore_zone #
single stored buffer
Definition
;
Members
off: zone offset of storagename: front-end name for this zonetype: front-end type for this zonebuffer: pointer to data buffer managed by this zoneoldbuf: pointer to old data bufferbuffer_size: bytes in buffer->datashould_recover: whether this zone should recover from storagedirty: whether the data in buffer dirty
Description
zone structure in memory.
struct psz_context #
all about running state of pstore/zone
Definition
;
Members
kpszs: kmsg dump storage zonesppsz: pmsg storage zonecpsz: console storage zonefpszs: ftrace storage zoneskmsg_max_cnt: max count of kpszskmsg_read_cnt: counter of total read kmsg dumpskmsg_write_cnt: counter of total kmsg dump writespmsg_read_cnt: counter of total read pmsg zoneconsole_read_cnt: counter of total read console zoneftrace_max_cnt: max count of fpszsftrace_read_cnt: counter of max read ftrace zoneoops_counter: counter of oops dumpspanic_counter: counter of panic dumpsrecovered: whether finished recovering data from storageon_panic: whether panic is happeningpstore_zone_info_lock: lock to pstore_zone_infopstore_zone_info: information from backendpstore: structure for pstore
enum psz_flush_mode #
flush mode for psz_zone_write()
Constants
FLUSH_NONE: do not flush to storage but update data on memoryFLUSH_PART: just flush part of data including meta data to storageFLUSH_META: just flush meta data of zone to storageFLUSH_ALL: flush all of zone
psz_recovery() #
int recover data from storage
Parameters
struct psz_context *cxt: the context of pstore/zone
Description
recovery means reading data back from storage after rebooting
Return
0 on success, others on failure.
struct pstore_zone_info #
pstore/zone back-end driver structure
Definition
;
Members
owner: Module which is responsible for this back-end driver.name: Name of the back-end driver.total_size: The total size in bytes pstore/zone can use. It must be greater than 4096 and be multiple of 4096.kmsg_size: The size of oops/panic zone. Zero means disabled, otherwise, it must be multiple of SECTOR_SIZE(512 Bytes).max_reason: Maximum kmsg dump reason to store.pmsg_size: The size of pmsg zone which is the same as kmsg_size.console_size: The size of console zone which is the same as kmsg_size.ftrace_size: The size of ftrace zone which is the same as kmsg_size.read: The general read operation. Both of the function parameters size and offset are relative value to storage. On success, the number of bytes should be returned, others mean error.write: The same as read, but the following error number: -EBUSY means try to write again later. -ENOMSG means to try next zone.erase: The general erase operation for device with special removing job. Both of the function parameters size and offset are relative value to storage. Return 0 on success and others on failure.panic_write: The write operation only used for panic case. It's optional if you do not care panic log. The parameters are relative value to storage. On success, the number of bytes should be returned, others excluding -ENOMSG mean error. -ENOMSG means to try next zone.
struct pstore_device_info #
back-end pstore/blk driver structure.
Definition
;
Members
flags: Refer to macro starting with PSTORE_FLAGS defined in linux/pstore.h. It means what front-ends this device support. Zero means all backends for compatible.zone: The struct pstore_zone_info details.
struct pstore_blk_config #
the pstore_blk backend configuration
Definition
;
Members
device: Name of the desired block devicemax_reason: Maximum kmsg dump reason to store to block devicekmsg_size: Total size of for kmsg dumpspmsg_size: Total size of the pmsg storage areaconsole_size: Total size of the console storage areaftrace_size: Total size for ftrace logging data (for all CPUs)
pstore_blk_get_config() #
int get a copy of the pstore_blk backend configuration
Parameters
struct pstore_blk_config *info: The sturct pstore_blk_config to be filled in
Description
Failure returns negative error code, and success returns 0.
Ramoops oops/panic logger
Peios Kernel / Administration / System administration / Troubleshooting and recovery
Sergiu Iordache <sergiu@chromium.org>
Updated: 10 Feb 2021
Introduction #
Ramoops is an oops/panic logger that writes its logs to RAM before the system crashes. It works by logging oopses and panics in a circular buffer. Ramoops needs a system with persistent RAM so that the content of that area can survive after a restart.
Ramoops concepts #
Ramoops uses a predefined memory area to store the dump. The start and size and type of the memory area are set using three variables:
mem_addressfor the start
mem_sizefor the size. The memory size will be rounded down to a power of two.
mem_typeto specify if the memory type (default is pgprot_writecombine).
mem_nameto specify a memory region defined byreserve_memcommand line parameter.
Typically the default value of mem_type=0 should be used as that sets the pstore mapping to pgprot_writecombine. Setting mem_type=1 attempts to use pgprot_noncached, which only works on some platforms. This is because pstore depends on atomic operations. At least on ARM, pgprot_noncached causes the memory to be mapped strongly ordered, and atomic operations on strongly ordered memory are implementation defined, and won't work on many ARMs such as omaps. Setting mem_type=2 attempts to treat the memory region as normal memory, which enables full cache on it. This can improve the performance.
The memory area is divided into record_size chunks (also rounded down to power of two) and each kmesg dump writes a record_size chunk of information.
Limiting which kinds of kmsg dumps are stored can be controlled via the max_reason value, as defined in include/linux/kmsg_dump.h's enum kmsg_dump_reason. For example, to store both Oopses and Panics, max_reason should be set to 2 (KMSG_DUMP_OOPS), to store only Panics max_reason should be set to 1 (KMSG_DUMP_PANIC). Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be controlled by the printk.always_kmsg_dump boot param: if unset, it'll be KMSG_DUMP_OOPS, otherwise KMSG_DUMP_MAX.
The module uses a counter to record multiple dumps but the counter gets reset on restart (i.e. new dumps after the restart will overwrite old ones).
Ramoops also supports software ECC protection of persistent memory regions. This might be useful when a hardware reset was used to bring the machine back to life (i.e. a watchdog triggered). In such cases, RAM may be somewhat corrupt, but usually it is restorable.
Setting the parameters #
Setting the ramoops parameters can be done in several different manners:
A. Use the module parameters (which have the names of the variables described as before). For quick debugging, you can also reserve parts of memory during boot and then use the reserved memory for ramoops. For example, assuming a machine with > 128 MB of memory, the following kernel command line will tell the kernel to use only the first 128 MB of memory, and place ECC-protected ramoops region at 128 MB boundary:
mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1B. Use Device Tree bindings, as described in
Documentation/devicetree/bindings/reserved-memory/ramoops.yaml. For example:reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; ramoops@8f000000 { compatible = "ramoops"; reg = <0 0x8f000000 0 0x100000>; record-size = <0x4000>; console-size = <0x4000>; }; };C. Use a platform device and set the platform data. The parameters can then be set through that platform data. An example of doing that is:
static struct ramoops_platform_data ramoops_data = ; static struct platform_device ramoops_dev = ; int ret; ret = ; if
D. Using a region of memory reserved via
reserve_memcommand line parameter. The address and size will be defined by thereserve_memparameter. Note, thatreserve_memmay not always allocate memory in the same location, and cannot be relied upon. Testing will need to be done, and it may not work on every machine, nor every kernel. Consider this a "best effort" approach. Thereserve_memoption takes a size, alignment and name as arguments. The name is used to map the memory to a label that can be retrieved by ramoops.reserve_mem=2M:4096:oops ramoops.mem_name=oops
You can specify either RAM memory or peripheral devices' memory. However, when specifying RAM, be sure to reserve the memory by issuing memblock_reserve() very early in the architecture code, e.g.:
#include <linux/memblock.h>
memblock_reserve(ramoops_data.mem_address, ramoops_data.mem_size);
Dump format #
The data dump begins with a header, currently defined as ==== followed by a timestamp and a new line. The dump then continues with the actual data.
Reading the data #
The dump data can be read from the pstore filesystem. The format for these files is dmesg-ramoops-N, where N is the record number in memory. To delete a stored record from RAM, simply unlink the respective pstore file.
Persistent function tracing #
Persistent function tracing might be useful for debugging software or hardware related hangs. The functions call chain log is stored in a ftrace-ramoops file. Here is an example of usage:
# mount -t debugfs debugfs /sys/kernel/debug/
# echo 1 > /sys/kernel/debug/pstore/record_ftrace
# reboot -f
[...]
# mount -t pstore pstore /mnt/
# tail /mnt/ftrace-ramoops
0 ffffffff8101ea64 ffffffff8101bcda native_apic_mem_read <- disconnect_bsp_APIC+0x6a/0xc0
0 ffffffff8101ea44 ffffffff8101bcf6 native_apic_mem_write <- disconnect_bsp_APIC+0x86/0xc0
0 ffffffff81020084 ffffffff8101a4b5 hpet_disable <- native_machine_shutdown+0x75/0x90
0 ffffffff81005f94 ffffffff8101a4bb iommu_shutdown_noop <- native_machine_shutdown+0x7b/0x90
0 ffffffff8101a6a1 ffffffff8101a437 native_machine_emergency_restart <- native_machine_restart+0x37/0x40
0 ffffffff811f9876 ffffffff8101a73a acpi_reboot <- native_machine_emergency_restart+0xaa/0x1e0
0 ffffffff8101a514 ffffffff8101a772 mach_reboot_fixups <- native_machine_emergency_restart+0xe2/0x1e0
0 ffffffff811d9c54 ffffffff8101a7a0 __const_udelay <- native_machine_emergency_restart+0x110/0x1e0
0 ffffffff811d9c34 ffffffff811d9c80 __delay <- __const_udelay+0x30/0x40
0 ffffffff811d9d14 ffffffff811d9c3f delay_tsc <- __delay+0xf/0x20
Reporting issues
Peios Kernel / Administration / System administration / Troubleshooting and recovery
Peios: The upstream Linux build, report and distribution procedures below apply in that context. Use Building Peios and Peios Standards and Conventions for Peios development and track Peios work in Acta.
The short guide (aka TL;DR) #
Are you facing a regression with vanilla kernels from the same stable or longterm series? One still supported? Then search the LKML and the Linux stable mailing list archives for matching reports to join. If you don't find any, install the latest release from that series. If it still shows the issue, report it to the stable mailing list (stable@vger.kernel.org) and CC the regressions list (regressions@lists.linux.dev); ideally also CC the maintainer and the mailing list for the subsystem in question.
In all other cases try your best guess which kernel part might be causing the issue. Check the MAINTAINERS file for how its developers expect to be told about problems, which most of the time will be by email with a mailing list in CC. Check the destination's archives for matching reports; search the LKML and the web, too. If you don't find any to join, install the latest mainline kernel. If the issue is present there, send a report.
The issue was fixed there, but you would like to see it resolved in a still supported stable or longterm series as well? Then install its latest release. If it shows the problem, search for the change that fixed it in mainline and check if backporting is in the works or was discarded; if it's neither, ask those who handled the change for it.
General remarks: When installing and testing a kernel as outlined above, ensure it's vanilla (IOW: not patched and not using add-on modules). Also make sure it's built and running in a healthy environment and not already tainted before the issue occurs.
If you are facing multiple issues with the Linux kernel at once, report each separately. While writing your report, include all information relevant to the issue, like the kernel and the distro used. In case of a regression, CC the regressions mailing list (regressions@lists.linux.dev) to your report. Also try to pinpoint the culprit with a bisection; if you succeed, include its commit-id and CC everyone in the sign-off-by chain.
Once the report is out, answer any questions that come up and help where you can. That includes keeping the ball rolling by occasionally retesting with newer releases and sending a status update afterwards.
Step-by-step guide how to report issues to the kernel maintainers #
The above TL;DR outlines roughly how to report issues to the Linux kernel developers. It might be all that's needed for people already familiar with reporting issues to Free/Libre & Open Source Software (FLOSS) projects. For everyone else there is this section. It is more detailed and uses a step-by-step approach. It still tries to be brief for readability and leaves out a lot of details; those are described below the step-by-step guide in a reference section, which explains each of the steps in more detail.
Note: this section covers a few more aspects than the TL;DR and does things in a slightly different order. That's in your interest, to make sure you notice early if an issue that looks like a Linux kernel problem is actually caused by something else. These steps thus help to ensure the time you invest in this process won't feel wasted in the end:
Are you facing an issue with a Linux kernel a hardware or software vendor provided? Then in almost all cases you are better off to stop reading this document and reporting the issue to your vendor instead, unless you are willing to install the latest Linux version yourself. Be aware the latter will often be needed anyway to hunt down and fix issues.
Perform a rough search for existing reports with your favorite internet search engine; additionally, check the archives of the Linux Kernel Mailing List (LKML). If you find matching reports, join the discussion instead of sending a new one.
See if the issue you are dealing with qualifies as regression, security issue, or a really severe problem: those are 'issues of high priority' that need special handling in some steps that are about to follow.
Make sure it's not the kernel's surroundings that are causing the issue you face.
Create a fresh backup and put system repair and restore tools at hand.
Ensure your system does not enhance its kernels by building additional kernel modules on-the-fly, which solutions like DKMS might be doing locally without your knowledge.
Check if your kernel was 'tainted' when the issue occurred, as the event that made the kernel set this flag might be causing the issue you face.
Write down coarsely how to reproduce the issue. If you deal with multiple issues at once, create separate notes for each of them and make sure they work independently on a freshly booted system. That's needed, as each issue needs to get reported to the kernel developers separately, unless they are strongly entangled.
If you are facing a regression within a stable or longterm version line (say something broke when updating from 5.10.4 to 5.10.5), scroll down to 'Dealing with regressions within a stable and longterm kernel line'.
Locate the driver or kernel subsystem that seems to be causing the issue. Find out how and where its developers expect reports. Note: most of the time this won't be bugzilla.kernel.org, as issues typically need to be sent by mail to a maintainer and a public mailing list.
Search the archives of the bug tracker or mailing list in question thoroughly for reports that might match your issue. If you find anything, join the discussion instead of sending a new report.
After these preparations you'll now enter the main part:
Unless you are already running the latest 'mainline' Linux kernel, better go and install it for the reporting process. Testing and reporting with the latest 'stable' Linux can be an acceptable alternative in some situations; during the merge window that actually might be even the best approach, but in that development phase it can be an even better idea to suspend your efforts for a few days anyway. Whatever version you choose, ideally use a 'vanilla' build. Ignoring these advices will dramatically increase the risk your report will be rejected or ignored.
Ensure the kernel you just installed does not 'taint' itself when running.
Reproduce the issue with the kernel you just installed. If it doesn't show up there, scroll down to the instructions for issues only happening with stable and longterm kernels.
Optimize your notes: try to find and write the most straightforward way to reproduce your issue. Make sure the end result has all the important details, and at the same time is easy to read and understand for others that hear about it for the first time. And if you learned something in this process, consider searching again for existing reports about the issue.
If your failure involves a 'panic', 'Oops', 'warning', or 'BUG', consider decoding the kernel log to find the line of code that triggered the error.
If your problem is a regression, try to narrow down when the issue was introduced as much as possible.
Start to compile the report by writing a detailed description about the issue. Always mention a few things: the latest kernel version you installed for reproducing, the Linux Distribution used, and your notes on how to reproduce the issue. Ideally, make the kernel's build configuration (.config) and the output from
dmesgavailable somewhere on the net and link to it. Include or upload all other information that might be relevant, like the output/screenshot of an Oops or the output fromlspci. Once you wrote this main part, insert a normal length paragraph on top of it outlining the issue and the impact quickly. On top of this add one sentence that briefly describes the problem and gets people to read on. Now give the thing a descriptive title or subject that yet again is shorter. Then you're ready to send or file the report like the MAINTAINERS file told you, unless you are dealing with one of those 'issues of high priority': they need special care which is explained in 'Special handling for high priority issues' below.Wait for reactions and keep the thing rolling until you can accept the outcome in one way or the other. Thus react publicly and in a timely manner to any inquiries. Test proposed fixes. Do proactive testing: retest with at least every first release candidate (RC) of a new mainline version and report your results. Send friendly reminders if things stall. And try to help yourself, if you don't get any help or if it's unsatisfying.
Reporting regressions within a stable and longterm kernel line #
This subsection is for you, if you followed above process and got sent here at the point about regression within a stable or longterm kernel version line. You face one of those if something breaks when updating from 5.10.4 to 5.10.5 (a switch from 5.9.15 to 5.10.5 does not qualify). The developers want to fix such regressions as quickly as possible, hence there is a streamlined process to report them:
Check if the kernel developers still maintain the Linux kernel version line you care about: go to the front page of kernel.org and make sure it mentions the latest release of the particular version line without an '[EOL]' tag.
Check the archives of the Linux stable mailing list for existing reports.
Install the latest release from the particular version line as a vanilla kernel. Ensure this kernel is not tainted and still shows the problem, as the issue might have already been fixed there. If you first noticed the problem with a vendor kernel, check a vanilla build of the last version known to work performs fine as well.
Send a short problem report to the Linux stable mailing list (stable@vger.kernel.org) and CC the Linux regressions mailing list (regressions@lists.linux.dev); if you suspect the cause in a particular subsystem, CC its maintainer and its mailing list. Roughly describe the issue and ideally explain how to reproduce it. Mention the first version that shows the problem and the last version that's working fine. Then wait for further instructions.
The reference section below explains each of these steps in more detail.
Reporting issues only occurring in older kernel version lines #
This subsection is for you, if you tried the latest mainline kernel as outlined above, but failed to reproduce your issue there; at the same time you want to see the issue fixed in a still supported stable or longterm series or vendor kernels regularly rebased on those. If that is the case, follow these steps:
Prepare yourself for the possibility that going through the next few steps might not get the issue solved in older releases: the fix might be too big or risky to get backported there.
Perform the first three steps in the section "Dealing with regressions within a stable and longterm kernel line" above.
Search the Linux kernel version control system for the change that fixed the issue in mainline, as its commit message might tell you if the fix is scheduled for backporting already. If you don't find anything that way, search the appropriate mailing lists for posts that discuss such an issue or peer-review possible fixes; then check the discussions if the fix was deemed unsuitable for backporting. If backporting was not considered at all, join the newest discussion, asking if it's in the cards.
One of the former steps should lead to a solution. If that doesn't work out, ask the maintainers for the subsystem that seems to be causing the issue for advice; CC the mailing list for the particular subsystem as well as the stable mailing list.
The reference section below explains each of these steps in more detail.
Reference section: Reporting issues to the kernel maintainers #
The detailed guides above outline all the major steps in brief fashion, which should be enough for most people. But sometimes there are situations where even experienced users might wonder how to actually do one of those steps. That's what this section is for, as it will provide a lot more details on each of the above steps. Consider this as reference documentation: it's possible to read it from top to bottom. But it's mainly meant to skim over and a place to look up details how to actually perform those steps.
A few words of general advice before digging into the details:
The Linux kernel developers are well aware this process is complicated and demands more than other FLOSS projects. We'd love to make it simpler. But that would require work in various places as well as some infrastructure, which would need constant maintenance; nobody has stepped up to do that work, so that's just how things are for now.
A warranty or support contract with some vendor doesn't entitle you to request fixes from developers in the upstream Linux kernel community: such contracts are completely outside the scope of the Linux kernel, its development community, and this document. That's why you can't demand anything such a contract guarantees in this context, not even if the developer handling the issue works for the vendor in question. If you want to claim your rights, use the vendor's support channel instead. When doing so, you might want to mention you'd like to see the issue fixed in the upstream Linux kernel; motivate them by saying it's the only way to ensure the fix in the end will get incorporated in all Linux distributions.
If you never reported an issue to a FLOSS project before you should consider reading How to Report Bugs Effectively, How To Ask Questions The Smart Way, and How to ask good questions.
With that off the table, find below the details on how to properly report issues to the Linux kernel developers.
Make sure you're using the upstream Linux kernel #
Are you facing an issue with a Linux kernel a hardware or software vendor provided? Then in almost all cases you are better off to stop reading this document and reporting the issue to your vendor instead, unless you are willing to install the latest Linux version yourself. Be aware the latter will often be needed anyway to hunt down and fix issues.
Like most programmers, Linux kernel developers don't like to spend time dealing with reports for issues that don't even happen with their current code. It's just a waste everybody's time, especially yours. Unfortunately such situations easily happen when it comes to the kernel and often leads to frustration on both sides. That's because almost all Linux-based kernels pre-installed on devices (Computers, Laptops, Smartphones, Routers, …) and most shipped by Linux distributors are quite distant from the official Linux kernel as distributed by kernel.org: these kernels from these vendors are often ancient from the point of Linux development or heavily modified, often both.
Most of these vendor kernels are quite unsuitable for reporting issues to the Linux kernel developers: an issue you face with one of them might have been fixed by the Linux kernel developers months or years ago already; additionally, the modifications and enhancements by the vendor might be causing the issue you face, even if they look small or totally unrelated. That's why you should report issues with these kernels to the vendor. Its developers should look into the report and, in case it turns out to be an upstream issue, fix it directly upstream or forward the report there. In practice that often does not work out or might not what you want. You thus might want to consider circumventing the vendor by installing the very latest Linux kernel core yourself. If that's an option for you move ahead in this process, as a later step in this guide will explain how to do that once it rules out other potential causes for your issue.
Note, the previous paragraph is starting with the word 'most', as sometimes developers in fact are willing to handle reports about issues occurring with vendor kernels. If they do in the end highly depends on the developers and the issue in question. Your chances are quite good if the distributor applied only small modifications to a kernel based on a recent Linux version; that for example often holds true for the mainline kernels shipped by Debian GNU/Linux Sid or Fedora Rawhide. Some developers will also accept reports about issues with kernels from distributions shipping the latest stable kernel, as long as it's only slightly modified; that for example is often the case for Arch Linux, regular Fedora releases, and openSUSE Tumbleweed. But keep in mind, you better want to use a mainline Linux and avoid using a stable kernel for this process, as outlined in the section 'Install a fresh kernel for testing' in more detail.
Obviously you are free to ignore all this advice and report problems with an old or heavily modified vendor kernel to the upstream Linux developers. But note, those often get rejected or ignored, so consider yourself warned. But it's still better than not reporting the issue at all: sometimes such reports directly or indirectly will help to get the issue fixed over time.
Search for existing reports, first run #
Perform a rough search for existing reports with your favorite internet search engine; additionally, check the archives of the Linux Kernel Mailing List (LKML). If you find matching reports, join the discussion instead of sending a new one.
Reporting an issue that someone else already brought forward is often a waste of time for everyone involved, especially you as the reporter. So it's in your own interest to thoroughly check if somebody reported the issue already. At this step of the process it's okay to just perform a rough search: a later step will tell you to perform a more detailed search once you know where your issue needs to be reported to. Nevertheless, do not hurry with this step of the reporting process, it can save you time and trouble.
Simply search the internet with your favorite search engine first. Afterwards, search the Linux Kernel Mailing List (LKML) archives.
If you get flooded with results consider telling your search engine to limit search timeframe to the past month or year. And wherever you search, make sure to use good search terms; vary them a few times, too. While doing so try to look at the issue from the perspective of someone else: that will help you to come up with other words to use as search terms. Also make sure not to use too many search terms at once. Remember to search with and without information like the name of the kernel driver or the name of the affected hardware component. But its exact brand name (say 'ASUS Red Devil Radeon RX 5700 XT Gaming OC') often is not much helpful, as it is too specific. Instead try search terms like the model line (Radeon 5700 or Radeon 5000) and the code name of the main chip ('Navi' or 'Navi10') with and without its manufacturer ('AMD').
In case you find an existing report about your issue, join the discussion, as you might be able to provide valuable additional information. That can be important even when a fix is prepared or in its final stages already, as developers might look for people that can provide additional information or test a proposed fix. Jump to the section 'Duties after the report went out' for details on how to get properly involved.
Note, searching bugzilla.kernel.org might also be a good idea, as that might provide valuable insights or turn up matching reports. If you find the latter, just keep in mind: most subsystems expect reports in different places, as described below in the section "Check where you need to report your issue". The developers that should take care of the issue thus might not even be aware of the bugzilla ticket. Hence, check the ticket if the issue already got reported as outlined in this document and if not consider doing so.
Issue of high priority? #
See if the issue you are dealing with qualifies as regression, security issue, or a really severe problem: those are 'issues of high priority' that need special handling in some steps that are about to follow.
Linus Torvalds and the leading Linux kernel developers want to see some issues fixed as soon as possible, hence there are 'issues of high priority' that get handled slightly differently in the reporting process. Three type of cases qualify: regressions, security issues, and really severe problems.
You deal with a regression if some application or practical use case running fine with one Linux kernel works worse or not at all with a newer version compiled using a similar configuration. The document Documentation/admin-guide/reporting-regressions.rst explains this in more detail. It also provides a good deal of other information about regressions you might want to be aware of; it for example explains how to add your issue to the list of tracked regressions, to ensure it won't fall through the cracks.
What qualifies as security issue is left to your judgment. Consider reading Documentation/process/security-bugs.rst before proceeding, as it provides additional details how to best handle security issues.
An issue is a 'really severe problem' when something totally unacceptably bad happens. That's for example the case when a Linux kernel corrupts the data it's handling or damages hardware it's running on. You're also dealing with a severe issue when the kernel suddenly stops working with an error message ('kernel panic') or without any farewell note at all. Note: do not confuse a 'panic' (a fatal error where the kernel stop itself) with a 'Oops' (a recoverable error), as the kernel remains running after the latter.
Ensure a healthy environment #
Make sure it's not the kernel's surroundings that are causing the issue you face.
Problems that look a lot like a kernel issue are sometimes caused by build or runtime environment. It's hard to rule out that problem completely, but you should minimize it:
Use proven tools when building your kernel, as bugs in the compiler or the binutils can cause the resulting kernel to misbehave.
Ensure your computer components run within their design specifications; that's especially important for the main processor, the main memory, and the motherboard. Therefore, stop undervolting or overclocking when facing a potential kernel issue.
Try to make sure it's not faulty hardware that is causing your issue. Bad main memory for example can result in a multitude of issues that will manifest itself in problems looking like kernel issues.
If you're dealing with a filesystem issue, you might want to check the file system in question with
fsck, as it might be damaged in a way that leads to unexpected kernel behavior.When dealing with a regression, make sure it's not something else that changed in parallel to updating the kernel. The problem for example might be caused by other software that was updated at the same time. It can also happen that a hardware component coincidentally just broke when you rebooted into a new kernel for the first time. Updating the systems BIOS or changing something in the BIOS Setup can also lead to problems that on look a lot like a kernel regression.
Prepare for emergencies #
Create a fresh backup and put system repair and restore tools at hand.
Reminder, you are dealing with computers, which sometimes do unexpected things, especially if you fiddle with crucial parts like the kernel of its operating system. That's what you are about to do in this process. Thus, make sure to create a fresh backup; also ensure you have all tools at hand to repair or reinstall the operating system as well as everything you need to restore the backup.
Make sure your kernel doesn't get enhanced #
Ensure your system does not enhance its kernels by building additional kernel modules on-the-fly, which solutions like DKMS might be doing locally without your knowledge.
The risk your issue report gets ignored or rejected dramatically increases if your kernel gets enhanced in any way. That's why you should remove or disable mechanisms like akmods and DKMS: those build add-on kernel modules automatically, for example when you install a new Linux kernel or boot it for the first time. Also remove any modules they might have installed. Then reboot before proceeding.
Note, you might not be aware that your system is using one of these solutions: they often get set up silently when you install Nvidia's proprietary graphics driver, VirtualBox, or other software that requires a some support from a module not part of the Linux kernel. That why your might need to uninstall the packages with such software to get rid of any 3rd party kernel module.
Check 'taint' flag #
Check if your kernel was 'tainted' when the issue occurred, as the event that made the kernel set this flag might be causing the issue you face.
The kernel marks itself with a 'taint' flag when something happens that might lead to follow-up errors that look totally unrelated. The issue you face might be such an error if your kernel is tainted. That's why it's in your interest to rule this out early before investing more time into this process. This is the only reason why this step is here, as this process later will tell you to install the latest mainline kernel; you will need to check the taint flag again then, as that's when it matters because it's the kernel the report will focus on.
On a running system is easy to check if the kernel tainted itself: if cat /proc/sys/kernel/tainted returns '0' then the kernel is not tainted and everything is fine. Checking that file is impossible in some situations; that's why the kernel also mentions the taint status when it reports an internal problem (a 'kernel bug'), a recoverable error (a 'kernel Oops') or a non-recoverable error before halting operation (a 'kernel panic'). Look near the top of the error messages printed when one of these occurs and search for a line starting with 'CPU:'. It should end with 'Not tainted' if the kernel was not tainted when it noticed the problem; it was tainted if you see 'Tainted:' followed by a few spaces and some letters.
If your kernel is tainted, study Documentation/admin-guide/tainted-kernels.rst to find out why. Try to eliminate the reason. Often it's caused by one these three things:
A recoverable error (a 'kernel Oops') occurred and the kernel tainted itself, as the kernel knows it might misbehave in strange ways after that point. In that case check your kernel or system log and look for a section that starts with this:
Oops: 0000 [#1] SMPThat's the first Oops since boot-up, as the '#1' between the brackets shows. Every Oops and any other problem that happens after that point might be a follow-up problem to that first Oops, even if both look totally unrelated. Rule this out by getting rid of the cause for the first Oops and reproducing the issue afterwards. Sometimes simply restarting will be enough, sometimes a change to the configuration followed by a reboot can eliminate the Oops. But don't invest too much time into this at this point of the process, as the cause for the Oops might already be fixed in the newer Linux kernel version you are going to install later in this process.
Your system uses a software that installs its own kernel modules, for example Nvidia's proprietary graphics driver or VirtualBox. The kernel taints itself when it loads such module from external sources (even if they are Open Source): they sometimes cause errors in unrelated kernel areas and thus might be causing the issue you face. You therefore have to prevent those modules from loading when you want to report an issue to the Linux kernel developers. Most of the time the easiest way to do that is: temporarily uninstall such software including any modules they might have installed. Afterwards reboot.
The kernel also taints itself when it's loading a module that resides in the staging tree of the Linux kernel source. That's a special area for code (mostly drivers) that does not yet fulfill the normal Linux kernel quality standards. When you report an issue with such a module it's obviously okay if the kernel is tainted; just make sure the module in question is the only reason for the taint. If the issue happens in an unrelated area reboot and temporarily block the module from being loaded by specifying
foo.blacklist=1as kernel parameter (replace 'foo' with the name of the module in question).
Document how to reproduce issue #
Write down coarsely how to reproduce the issue. If you deal with multiple issues at once, create separate notes for each of them and make sure they work independently on a freshly booted system. That's needed, as each issue needs to get reported to the kernel developers separately, unless they are strongly entangled.
If you deal with multiple issues at once, you'll have to report each of them separately, as they might be handled by different developers. Describing various issues in one report also makes it quite difficult for others to tear it apart. Hence, only combine issues in one report if they are very strongly entangled.
Additionally, during the reporting process you will have to test if the issue happens with other kernel versions. Therefore, it will make your work easier if you know exactly how to reproduce an issue quickly on a freshly booted system.
Note: it's often fruitless to report issues that only happened once, as they might be caused by a bit flip due to cosmic radiation. That's why you should try to rule that out by reproducing the issue before going further. Feel free to ignore this advice if you are experienced enough to tell a one-time error due to faulty hardware apart from a kernel issue that rarely happens and thus is hard to reproduce.
Regression in stable or longterm kernel? #
If you are facing a regression within a stable or longterm version line (say something broke when updating from 5.10.4 to 5.10.5), scroll down to 'Dealing with regressions within a stable and longterm kernel line'.
Regression within a stable and longterm kernel version line are something the Linux developers want to fix badly, as such issues are even more unwanted than regression in the main development branch, as they can quickly affect a lot of people. The developers thus want to learn about such issues as quickly as possible, hence there is a streamlined process to report them. Note, regressions with newer kernel version line (say something broke when switching from 5.9.15 to 5.10.5) do not qualify.
Check where you need to report your issue #
Locate the driver or kernel subsystem that seems to be causing the issue. Find out how and where its developers expect reports. Note: most of the time this won't be bugzilla.kernel.org, as issues typically need to be sent by mail to a maintainer and a public mailing list.
It's crucial to send your report to the right people, as the Linux kernel is a big project and most of its developers are only familiar with a small subset of it. Quite a few programmers for example only care for just one driver, for example one for a WiFi chip; its developer likely will only have small or no knowledge about the internals of remote or unrelated "subsystems", like the TCP stack, the PCIe/PCI subsystem, memory management or file systems.
Problem is: the Linux kernel lacks a central bug tracker where you can simply file your issue and make it reach the developers that need to know about it. That's why you have to find the right place and way to report issues yourself. You can do that with the help of a script (see below), but it mainly targets kernel developers and experts. For everybody else the MAINTAINERS file is the better place.
How to read the MAINTAINERS file #
To illustrate how to use the MAINTAINERS file, let's assume the WiFi in your Laptop suddenly misbehaves after updating the kernel. In that case it's likely an issue in the WiFi driver. Obviously it could also be some code it builds upon, but unless you suspect something like that stick to the driver. If it's really something else, the driver's developers will get the right people involved.
Sadly, there is no way to check which code is driving a particular hardware component that is both universal and easy.
In case of a problem with the WiFi driver you for example might want to look at the output of lspci -k, as it lists devices on the PCI/PCIe bus and the kernel module driving it:
[user@something ~]$ lspci -k
[...]
3a:00.0 Network controller: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter (rev 32)
Subsystem: Bigfoot Networks, Inc. Device 1535
Kernel driver in use: ath10k_pci
Kernel modules: ath10k_pci
[...]
But this approach won't work if your WiFi chip is connected over USB or some other internal bus. In those cases you might want to check your WiFi manager or the output of ip link. Look for the name of the problematic network interface, which might be something like 'wlp58s0'. This name can be used like this to find the module driving it:
[user@something ~]$ realpath --relative-to=/sys/module/ /sys/class/net/wlp58s0/device/driver/module
ath10k_pci
In case tricks like these don't bring you any further, try to search the internet on how to narrow down the driver or subsystem in question. And if you are unsure which it is: just try your best guess, somebody will help you if you guessed poorly.
Once you know the driver or subsystem, you want to search for it in the MAINTAINERS file. In the case of 'ath10k_pci' you won't find anything, as the name is too specific. Sometimes you will need to search on the net for help; but before doing so, try a somewhat shorted or modified name when searching the MAINTAINERS file, as then you might find something like this:
QUALCOMM ATHEROS ATH10K WIRELESS DRIVER
Mail: A. Some Human <shuman@example.com>
Mailing list: ath10k@lists.infradead.org
Status: Supported
Web-page: https://wireless.wiki.kernel.org/en/users/Drivers/ath10k
SCM: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
Files: drivers/net/wireless/ath/ath10k/
Note: the line description will be abbreviations, if you read the plain MAINTAINERS file found in the root of the Linux source tree. 'Mail:' for example will be 'M:', 'Mailing list:' will be 'L', and 'Status:' will be 'S:'. A section near the top of the file explains these and other abbreviations.
First look at the line 'Status'. Ideally it should be 'Supported' or 'Maintained'. If it states 'Obsolete' then you are using some outdated approach that was replaced by a newer solution you need to switch to. Sometimes the code only has someone who provides 'Odd Fixes' when feeling motivated. And with 'Orphan' you are totally out of luck, as nobody takes care of the code anymore. That only leaves these options: arrange yourself to live with the issue, fix it yourself, or find a programmer somewhere willing to fix it.
After checking the status, look for a line starting with 'bugs:': it will tell you where to find a subsystem specific bug tracker to file your issue. The example above does not have such a line. That is the case for most sections, as Linux kernel development is completely driven by mail. Very few subsystems use a bug tracker, and only some of those rely on bugzilla.kernel.org.
In this and many other cases you thus have to look for lines starting with 'Mail:' instead. Those mention the name and the email addresses for the maintainers of the particular code. Also look for a line starting with 'Mailing list:', which tells you the public mailing list where the code is developed. Your report later needs to go by mail to those addresses. Additionally, for all issue reports sent by email, make sure to add the Linux Kernel Mailing List (LKML) <linux-kernel@vger.kernel.org> to CC. Don't omit either of the mailing lists when sending your issue report by mail later! Maintainers are busy people and might leave some work for other developers on the subsystem specific list; and LKML is important to have one place where all issue reports can be found.
Finding the maintainers with the help of a script #
For people that have the Linux sources at hand there is a second option to find the proper place to report: the script 'scripts/get_maintainer.pl' which tries to find all people to contact. It queries the MAINTAINERS file and needs to be called with a path to the source code in question. For drivers compiled as module if often can be found with a command like this:
$ modinfo ath10k_pci | grep filename | sed 's!/lib/modules/.*/kernel/!!; s!filename:!!; s!\.ko\(\|\.xz\)!!'
drivers/net/wireless/ath/ath10k/ath10k_pci.ko
Pass parts of this to the script:
$ ./scripts/get_maintainer.pl -f drivers/net/wireless/ath/ath10k*
Some Human <shuman@example.com> (supporter:QUALCOMM ATHEROS ATH10K WIRELESS DRIVER)
Another S. Human <asomehuman@example.com> (maintainer:NETWORKING DRIVERS)
ath10k@lists.infradead.org (open list:QUALCOMM ATHEROS ATH10K WIRELESS DRIVER)
linux-wireless@vger.kernel.org (open list:NETWORKING DRIVERS (WIRELESS))
netdev@vger.kernel.org (open list:NETWORKING DRIVERS)
linux-kernel@vger.kernel.org (open list)
Don't sent your report to all of them. Send it to the maintainers, which the script calls "supporter:"; additionally CC the most specific mailing list for the code as well as the Linux Kernel Mailing List (LKML). In this case you thus would need to send the report to 'Some Human <shuman@example.com>' with 'ath10k@lists.infradead.org' and 'linux-kernel@vger.kernel.org' in CC.
Note: in case you cloned the Linux sources with git you might want to call get_maintainer.pl a second time with --git. The script then will look at the commit history to find which people recently worked on the code in question, as they might be able to help. But use these results with care, as it can easily send you in a wrong direction. That for example happens quickly in areas rarely changed (like old or unmaintained drivers): sometimes such code is modified during tree-wide cleanups by developers that do not care about the particular driver at all.
Search for existing reports, second run #
Search the archives of the bug tracker or mailing list in question thoroughly for reports that might match your issue. If you find anything, join the discussion instead of sending a new report.
As mentioned earlier already: reporting an issue that someone else already brought forward is often a waste of time for everyone involved, especially you as the reporter. That's why you should search for existing report again, now that you know where they need to be reported to. If it's mailing list, you will often find its archives on lore.kernel.org.
But some list are hosted in different places. That for example is the case for the ath10k WiFi driver used as example in the previous step. But you'll often find the archives for these lists easily on the net. Searching for 'archive ath10k@lists.infradead.org' for example will lead you to the Info page for the ath10k mailing list, which at the top links to its list archives. Sadly this and quite a few other lists miss a way to search the archives. In those cases use a regular internet search engine and add something like 'site:lists.infradead.org/pipermail/ath10k/' to your search terms, which limits the results to the archives at that URL.
It's also wise to check the internet, LKML and maybe bugzilla.kernel.org again at this point. If your report needs to be filed in a bug tracker, you may want to check the mailing list archives for the subsystem as well, as someone might have reported it only there.
For details how to search and what to do if you find matching reports see "Search for existing reports, first run" above.
Do not hurry with this step of the reporting process: spending 30 to 60 minutes or even more time can save you and others quite a lot of time and trouble.
Install a fresh kernel for testing #
Unless you are already running the latest 'mainline' Linux kernel, better go and install it for the reporting process. Testing and reporting with the latest 'stable' Linux can be an acceptable alternative in some situations; during the merge window that actually might be even the best approach, but in that development phase it can be an even better idea to suspend your efforts for a few days anyway. Whatever version you choose, ideally use a 'vanilla' built. Ignoring these advices will dramatically increase the risk your report will be rejected or ignored.
As mentioned in the detailed explanation for the first step already: Like most programmers, Linux kernel developers don't like to spend time dealing with reports for issues that don't even happen with the current code. It's just a waste everybody's time, especially yours. That's why it's in everybody's interest that you confirm the issue still exists with the latest upstream code before reporting it. You are free to ignore this advice, but as outlined earlier: doing so dramatically increases the risk that your issue report might get rejected or simply ignored.
In the scope of the kernel "latest upstream" normally means:
Install a mainline kernel; the latest stable kernel can be an option, but most of the time is better avoided. Longterm kernels (sometimes called 'LTS kernels') are unsuitable at this point of the process. The next subsection explains all of this in more detail.
The over next subsection describes way to obtain and install such a kernel. It also outlines that using a pre-compiled kernel are fine, but better are vanilla, which means: it was built using Linux sources taken straight from kernel.org and not modified or enhanced in any way.
Choosing the right version for testing #
Head over to kernel.org to find out which version you want to use for testing. Ignore the big yellow button that says 'Latest release' and look a little lower at the table. At its top you'll see a line starting with mainline, which most of the time will point to a pre-release with a version number like '5.8-rc2'. If that's the case, you'll want to use this mainline kernel for testing, as that where all fixes have to be applied first. Do not let that 'rc' scare you, these 'development kernels' are pretty reliable — and you made a backup, as you were instructed above, didn't you?
In about two out of every nine to ten weeks, mainline might point you to a proper release with a version number like '5.7'. If that happens, consider suspending the reporting process until the first pre-release of the next version (5.8-rc1) shows up on kernel.org. That's because the Linux development cycle then is in its two-week long 'merge window'. The bulk of the changes and all intrusive ones get merged for the next release during this time. It's a bit more risky to use mainline during this period. Kernel developers are also often quite busy then and might have no spare time to deal with issue reports. It's also quite possible that one of the many changes applied during the merge window fixes the issue you face; that's why you soon would have to retest with a newer kernel version anyway, as outlined below in the section 'Duties after the report went out'.
That's why it might make sense to wait till the merge window is over. But don't to that if you're dealing with something that shouldn't wait. In that case consider obtaining the latest mainline kernel via git (see below) or use the latest stable version offered on kernel.org. Using that is also acceptable in case mainline for some reason does currently not work for you. An in general: using it for reproducing the issue is also better than not reporting it issue at all.
Better avoid using the latest stable kernel outside merge windows, as all fixes must be applied to mainline first. That's why checking the latest mainline kernel is so important: any issue you want to see fixed in older version lines needs to be fixed in mainline first before it can get backported, which can take a few days or weeks. Another reason: the fix you hope for might be too hard or risky for backporting; reporting the issue again hence is unlikely to change anything.
These aspects are also why longterm kernels (sometimes called "LTS kernels") are unsuitable for this part of the reporting process: they are to distant from the current code. Hence go and test mainline first and follow the process further: if the issue doesn't occur with mainline it will guide you how to get it fixed in older version lines, if that's in the cards for the fix in question.
How to obtain a fresh Linux kernel #
Using a pre-compiled kernel: This is often the quickest, easiest, and safest way for testing — especially is you are unfamiliar with the Linux kernel. The problem: most of those shipped by distributors or add-on repositories are build from modified Linux sources. They are thus not vanilla and therefore often unsuitable for testing and issue reporting: the changes might cause the issue you face or influence it somehow.
But you are in luck if you are using a popular Linux distribution: for quite a few of them you'll find repositories on the net that contain packages with the latest mainline or stable Linux built as vanilla kernel. It's totally okay to use these, just make sure from the repository's description they are vanilla or at least close to it. Additionally ensure the packages contain the latest versions as offered on kernel.org. The packages are likely unsuitable if they are older than a week, as new mainline and stable kernels typically get released at least once a week.
Please note that you might need to build your own kernel manually later: that's sometimes needed for debugging or testing fixes, as described later in this document. Also be aware that pre-compiled kernels might lack debug symbols that are needed to decode messages the kernel prints when a panic, Oops, warning, or BUG occurs; if you plan to decode those, you might be better off compiling a kernel yourself (see the end of this subsection and the section titled 'Decode failure messages' for details).
Using git: Developers and experienced Linux users familiar with git are often best served by obtaining the latest Linux kernel sources straight from the official development repository on kernel.org. Those are likely a bit ahead of the latest mainline pre-release. Don't worry about it: they are as reliable as a proper pre-release, unless the kernel's development cycle is currently in the middle of a merge window. But even then they are quite reliable.
Conventional: People unfamiliar with git are often best served by downloading the sources as tarball from kernel.org.
How to actually build a kernel is not described here, as many websites explain the necessary steps already. If you are new to it, consider following one of those how-to's that suggest to use make localmodconfig, as that tries to pick up the configuration of your current kernel and then tries to adjust it somewhat for your system. That does not make the resulting kernel any better, but quicker to compile.
Note: If you are dealing with a panic, Oops, warning, or BUG from the kernel, please try to enable CONFIG_KALLSYMS when configuring your kernel. Additionally, enable CONFIG_DEBUG_KERNEL and CONFIG_DEBUG_INFO, too; the latter is the relevant one of those two, but can only be reached if you enable the former. Be aware CONFIG_DEBUG_INFO increases the storage space required to build a kernel by quite a bit. But that's worth it, as these options will allow you later to pinpoint the exact line of code that triggers your issue. The section 'Decode failure messages' below explains this in more detail.
But keep in mind: Always keep a record of the issue encountered in case it is hard to reproduce. Sending an undecoded report is better than not reporting the issue at all.
Check 'taint' flag #
Ensure the kernel you just installed does not 'taint' itself when running.
As outlined above in more detail already: the kernel sets a 'taint' flag when something happens that can lead to follow-up errors that look totally unrelated. That's why you need to check if the kernel you just installed does not set this flag. And if it does, you in almost all the cases needs to eliminate the reason for it before you reporting issues that occur with it. See the section above for details how to do that.
Reproduce issue with the fresh kernel #
Reproduce the issue with the kernel you just installed. If it doesn't show up there, scroll down to the instructions for issues only happening with stable and longterm kernels.
Check if the issue occurs with the fresh Linux kernel version you just installed. If it was fixed there already, consider sticking with this version line and abandoning your plan to report the issue. But keep in mind that other users might still be plagued by it, as long as it's not fixed in either stable and longterm version from kernel.org (and thus vendor kernels derived from those). If you prefer to use one of those or just want to help their users, head over to the section "Details about reporting issues only occurring in older kernel version lines" below.
Optimize description to reproduce issue #
Optimize your notes: try to find and write the most straightforward way to reproduce your issue. Make sure the end result has all the important details, and at the same time is easy to read and understand for others that hear about it for the first time. And if you learned something in this process, consider searching again for existing reports about the issue.
An unnecessarily complex report will make it hard for others to understand your report. Thus try to find a reproducer that's straight forward to describe and thus easy to understand in written form. Include all important details, but at the same time try to keep it as short as possible.
In this in the previous steps you likely have learned a thing or two about the issue you face. Use this knowledge and search again for existing reports instead you can join.
Decode failure messages #
If your failure involves a 'panic', 'Oops', 'warning', or 'BUG', consider decoding the kernel log to find the line of code that triggered the error.
When the kernel detects an internal problem, it will log some information about the executed code. This makes it possible to pinpoint the exact line in the source code that triggered the issue and shows how it was called. But that only works if you enabled CONFIG_DEBUG_INFO and CONFIG_KALLSYMS when configuring your kernel. If you did so, consider to decode the information from the kernel's log. That will make it a lot easier to understand what lead to the 'panic', 'Oops', 'warning', or 'BUG', which increases the chances that someone can provide a fix.
Decoding can be done with a script you find in the Linux source tree. If you are running a kernel you compiled yourself earlier, call it like this:
[user@something ~]$ sudo dmesg | ./linux-5.10.5/scripts/decode_stacktrace.sh ./linux-5.10.5/vmlinux
If you are running a packaged vanilla kernel, you will likely have to install the corresponding packages with debug symbols. Then call the script (which you might need to get from the Linux sources if your distro does not package it) like this:
[user@something ~]$ sudo dmesg | ./linux-5.10.5/scripts/decode_stacktrace.sh \
/usr/lib/debug/lib/modules/5.10.10-4.1.x86_64/vmlinux /usr/src/kernels/5.10.10-4.1.x86_64/
The script will work on log lines like the following, which show the address of the code the kernel was executing when the error occurred:
[ 68.387301] RIP: 0010:test_module_init+0x5/0xffa [test_module]
Once decoded, these lines will look like this:
[ 68.387301] RIP: 0010:test_module_init (/home/username/linux-5.10.5/test-module/test-module.c:16) test_module
In this case the executed code was built from the file '~/linux-5.10.5/test-module/test-module.c' and the error occurred by the instructions found in line '16'.
The script will similarly decode the addresses mentioned in the section starting with 'Call trace', which show the path to the function where the problem occurred. Additionally, the script will show the assembler output for the code section the kernel was executing.
Note, if you can't get this to work, simply skip this step and mention the reason for it in the report. If you're lucky, it might not be needed. And if it is, someone might help you to get things going. Also be aware this is just one of several ways to decode kernel stack traces. Sometimes different steps will be required to retrieve the relevant details. Don't worry about that, if that's needed in your case, developers will tell you what to do.
Special care for regressions #
If your problem is a regression, try to narrow down when the issue was introduced as much as possible.
Linux lead developer Linus Torvalds insists that the Linux kernel never worsens, that's why he deems regressions as unacceptable and wants to see them fixed quickly. That's why changes that introduced a regression are often promptly reverted if the issue they cause can't get solved quickly any other way. Reporting a regression is thus a bit like playing a kind of trump card to get something quickly fixed. But for that to happen the change that's causing the regression needs to be known. Normally it's up to the reporter to track down the culprit, as maintainers often won't have the time or setup at hand to reproduce it themselves.
To find the change there is a process called 'bisection' which the document Documentation/admin-guide/bug-bisect.rst describes in detail. That process will often require you to build about ten to twenty kernel images, trying to reproduce the issue with each of them before building the next. Yes, that takes some time, but don't worry, it works a lot quicker than most people assume. Thanks to a 'binary search' this will lead you to the one commit in the source code management system that's causing the regression. Once you find it, search the net for the subject of the change, its commit id and the shortened commit id (the first 12 characters of the commit id). This will lead you to existing reports about it, if there are any.
Note, a bisection needs a bit of know-how, which not everyone has, and quite a bit of effort, which not everyone is willing to invest. Nevertheless, it's highly recommended performing a bisection yourself. If you really can't or don't want to go down that route at least find out which mainline kernel introduced the regression. If something for example breaks when switching from 5.5.15 to 5.8.4, then try at least all the mainline releases in that area (5.6, 5.7 and 5.8) to check when it first showed up. Unless you're trying to find a regression in a stable or longterm kernel, avoid testing versions which number has three sections (5.6.12, 5.7.8), as that makes the outcome hard to interpret, which might render your testing useless. Once you found the major version which introduced the regression, feel free to move on in the reporting process. But keep in mind: it depends on the issue at hand if the developers will be able to help without knowing the culprit. Sometimes they might recognize from the report want went wrong and can fix it; other times they will be unable to help unless you perform a bisection.
When dealing with regressions make sure the issue you face is really caused by the kernel and not by something else, as outlined above already.
In the whole process keep in mind: an issue only qualifies as regression if the older and the newer kernel got built with a similar configuration. This can be achieved by using make olddefconfig, as explained in more detail by Documentation/admin-guide/reporting-regressions.rst; that document also provides a good deal of other information about regressions you might want to be aware of.
Write and send the report #
Start to compile the report by writing a detailed description about the issue. Always mention a few things: the latest kernel version you installed for reproducing, the Linux Distribution used, and your notes on how to reproduce the issue. Ideally, make the kernel's build configuration (.config) and the output from ``dmesg`` available somewhere on the net and link to it. Include or upload all other information that might be relevant, like the output/screenshot of an Oops or the output from ``lspci``. Once you wrote this main part, insert a normal length paragraph on top of it outlining the issue and the impact quickly. On top of this add one sentence that briefly describes the problem and gets people to read on. Now give the thing a descriptive title or subject that yet again is shorter. Then you're ready to send or file the report like the MAINTAINERS file told you, unless you are dealing with one of those 'issues of high priority': they need special care which is explained in 'Special handling for high priority issues' below.
Now that you have prepared everything it's time to write your report. How to do that is partly explained by the three documents linked to in the preface above. That's why this text will only mention a few of the essentials as well as things specific to the Linux kernel.
There is one thing that fits both categories: the most crucial parts of your report are the title/subject, the first sentence, and the first paragraph. Developers often get quite a lot of mail. They thus often just take a few seconds to skim a mail before deciding to move on or look closer. Thus: the better the top section of your report, the higher are the chances that someone will look into it and help you. And that is why you should ignore them for now and write the detailed report first. ;-)
Things each report should mention #
Describe in detail how your issue happens with the fresh vanilla kernel you installed. Try to include the step-by-step instructions you wrote and optimized earlier that outline how you and ideally others can reproduce the issue; in those rare cases where that's impossible try to describe what you did to trigger it.
Also include all the relevant information others might need to understand the issue and its environment. What's actually needed depends a lot on the issue, but there are some things you should include always:
the output from
cat /proc/version, which contains the Linux kernel version number and the compiler it was built with.the Linux distribution the machine is running (
hostnamectl | grep "Operating System")the architecture of the CPU and the operating system (
uname -mi)if you are dealing with a regression and performed a bisection, mention the subject and the commit-id of the change that is causing it.
In a lot of cases it's also wise to make two more things available to those that read your report:
the configuration used for building your Linux kernel (the '.config' file)
the kernel's messages that you get from
dmesgwritten to a file. Make sure that it starts with a line like 'Linux version 5.8-1 (foobar@example.com) (gcc (GCC) 10.2.1, GNU ld version 2.34) #1 SMP Mon Aug 3 14:54:37 UTC 2020' If it's missing, then important messages from the first boot phase already got discarded. In this case instead consider usingjournalctl -b 0 -k; alternatively you can also reboot, reproduce the issue and calldmesgright afterwards.
These two files are big, that's why it's a bad idea to put them directly into your report. If you are filing the issue in a bug tracker then attach them to the ticket. If you report the issue by mail do not attach them, as that makes the mail too large; instead do one of these things:
Upload the files somewhere public (your website, a public file paste service, a ticket created just for this purpose on bugzilla.kernel.org, ...) and include a link to them in your report. Ideally use something where the files stay available for years, as they could be useful to someone many years from now; this for example can happen if five or ten years from now a developer works on some code that was changed just to fix your issue.
Put the files aside and mention you will send them later in individual replies to your own mail. Just remember to actually do that once the report went out. ;-)
Things that might be wise to provide #
Depending on the issue you might need to add more background data. Here are a few suggestions what often is good to provide:
If you are dealing with a 'warning', an 'OOPS' or a 'panic' from the kernel, include it. If you can't copy'n'paste it, try to capture a netconsole trace or at least take a picture of the screen.
If the issue might be related to your computer hardware, mention what kind of system you use. If you for example have problems with your graphics card, mention its manufacturer, the card's model, and what chip is uses. If it's a laptop mention its name, but try to make sure it's meaningful. 'Dell XPS 13' for example is not, because it might be the one from 2012; that one looks not that different from the one sold today, but apart from that the two have nothing in common. Hence, in such cases add the exact model number, which for example are '9380' or '7390' for XPS 13 models introduced during 2019. Names like 'Lenovo Thinkpad T590' are also somewhat ambiguous: there are variants of this laptop with and without a dedicated graphics chip, so try to find the exact model name or specify the main components.
Mention the relevant software in use. If you have problems with loading modules, you want to mention the versions of kmod, systemd, and udev in use. If one of the DRM drivers misbehaves, you want to state the versions of libdrm and Mesa; also specify your Wayland compositor or the X-Server and its driver. If you have a filesystem issue, mention the version of corresponding filesystem utilities (e2fsprogs, btrfs-progs, xfsprogs, ...).
Gather additional information from the kernel that might be of interest. The output from
lspci -nnwill for example help others to identify what hardware you use. If you have a problem with hardware you even might want to make the output fromsudo lspci -vvvavailable, as that provides insights how the components were configured. For some issues it might be good to include the contents of files like/proc/cpuinfo,/proc/ioports,/proc/iomem,/proc/modules, or/proc/scsi/scsi. Some subsystem also offer tools to collect relevant information. One such tool isalsa-info.shwhich the audio/sound subsystem developers provide.
Those examples should give your some ideas of what data might be wise to attach, but you have to think yourself what will be helpful for others to know. Don't worry too much about forgetting something, as developers will ask for additional details they need. But making everything important available from the start increases the chance someone will take a closer look.
The important part: the head of your report #
Now that you have the detailed part of the report prepared let's get to the most important section: the first few sentences. Thus go to the top, add something like 'The detailed description:' before the part you just wrote and insert two newlines at the top. Now write one normal length paragraph that describes the issue roughly. Leave out all boring details and focus on the crucial parts readers need to know to understand what this is all about; if you think this bug affects a lot of users, mention this to get people interested.
Once you did that insert two more lines at the top and write a one sentence summary that explains quickly what the report is about. After that you have to get even more abstract and write an even shorter subject/title for the report.
Now that you have written this part take some time to optimize it, as it is the most important parts of your report: a lot of people will only read this before they decide if reading the rest is time well spent.
Now send or file the report like the MAINTAINERS file told you, unless it's one of those 'issues of high priority' outlined earlier: in that case please read the next subsection first before sending the report on its way.
Special handling for high priority issues #
Reports for high priority issues need special handling.
Severe issues: make sure the subject or ticket title as well as the first paragraph makes the severeness obvious.
Regressions: make the report's subject start with '[REGRESSION]'.
In case you performed a successful bisection, use the title of the change that introduced the regression as the second part of your subject. Make the report also mention the commit id of the culprit. In case of an unsuccessful bisection, make your report mention the latest tested version that's working fine (say 5.7) and the oldest where the issue occurs (say 5.8-rc1).
When sending the report by mail, CC the Linux regressions mailing list (regressions@lists.linux.dev). In case the report needs to be filed to some web tracker, proceed to do so. Once filed, forward the report by mail to the regressions list; CC the maintainer and the mailing list for the subsystem in question. Make sure to inline the forwarded report, hence do not attach it. Also add a short note at the top where you mention the URL to the ticket.
When mailing or forwarding the report, in case of a successful bisection add the author of the culprit to the recipients; also CC everyone in the signed-off-by chain, which you find at the end of its commit message.
Security issues: for these issues your will have to evaluate if a short-term risk to other users would arise if details were publicly disclosed. If that's not the case simply proceed with reporting the issue as described. For issues that bear such a risk you will need to adjust the reporting process slightly:
If the MAINTAINERS file instructed you to report the issue by mail, do not CC any public mailing lists.
If you were supposed to file the issue in a bug tracker make sure to mark the ticket as 'private' or 'security issue'. If the bug tracker does not offer a way to keep reports private, forget about it and send your report as a private mail to the maintainers instead.
In both cases make sure to also mail your report to the addresses the MAINTAINERS file lists in the section 'security contact'. Ideally directly CC them when sending the report by mail. If you filed it in a bug tracker, forward the report's text to these addresses; but on top of it put a small note where you mention that you filed it with a link to the ticket.
See Documentation/process/security-bugs.rst for more information.
Duties after the report went out #
Wait for reactions and keep the thing rolling until you can accept the outcome in one way or the other. Thus react publicly and in a timely manner to any inquiries. Test proposed fixes. Do proactive testing: retest with at least every first release candidate (RC) of a new mainline version and report your results. Send friendly reminders if things stall. And try to help yourself, if you don't get any help or if it's unsatisfying.
If your report was good and you are really lucky then one of the developers might immediately spot what's causing the issue; they then might write a patch to fix it, test it, and send it straight for integration in mainline while tagging it for later backport to stable and longterm kernels that need it. Then all you need to do is reply with a 'Thank you very much' and switch to a version with the fix once it gets released.
But this ideal scenario rarely happens. That's why the job is only starting once you got the report out. What you'll have to do depends on the situations, but often it will be the things listed below. But before digging into the details, here are a few important things you need to keep in mind for this part of the process.
General advice for further interactions #
Always reply in public: When you filed the issue in a bug tracker, always reply there and do not contact any of the developers privately about it. For mailed reports always use the 'Reply-all' function when replying to any mails you receive. That includes mails with any additional data you might want to add to your report: go to your mail applications 'Sent' folder and use 'reply-all' on your mail with the report. This approach will make sure the public mailing list(s) and everyone else that gets involved over time stays in the loop; it also keeps the mail thread intact, which among others is really important for mailing lists to group all related mails together.
There are just two situations where a comment in a bug tracker or a 'Reply-all' is unsuitable:
Someone tells you to send something privately.
You were told to send something, but noticed it contains sensitive information that needs to be kept private. In that case it's okay to send it in private to the developer that asked for it. But note in the ticket or a mail that you did that, so everyone else knows you honored the request.
Do research before asking for clarifications or help: In this part of the process someone might tell you to do something that requires a skill you might not have mastered yet. For example, you might be asked to use some test tools you never have heard of yet; or you might be asked to apply a patch to the Linux kernel sources to test if it helps. In some cases it will be fine sending a reply asking for instructions how to do that. But before going that route try to find the answer own your own by searching the internet; alternatively consider asking in other places for advice. For example ask a friend or post about it to a chatroom or forum you normally hang out.
Be patient: If you are really lucky you might get a reply to your report within a few hours. But most of the time it will take longer, as maintainers are scattered around the globe and thus might be in a different time zone – one where they already enjoy their night away from keyboard.
In general, kernel developers will take one to five business days to respond to reports. Sometimes it will take longer, as they might be busy with the merge windows, other work, visiting developer conferences, or simply enjoying a long summer holiday.
The 'issues of high priority' (see above for an explanation) are an exception here: maintainers should address them as soon as possible; that's why you should wait a week at maximum (or just two days if it's something urgent) before sending a friendly reminder.
Sometimes the maintainer might not be responding in a timely manner; other times there might be disagreements, for example if an issue qualifies as regression or not. In such cases raise your concerns on the mailing list and ask others for public or private replies how to move on. If that fails, it might be appropriate to get a higher authority involved. In case of a WiFi driver that would be the wireless maintainers; if there are no higher level maintainers or all else fails, it might be one of those rare situations where it's okay to get Linus Torvalds involved.
Proactive testing: Every time the first pre-release (the 'rc1') of a new mainline kernel version gets released, go and check if the issue is fixed there or if anything of importance changed. Mention the outcome in the ticket or in a mail you sent as reply to your report (make sure it has all those in the CC that up to that point participated in the discussion). This will show your commitment and that you are willing to help. It also tells developers if the issue persists and makes sure they do not forget about it. A few other occasional retests (for example with rc3, rc5 and the final) are also a good idea, but only report your results if something relevant changed or if you are writing something anyway.
With all these general things off the table let's get into the details of how to help to get issues resolved once they were reported.
Inquires and testing request #
Here are your duties in case you got replies to your report:
Check who you deal with: Most of the time it will be the maintainer or a developer of the particular code area that will respond to your report. But as issues are normally reported in public it could be anyone that's replying — including people that want to help, but in the end might guide you totally off track with their questions or requests. That rarely happens, but it's one of many reasons why it's wise to quickly run an internet search to see who you're interacting with. By doing this you also get aware if your report was heard by the right people, as a reminder to the maintainer (see below) might be in order later if discussion fades out without leading to a satisfying solution for the issue.
Inquiries for data: Often you will be asked to test something or provide additional details. Try to provide the requested information soon, as you have the attention of someone that might help and risk losing it the longer you wait; that outcome is even likely if you do not provide the information within a few business days.
Requests for testing: When you are asked to test a diagnostic patch or a possible fix, try to test it in timely manner, too. But do it properly and make sure to not rush it: mixing things up can happen easily and can lead to a lot of confusion for everyone involved. A common mistake for example is thinking a proposed patch with a fix was applied, but in fact wasn't. Things like that happen even to experienced testers occasionally, but they most of the time will notice when the kernel with the fix behaves just as one without it.
What to do when nothing of substance happens #
Some reports will not get any reaction from the responsible Linux kernel developers; or a discussion around the issue evolved, but faded out with nothing of substance coming out of it.
In these cases wait two (better: three) weeks before sending a friendly reminder: maybe the maintainer was just away from keyboard for a while when your report arrived or had something more important to take care of. When writing the reminder, kindly ask if anything else from your side is needed to get the ball running somehow. If the report got out by mail, do that in the first lines of a mail that is a reply to your initial mail (see above) which includes a full quote of the original report below: that's on of those few situations where such a 'TOFU' (Text Over, Fullquote Under) is the right approach, as then all the recipients will have the details at hand immediately in the proper order.
After the reminder wait three more weeks for replies. If you still don't get a proper reaction, you first should reconsider your approach. Did you maybe try to reach out to the wrong people? Was the report maybe offensive or so confusing that people decided to completely stay away from it? The best way to rule out such factors: show the report to one or two people familiar with FLOSS issue reporting and ask for their opinion. Also ask them for their advice how to move forward. That might mean: prepare a better report and make those people review it before you send it out. Such an approach is totally fine; just mention that this is the second and improved report on the issue and include a link to the first report.
If the report was proper you can send a second reminder; in it ask for advice why the report did not get any replies. A good moment for this second reminder mail is shortly after the first pre-release (the 'rc1') of a new Linux kernel version got published, as you should retest and provide a status update at that point anyway (see above).
If the second reminder again results in no reaction within a week, try to contact a higher-level maintainer asking for advice: even busy maintainers by then should at least have sent some kind of acknowledgment.
Remember to prepare yourself for a disappointment: maintainers ideally should react somehow to every issue report, but they are only obliged to fix those 'issues of high priority' outlined earlier. So don't be too devastating if you get a reply along the lines of 'thanks for the report, I have more important issues to deal with currently and won't have time to look into this for the foreseeable future'.
It's also possible that after some discussion in the bug tracker or on a list nothing happens anymore and reminders don't help to motivate anyone to work out a fix. Such situations can be devastating, but is within the cards when it comes to Linux kernel development. This and several other reasons for not getting help are explained in 'Why some issues won't get any reaction or remain unfixed after being reported' near the end of this document.
Don't get devastated if you don't find any help or if the issue in the end does not get solved: the Linux kernel is FLOSS and thus you can still help yourself. You for example could try to find others that are affected and team up with them to get the issue resolved. Such a team could prepare a fresh report together that mentions how many you are and why this is something that in your option should get fixed. Maybe together you can also narrow down the root cause or the change that introduced a regression, which often makes developing a fix easier. And with a bit of luck there might be someone in the team that knows a bit about programming and might be able to write a fix.
Reference for "Reporting regressions within a stable and longterm kernel line" #
This subsection provides details for the steps you need to perform if you face a regression within a stable and longterm kernel line.
Make sure the particular version line still gets support #
Check if the kernel developers still maintain the Linux kernel version line you care about: go to the front page of kernel.org and make sure it mentions the latest release of the particular version line without an '[EOL]' tag.
Most kernel version lines only get supported for about three months, as maintaining them longer is quite a lot of work. Hence, only one per year is chosen and gets supported for at least two years (often six). That's why you need to check if the kernel developers still support the version line you care for.
Note, if kernel.org lists two stable version lines on the front page, you should consider switching to the newer one and forget about the older one: support for it is likely to be abandoned soon. Then it will get a "end-of-life" (EOL) stamp. Version lines that reached that point still get mentioned on the kernel.org front page for a week or two, but are unsuitable for testing and reporting.
Search stable mailing list #
Check the archives of the Linux stable mailing list for existing reports.
Maybe the issue you face is already known and was fixed or is about to. Hence, search the archives of the Linux stable mailing list for reports about an issue like yours. If you find any matches, consider joining the discussion, unless the fix is already finished and scheduled to get applied soon.
Reproduce issue with the newest release #
Install the latest release from the particular version line as a vanilla kernel. Ensure this kernel is not tainted and still shows the problem, as the issue might have already been fixed there. If you first noticed the problem with a vendor kernel, check a vanilla build of the last version known to work performs fine as well.
Before investing any more time in this process you want to check if the issue was already fixed in the latest release of version line you're interested in. This kernel needs to be vanilla and shouldn't be tainted before the issue happens, as detailed outlined already above in the section "Install a fresh kernel for testing".
Did you first notice the regression with a vendor kernel? Then changes the vendor applied might be interfering. You need to rule that out by performing a recheck. Say something broke when you updated from 5.10.4-vendor.42 to 5.10.5-vendor.43. Then after testing the latest 5.10 release as outlined in the previous paragraph check if a vanilla build of Linux 5.10.4 works fine as well. If things are broken there, the issue does not qualify as upstream regression and you need switch back to the main step-by-step guide to report the issue.
Report the regression #
Send a short problem report to the Linux stable mailing list (stable@vger.kernel.org) and CC the Linux regressions mailing list (regressions@lists.linux.dev); if you suspect the cause in a particular subsystem, CC its maintainer and its mailing list. Roughly describe the issue and ideally explain how to reproduce it. Mention the first version that shows the problem and the last version that's working fine. Then wait for further instructions.
When reporting a regression that happens within a stable or longterm kernel line (say when updating from 5.10.4 to 5.10.5) a brief report is enough for the start to get the issue reported quickly. Hence a rough description to the stable and regressions mailing list is all it takes; but in case you suspect the cause in a particular subsystem, CC its maintainers and its mailing list as well, because that will speed things up.
And note, it helps developers a great deal if you can specify the exact version that introduced the problem. Hence if possible within a reasonable time frame, try to find that version using vanilla kernels. Let's assume something broke when your distributor released a update from Linux kernel 5.10.5 to 5.10.8. Then as instructed above go and check the latest kernel from that version line, say 5.10.9. If it shows the problem, try a vanilla 5.10.5 to ensure that no patches the distributor applied interfere. If the issue doesn't manifest itself there, try 5.10.7 and then (depending on the outcome) 5.10.8 or 5.10.6 to find the first version where things broke. Mention it in the report and state that 5.10.9 is still broken.
What the previous paragraph outlines is basically a rough manual 'bisection'. Once your report is out your might get asked to do a proper one, as it allows to pinpoint the exact change that causes the issue (which then can easily get reverted to fix the issue quickly). Hence consider to do a proper bisection right away if time permits. See the section 'Special care for regressions' and the document Documentation/admin-guide/bug-bisect.rst for details how to perform one. In case of a successful bisection add the author of the culprit to the recipients; also CC everyone in the signed-off-by chain, which you find at the end of its commit message.
Reference for "Reporting issues only occurring in older kernel version lines" #
This section provides details for the steps you need to take if you could not reproduce your issue with a mainline kernel, but want to see it fixed in older version lines (aka stable and longterm kernels).
Some fixes are too complex #
Prepare yourself for the possibility that going through the next few steps might not get the issue solved in older releases: the fix might be too big or risky to get backported there.
Even small and seemingly obvious code-changes sometimes introduce new and totally unexpected problems. The maintainers of the stable and longterm kernels are very aware of that and thus only apply changes to these kernels that are within rules outlined in Documentation/process/stable-kernel-rules.rst.
Complex or risky changes for example do not qualify and thus only get applied to mainline. Other fixes are easy to get backported to the newest stable and longterm kernels, but too risky to integrate into older ones. So be aware the fix you are hoping for might be one of those that won't be backported to the version line your care about. In that case you'll have no other choice then to live with the issue or switch to a newer Linux version, unless you want to patch the fix into your kernels yourself.
Common preparations #
Perform the first three steps in the section "Reporting issues only occurring in older kernel version lines" above.
You need to carry out a few steps already described in another section of this guide. Those steps will let you:
Check if the kernel developers still maintain the Linux kernel version line you care about.
Search the Linux stable mailing list for exiting reports.
Check with the latest release.
Check code history and search for existing discussions #
Search the Linux kernel version control system for the change that fixed the issue in mainline, as its commit message might tell you if the fix is scheduled for backporting already. If you don't find anything that way, search the appropriate mailing lists for posts that discuss such an issue or peer-review possible fixes; then check the discussions if the fix was deemed unsuitable for backporting. If backporting was not considered at all, join the newest discussion, asking if it's in the cards.
In a lot of cases the issue you deal with will have happened with mainline, but got fixed there. The commit that fixed it would need to get backported as well to get the issue solved. That's why you want to search for it or any discussions abound it.
First try to find the fix in the Git repository that holds the Linux kernel sources. You can do this with the web interfaces on kernel.org or its mirror on GitHub; if you have a local clone you alternatively can search on the command line with
git log --grep=<pattern>.If you find the fix, look if the commit message near the end contains a 'stable tag' that looks like this:
Cc: <stable@vger.kernel.org> # 5.4+
If that's case the developer marked the fix safe for backporting to version line 5.4 and later. Most of the time it's getting applied there within two weeks, but sometimes it takes a bit longer.
If the commit doesn't tell you anything or if you can't find the fix, look again for discussions about the issue. Search the net with your favorite internet search engine as well as the archives for the Linux kernel developers mailing list. Also read the section
Locate kernel area that causes the issueabove and follow the instructions to find the subsystem in question: its bug tracker or mailing list archive might have the answer you are looking for.If you see a proposed fix, search for it in the version control system as outlined above, as the commit might tell you if a backport can be expected.
Check the discussions for any indicators the fix might be too risky to get backported to the version line you care about. If that's the case you have to live with the issue or switch to the kernel version line where the fix got applied.
If the fix doesn't contain a stable tag and backporting was not discussed, join the discussion: mention the version where you face the issue and that you would like to see it fixed, if suitable.
Ask for advice #
One of the former steps should lead to a solution. If that doesn't work out, ask the maintainers for the subsystem that seems to be causing the issue for advice; CC the mailing list for the particular subsystem as well as the stable mailing list.
If the previous three steps didn't get you closer to a solution there is only one option left: ask for advice. Do that in a mail you sent to the maintainers for the subsystem where the issue seems to have its roots; CC the mailing list for the subsystem as well as the stable mailing list (stable@vger.kernel.org).
Why some issues won't get any reaction or remain unfixed after being reported #
When reporting a problem to the Linux developers, be aware only 'issues of high priority' (regressions, security issues, severe problems) are definitely going to get resolved. The maintainers or if all else fails Linus Torvalds himself will make sure of that. They and the other kernel developers will fix a lot of other issues as well. But be aware that sometimes they can't or won't help; and sometimes there isn't even anyone to send a report to.
This is best explained with kernel developers that contribute to the Linux kernel in their spare time. Quite a few of the drivers in the kernel were written by such programmers, often because they simply wanted to make their hardware usable on their favorite operating system.
These programmers most of the time will happily fix problems other people report. But nobody can force them to do, as they are contributing voluntarily.
Then there are situations where such developers really want to fix an issue, but can't: sometimes they lack hardware programming documentation to do so. This often happens when the publicly available docs are superficial or the driver was written with the help of reverse engineering.
Sooner or later spare time developers will also stop caring for the driver. Maybe their test hardware broke, got replaced by something more fancy, or is so old that it's something you don't find much outside of computer museums anymore. Sometimes developer stops caring for their code and Linux at all, as something different in their life became way more important. In some cases nobody is willing to take over the job as maintainer – and nobody can be forced to, as contributing to the Linux kernel is done on a voluntary basis. Abandoned drivers nevertheless remain in the kernel: they are still useful for people and removing would be a regression.
The situation is not that different with developers that are paid for their work on the Linux kernel. Those contribute most changes these days. But their employers sooner or later also stop caring for their code or make its programmer focus on other things. Hardware vendors for example earn their money mainly by selling new hardware; quite a few of them hence are not investing much time and energy in maintaining a Linux kernel driver for something they stopped selling years ago. Enterprise Linux distributors often care for a longer time period, but in new versions often leave support for old and rare hardware aside to limit the scope. Often spare time contributors take over once a company orphans some code, but as mentioned above: sooner or later they will leave the code behind, too.
Priorities are another reason why some issues are not fixed, as maintainers quite often are forced to set those, as time to work on Linux is limited. That's true for spare time or the time employers grant their developers to spend on maintenance work on the upstream kernel. Sometimes maintainers also get overwhelmed with reports, even if a driver is working nearly perfectly. To not get completely stuck, the programmer thus might have no other choice than to prioritize issue reports and reject some of them.
But don't worry too much about all of this, a lot of drivers have active maintainers who are quite interested in fixing as many issues as possible.
Closing words #
Compared with other Free/Libre & Open Source Software it's hard to report issues to the Linux kernel developers: the length and complexity of this document and the implications between the lines illustrate that. But that's how it is for now. The main author of this text hopes documenting the state of the art will lay some groundwork to improve the situation over time.
Reporting regressions
Peios Kernel / Administration / System administration / Troubleshooting and recovery
Peios: The upstream Linux build, report and distribution procedures below apply in that context. Use Building Peios and Peios Standards and Conventions for Peios development and track Peios work in Acta.
"We don't cause regressions" is the first rule of Linux kernel development; Linux founder and lead developer Linus Torvalds established it himself and ensures it's obeyed.
This document describes what the rule means for users and how the Linux kernel's development model ensures to address all reported regressions; aspects relevant for kernel developers are left to Documentation/process/handling-regressions.rst.
The important bits (aka "TL;DR") #
-
It's a regression if something running fine with one Linux kernel works worse or not at all with a newer version. Note, the newer kernel has to be compiled using a similar configuration; the detailed explanations below describes this and other fine print in more detail.
-
Report your issue as outlined in Documentation/admin-guide/reporting-issues.rst, it already covers all aspects important for regressions and repeated below for convenience. Two of them are important: start your report's subject with "[REGRESSION]" and CC or forward it to the regression mailing list (regressions@lists.linux.dev).
-
Optional, but recommended: when sending or forwarding your report, make the Linux kernel regression tracking bot "regzbot" track the issue by specifying when the regression started like this:
#regzbot introduced: v5.13..v5.14-rc1
All the details on Linux kernel regressions relevant for users #
The important basics #
What is a "regression" and what is the "no regressions" rule? #
It's a regression if some application or practical use case running fine with one Linux kernel works worse or not at all with a newer version compiled using a similar configuration. The "no regressions" rule forbids this to take place; if it happens by accident, developers that caused it are expected to quickly fix the issue.
It thus is a regression when a WiFi driver from Linux 5.13 works fine, but with 5.14 doesn't work at all, works significantly slower, or misbehaves somehow. It's also a regression if a perfectly working application suddenly shows erratic behavior with a newer kernel version; such issues can be caused by changes in procfs, sysfs, or one of the many other interfaces Linux provides to userland software. But keep in mind, as mentioned earlier: 5.14 in this example needs to be built from a configuration similar to the one from 5.13. This can be achieved using make olddefconfig, as explained in more detail below.
Note the "practical use case" in the first sentence of this section: developers despite the "no regressions" rule are free to change any aspect of the kernel and even APIs or ABIs to userland, as long as no existing application or use case breaks.
Also be aware the "no regressions" rule covers only interfaces the kernel provides to the userland. It thus does not apply to kernel-internal interfaces like the module API, which some externally developed drivers use to hook into the kernel.
How do I report a regression? #
Just report the issue as outlined in Documentation/admin-guide/reporting-issues.rst, it already describes the important points. The following aspects outlined there are especially relevant for regressions:
When checking for existing reports to join, also search the archives of the Linux regressions mailing list and regzbot's web-interface.
Start your report's subject with "[REGRESSION]".
In your report, clearly mention the last kernel version that worked fine and the first broken one. Ideally try to find the exact change causing the regression using a bisection, as explained below in more detail.
Remember to let the Linux regressions mailing list (regressions@lists.linux.dev) know about your report:
If you report the regression by mail, CC the regressions list.
If you report your regression to some bug tracker, forward the submitted report by mail to the regressions list while CCing the maintainer and the mailing list for the subsystem in question.
If it's a regression within a stable or longterm series (e.g. v5.15.3..v5.15.5), remember to CC the Linux stable mailing list (stable@vger.kernel.org).
In case you performed a successful bisection, add everyone to the CC the culprit's commit message mentions in lines starting with "Signed-off-by:".
When CCing for forwarding your report to the list, consider directly telling the aforementioned Linux kernel regression tracking bot about your report. To do that, include a paragraph like this in your mail:
#regzbot introduced: v5.13..v5.14-rc1
Regzbot will then consider your mail a report for a regression introduced in the specified version range. In above case Linux v5.13 still worked fine and Linux v5.14-rc1 was the first version where you encountered the issue. If you performed a bisection to find the commit that caused the regression, specify the culprit's commit-id instead:
#regzbot introduced: 1f2e3d4c5d
Placing such a "regzbot command" is in your interest, as it will ensure the report won't fall through the cracks unnoticed. If you omit this, the Linux kernel's regressions tracker will take care of telling regzbot about your regression, as long as you send a copy to the regressions mailing lists. But the regression tracker is just one human which sometimes has to rest or occasionally might even enjoy some time away from computers (as crazy as that might sound). Relying on this person thus will result in an unnecessary delay before the regressions becomes mentioned on the list of tracked and unresolved Linux kernel regressions and the weekly regression reports sent by regzbot. Such delays can result in Linus Torvalds being unaware of important regressions when deciding between "continue development or call this finished and release the final?".
Are really all regressions fixed? #
Nearly all of them are, as long as the change causing the regression (the "culprit commit") is reliably identified. Some regressions can be fixed without this, but often it's required.
Who needs to find the root cause of a regression? #
Developers of the affected code area should try to locate the culprit on their own. But for them that's often impossible to do with reasonable effort, as quite a lot of issues only occur in a particular environment outside the developer's reach -- for example, a specific hardware platform, firmware, Linux distro, system's configuration, or application. That's why in the end it's often up to the reporter to locate the culprit commit; sometimes users might even need to run additional tests afterwards to pinpoint the exact root cause. Developers should offer advice and reasonably help where they can, to make this process relatively easy and achievable for typical users.
How can I find the culprit? #
Perform a bisection, as roughly outlined in Documentation/admin-guide/reporting-issues.rst and described in more detail by Documentation/admin-guide/bug-bisect.rst. It might sound like a lot of work, but in many cases finds the culprit relatively quickly. If it's hard or time-consuming to reliably reproduce the issue, consider teaming up with other affected users to narrow down the search range together.
Who can I ask for advice when it comes to regressions? #
Send a mail to the regressions mailing list (regressions@lists.linux.dev) while CCing the Linux kernel's regression tracker (regressions@leemhuis.info); if the issue might better be dealt with in private, feel free to omit the list.
Additional details about regressions #
What is the goal of the "no regressions" rule? #
Users should feel safe when updating kernel versions and not have to worry something might break. This is in the interest of the kernel developers to make updating attractive: they don't want users to stay on stable or longterm Linux series that are either abandoned or more than one and a half years old. That's in everybody's interest, as those series might have known bugs, security issues, or other problematic aspects already fixed in later versions. Additionally, the kernel developers want to make it simple and appealing for users to test the latest pre-release or regular release. That's also in everybody's interest, as it's a lot easier to track down and fix problems, if they are reported shortly after being introduced.
Is the "no regressions" rule really adhered in practice? #
It's taken really seriously, as can be seen by many mailing list posts from Linux creator and lead developer Linus Torvalds, some of which are quoted in Documentation/process/handling-regressions.rst.
Exceptions to this rule are extremely rare; in the past developers almost always turned out to be wrong when they assumed a particular situation was warranting an exception.
Who ensures the "no regressions" rule is actually followed? #
The subsystem maintainers should take care of that, which are watched and supported by the tree maintainers -- e.g. Linus Torvalds for mainline and Greg Kroah-Hartman et al. for various stable/longterm series.
All of them are helped by people trying to ensure no regression report falls through the cracks. One of them is Thorsten Leemhuis, who's currently acting as the Linux kernel's "regressions tracker"; to facilitate this work he relies on regzbot, the Linux kernel regression tracking bot. That's why you want to bring your report on the radar of these people by CCing or forwarding each report to the regressions mailing list, ideally with a "regzbot command" in your mail to get it tracked immediately.
How quickly are regressions normally fixed? #
Developers should fix any reported regression as quickly as possible, to provide affected users with a solution in a timely manner and prevent more users from running into the issue; nevertheless developers need to take enough time and care to ensure regression fixes do not cause additional damage.
The answer thus depends on various factors like the impact of a regression, its age, or the Linux series in which it occurs. In the end though, most regressions should be fixed within two weeks.
Is it a regression, if the issue can be avoided by updating some software? #
Almost always: yes. If a developer tells you otherwise, ask the regression tracker for advice as outlined above.
Is it a regression, if a newer kernel works slower or consumes more energy? #
Yes, but the difference has to be significant. A five percent slow-down in a micro-benchmark thus is unlikely to qualify as regression, unless it also influences the results of a broad benchmark by more than one percent. If in doubt, ask for advice.
Is it a regression, if an external kernel module breaks when updating Linux? #
No, as the "no regression" rule is about interfaces and services the Linux kernel provides to the userland. It thus does not cover building or running externally developed kernel modules, as they run in kernel-space and hook into the kernel using internal interfaces occasionally changed.
How are regressions handled that are caused by security fixes? #
In extremely rare situations security issues can't be fixed without causing regressions; those fixes are given way, as they are the lesser evil in the end. Luckily this middling almost always can be avoided, as key developers for the affected area and often Linus Torvalds himself try very hard to fix security issues without causing regressions.
If you nevertheless face such a case, check the mailing list archives if people tried their best to avoid the regression. If not, report it; if in doubt, ask for advice as outlined above.
What happens if fixing a regression is impossible without causing another? #
Sadly these things happen, but luckily not very often; if they occur, expert developers of the affected code area should look into the issue to find a fix that avoids regressions or at least their impact. If you run into such a situation, do what was outlined already for regressions caused by security fixes: check earlier discussions if people already tried their best and ask for advice if in doubt.
A quick note while at it: these situations could be avoided, if people would regularly give mainline pre-releases (say v5.15-rc1 or -rc3) from each development cycle a test run. This is best explained by imagining a change integrated between Linux v5.14 and v5.15-rc1 which causes a regression, but at the same time is a hard requirement for some other improvement applied for 5.15-rc1. All these changes often can simply be reverted and the regression thus solved, if someone finds and reports it before 5.15 is released. A few days or weeks later this solution can become impossible, as some software might have started to rely on aspects introduced by one of the follow-up changes: reverting all changes would then cause a regression for users of said software and thus is out of the question.
Is it a regression, if some feature I relied on was removed months ago? #
It is, but often it's hard to fix such regressions due to the aspects outlined in the previous section. It hence needs to be dealt with on a case-by-case basis. This is another reason why it's in everybody's interest to regularly test mainline pre-releases.
Does the "no regression" rule apply if I seem to be the only affected person? #
It does, but only for practical usage: the Linux developers want to be free to remove support for hardware only to be found in attics and museums anymore.
Note, sometimes regressions can't be avoided to make progress -- and the latter is needed to prevent Linux from stagnation. Hence, if only very few users seem to be affected by a regression, it for the greater good might be in their and everyone else's interest to lettings things pass. Especially if there is an easy way to circumvent the regression somehow, for example by updating some software or using a kernel parameter created just for this purpose.
Does the regression rule apply for code in the staging tree as well? #
Not according to the help text for the configuration option covering all staging code, which since its early days states:
Please note that these drivers are under heavy development, may or
may not work, and may contain userspace interfaces that most likely
will be changed in the near future.
The staging developers nevertheless often adhere to the "no regressions" rule, but sometimes bend it to make progress. That's for example why some users had to deal with (often negligible) regressions when a WiFi driver from the staging tree was replaced by a totally different one written from scratch.
Why do later versions have to be "compiled with a similar configuration"? #
Because the Linux kernel developers sometimes integrate changes known to cause regressions, but make them optional and disable them in the kernel's default configuration. This trick allows progress, as the "no regressions" rule otherwise would lead to stagnation.
Consider for example a new security feature blocking access to some kernel interfaces often abused by malware, which at the same time are required to run a few rarely used applications. The outlined approach makes both camps happy: people using these applications can leave the new security feature off, while everyone else can enable it without running into trouble.
How to create a configuration similar to the one of an older kernel? #
Start your machine with a known-good kernel and configure the newer Linux version with make olddefconfig. This makes the kernel's build scripts pick up the configuration file (the ".config" file) from the running kernel as base for the new one you are about to compile; afterwards they set all new configuration options to their default value, which should disable new features that might cause regressions.
Can I report a regression I found with pre-compiled vanilla kernels? #
You need to ensure the newer kernel was compiled with a similar configuration file as the older one (see above), as those that built them might have enabled some known-to-be incompatible feature for the newer kernel. If in doubt, report the matter to the kernel's provider and ask for advice.
More about regression tracking with "regzbot" #
What is regression tracking and why should I care about it? #
Rules like "no regressions" need someone to ensure they are followed, otherwise they are broken either accidentally or on purpose. History has shown this to be true for Linux kernel development as well. That's why Thorsten Leemhuis, the Linux Kernel's regression tracker, and some people try to ensure all regression are fixed by keeping an eye on them until they are resolved. Neither of them are paid for this, that's why the work is done on a best effort basis.
Why and how are Linux kernel regressions tracked using a bot? #
Tracking regressions completely manually has proven to be quite hard due to the distributed and loosely structured nature of Linux kernel development process. That's why the Linux kernel's regression tracker developed regzbot to facilitate the work, with the long term goal to automate regression tracking as much as possible for everyone involved.
Regzbot works by watching for replies to reports of tracked regressions. Additionally, it's looking out for posted or committed patches referencing such reports with "Link:" tags; replies to such patch postings are tracked as well. Combined this data provides good insights into the current state of the fixing process.
How to see which regressions regzbot tracks currently? #
Check out regzbot's web-interface.
What kind of issues are supposed to be tracked by regzbot? #
The bot is meant to track regressions, hence please don't involve regzbot for regular issues. But it's okay for the Linux kernel's regression tracker if you involve regzbot to track severe issues, like reports about hangs, corrupted data, or internal errors (Panic, Oops, BUG(), warning, ...).
How to change aspects of a tracked regression? #
By using a 'regzbot command' in a direct or indirect reply to the mail with the report. The easiest way to do that: find the report in your "Sent" folder or the mailing list archive and reply to it using your mailer's "Reply-all" function. In that mail, use one of the following commands in a stand-alone paragraph (IOW: use blank lines to separate one or multiple of these commands from the rest of the mail's text).
Update when the regression started to happen, for example after performing a bisection:
#regzbot introduced: 1f2e3d4c5dSet or update the title:
#regzbot title: fooMonitor a discussion or bugzilla.kernel.org ticket where additions aspects of the issue or a fix are discussed::
#regzbot monitor: https://lore.kernel.org/r/30th.anniversary.repost@klaava.Helsinki.FI/ #regzbot monitor: https://bugzilla.kernel.org/show_bug.cgi?id=123456789Point to a place with further details of interest, like a mailing list post or a ticket in a bug tracker that are slightly related, but about a different topic:
#regzbot link: https://bugzilla.kernel.org/show_bug.cgi?id=123456789Mark a regression as invalid:
#regzbot invalid: wasn't a regression, problem has always existed
Regzbot supports a few other commands primarily used by developers or people tracking regressions. They and more details about the aforementioned regzbot commands can be found in the getting started guide and the reference documentation for regzbot.
Linux Magic System Request Key Hacks
Peios Kernel / Administration / System administration / Troubleshooting and recovery
Documentation for sysrq.c
What is the magic SysRq key? #
It is a 'magical' key combo you can hit which the kernel will respond to regardless of whatever else it is doing, unless it is completely locked up.
How do I enable the magic SysRq key? #
You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' when configuring the kernel. When running a kernel with SysRq compiled in, /proc/sys/kernel/sysrq controls the functions allowed to be invoked via the SysRq key. The default value in this file is set by the CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE config symbol, which itself defaults to 1. Here is the list of possible values in /proc/sys/kernel/sysrq:
0 - disable sysrq completely
1 - enable all functions of sysrq
>1 - bitmask of allowed sysrq functions (see below for detailed function description):
2 = 0x2 - enable control of console logging level 4 = 0x4 - enable control of keyboard (SAK, unraw) 8 = 0x8 - enable debugging dumps of processes etc. 16 = 0x10 - enable sync command 32 = 0x20 - enable remount read-only 64 = 0x40 - enable signalling of processes (term, kill, oom-kill) 128 = 0x80 - allow reboot/poweroff 256 = 0x100 - allow nicing of all RT tasks
You can set the value in the file by the following command:
echo "number" >/proc/sys/kernel/sysrq
The number may be written here either as decimal or as hexadecimal with the 0x prefix. CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE must always be written in hexadecimal.
Note that the value of /proc/sys/kernel/sysrq influences only the invocation via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always allowed (by a user with admin privileges).
How do I use the magic SysRq key? #
-
On x86
You press the key combo
ALT-SysRq-<command key>. -
On SPARC
You press
ALT-STOP-<command key>, I believe. -
On the serial console (PC style standard serial ports only)
You send a
BREAK, then within 5 seconds a command key. SendingBREAKtwice is interpreted as a normal BREAK. -
On PowerPC
Press
ALT - Print Screen(orF13) -<command key>.Print Screen(orF13) -<command key>may suffice. -
On other
If you know of the key combos for other architectures, please submit a patch to be included in this section.
-
On all
Write a single character to /proc/sysrq-trigger. Only the first character is processed, the rest of the string is ignored. However, it is not recommended to write any extra characters as the behavior is undefined and might change in the future versions. E.g.:
echo t > /proc/sysrq-triggerAlternatively, write multiple characters prepended by underscore. This way, all characters will be processed. E.g.:
echo _reisub > /proc/sysrq-trigger
The <command key> is case sensitive.
What are the 'command' keys? #
|
Command |
Function |
|---|---|
|
|
Will immediately reboot the system without syncing or unmounting your disks. |
|
|
Will perform a system crash and a crashdump will be taken if configured. |
|
|
Shows all locks that are held. |
|
|
Send a SIGTERM to all processes, except for init. |
|
|
Will call the oom killer to kill a memory hog process, but do not panic if nothing can be killed. |
|
|
Used by kgdb (kernel debugger) |
|
|
Will display help (actually any other key than those listed here will display help. but |
|
|
Send a SIGKILL to all processes, except for init. |
|
|
Forcibly "Just thaw it" - filesystems frozen by the FIFREEZE ioctl. |
|
|
Secure Access Key (SAK) Kills all programs on the current virtual console. NOTE: See important comments below in SAK section. |
|
|
Shows a stack backtrace for all active CPUs. |
|
|
Will dump current memory info to your console. |
|
|
Used to make RT tasks nice-able |
|
|
Will shut your system off (if configured and supported). |
|
|
Will dump the current registers and flags to your console. |
|
|
Will dump per CPU lists of all armed hrtimers (but NOT regular timer_list timers) and detailed information about all clockevent devices. |
|
|
Turns off keyboard raw mode and sets it to XLATE. |
|
|
Will attempt to sync all mounted filesystems. |
|
|
Will dump a list of current tasks and their information to your console. |
|
|
Will attempt to remount all mounted filesystems read-only. |
|
|
Forcefully restores framebuffer console |
|
|
Causes ETM buffer dump [ARM-specific] |
|
|
Dumps tasks that are in uninterruptible (blocked) state. |
|
|
Used by xmon interface on ppc/powerpc platforms. Show global PMU Registers on sparc64. Dump all TLB entries on MIPS. |
|
|
Show global CPU Registers [SPARC-64 specific] |
|
|
Dump the ftrace buffer |
|
|
Sets the console log level, controlling which kernel messages will be printed to your console. ( |
|
|
Replay the kernel log messages on consoles. |
Okay, so what can I use them for? #
Well, unraw(r) is very handy when your X server or a svgalib program crashes.
sak(k) (Secure Access Key) is useful when you want to be sure there is no trojan program running at console which could grab your password when you would try to login. It will kill all programs on given console, thus letting you make sure that the login prompt you see is actually the one from init, not some trojan program.
It seems others find it useful as (System Attention Key) which is useful when you want to exit a program that will not let you switch consoles. (For example, X or a svgalib program.)
reboot(b) is good when you're unable to shut down, it is an equivalent of pressing the "reset" button.
crash(c) can be used to manually trigger a crashdump when the system is hung. Note that this just triggers a crash if there is no dump mechanism available.
sync(s) is handy before yanking removable medium or after using a rescue shell that provides no graceful shutdown -- it will ensure your data is safely written to the disk. Note that the sync hasn't taken place until you see the "OK" and "Done" appear on the screen.
umount(u) can be used to mark filesystems as properly unmounted. From the running system's point of view, they will be remounted read-only. The remount isn't complete until you see the "OK" and "Done" message appear on the screen.
The loglevels 0-9 are useful when your console is being flooded with kernel messages you do not want to see. Selecting 0 will prevent all but the most urgent kernel messages from reaching your console. (They will still be logged if syslogd/klogd are alive, though.)
term(e) and kill(i) are useful if you have some sort of runaway process you are unable to kill any other way, especially if it's spawning other processes.
"just thaw it(j)" is useful if your system becomes unresponsive due to a frozen (probably root) filesystem via the FIFREEZE ioctl.
Replay logs(R) is useful to view the kernel log messages when system is hung or you are not able to use dmesg command to view the messages in printk buffer. User may have to press the key combination multiple times if console system is busy. If it is completely locked up, then messages won't be printed. Output messages depend on current console loglevel, which can be modified using sysrq[0-9] (see above).
Sometimes SysRq seems to get 'stuck' after using it, what can I do? #
When this happens, try tapping shift, alt and control on both sides of the keyboard, and hitting an invalid sysrq sequence again. (i.e., something like alt-sysrq-z).
Switching to another virtual console (ALT+Fn) and then back again should also help.
I hit SysRq, but nothing seems to happen, what's wrong? #
There are some keyboards that produce a different keycode for SysRq than the pre-defined value of 99 (see KEY_SYSRQ in include/uapi/linux/input-event-codes.h), or which don't have a SysRq key at all. In these cases, run showkey -s to find an appropriate scancode sequence, and use setkeycodes <sequence> 99 to map this sequence to the usual SysRq code (e.g., setkeycodes e05b 99). It's probably best to put this command in a boot script. Oh, and by the way, you exit showkey by not typing anything for ten seconds.
I want to add SysRQ key events to a module, how does it work? #
In order to register a basic function with the table, you must first include the header include/linux/sysrq.h, this will define everything else you need. Next, you must create a sysrq_key_op struct, and populate it with A) the key handler function you will use, B) a help_msg string, that will print when SysRQ prints help, and C) an action_msg string, that will print right before your handler is called. Your handler must conform to the prototype in 'sysrq.h'.
After the sysrq_key_op is created, you can call the kernel function register_sysrq_key(int key, const struct sysrq_key_op *op_p); this will register the operation pointed to by op_p at table key 'key', if that slot in the table is blank. At module unload time, you must call the function unregister_sysrq_key(int key, const struct sysrq_key_op *op_p), which will remove the key op pointed to by 'op_p' from the key 'key', if and only if it is currently registered in that slot. This is in case the slot has been overwritten since you registered it.
The Magic SysRQ system works by registering key operations against a key op lookup table, which is defined in 'drivers/tty/sysrq.c'. This key table has a number of operations registered into it at compile time, but is mutable, and 2 functions are exported for interface to it:
register_sysrq_key and unregister_sysrq_key.
Of course, never ever leave an invalid pointer in the table. I.e., when your module that called register_sysrq_key() exits, it must call unregister_sysrq_key() to clean up the sysrq key table entry that it used. Null pointers in the table are always safe. :)
If for some reason you feel the need to call the handle_sysrq function from within a function called by handle_sysrq, you must be aware that you are in a lock (you are also in an interrupt handler, which means don't sleep!), so you must call __handle_sysrq_nolock instead.
When I hit a SysRq key combination only the header appears on the console? #
Sysrq output is subject to the same console loglevel control as all other console output. This means that if the kernel was booted 'quiet' as is common on distro kernels the output may not appear on the actual console, even though it will appear in the dmesg buffer, and be accessible via the dmesg command and to the consumers of /proc/kmsg. As a specific exception the header line from the sysrq command is passed to all console consumers as if the current loglevel was maximum. If only the header is emitted it is almost certain that the kernel loglevel is too low. Should you require the output on the console channel then you will need to temporarily up the console loglevel using alt-sysrq-8 or:
echo 8 > /proc/sysrq-trigger
Remember to return the loglevel to normal after triggering the sysrq command you are interested in.
I have more questions, who can I ask? #
-
Just ask them on the linux-kernel mailing list:
Credits #
-
Written by Mydraal <vulpyne@vulpyne.net>
-
Updated by Adam Sulmicki <adam@cfar.umd.edu>
-
Updated by Jeremy M. Dolan <jmd@turbogeek.org> 2001/01/28 10:15:59
-
Added to by Crutcher Dunnavant <crutcher+kernel@datastacks.com>
Tainted kernels
Peios Kernel / Administration / System administration / Troubleshooting and recovery
The kernel will mark itself as 'tainted' when something occurs that might be relevant later when investigating problems. Don't worry too much about this, most of the time it's not a problem to run a tainted kernel; the information is mainly of interest once someone wants to investigate some problem, as its real cause might be the event that got the kernel tainted. That's why bug reports from tainted kernels will often be ignored by developers, hence try to reproduce problems with an untainted kernel.
Note the kernel will remain tainted even after you undo what caused the taint (i.e. unload a proprietary kernel module), to indicate the kernel remains not trustworthy. That's also why the kernel will print the tainted state when it notices an internal problem (a 'kernel bug'), a recoverable error ('kernel oops') or a non-recoverable error ('kernel panic') and writes debug information about this to the logs dmesg outputs. It's also possible to check the tainted state at runtime through a file in /proc/.
Tainted flag in bugs, oops or panics messages #
You find the tainted state near the top in a line starting with 'CPU:'; if or why the kernel was tainted is shown after the Process ID ('PID:') and a shortened name of the command ('Comm:') that triggered the event:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
Oops: 0002 [#1] SMP PTI
CPU: 0 PID: 4424 Comm: insmod Tainted: P W O 4.20.0-0.rc6.fc30 #1
Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
RIP: 0010:my_oops_init+0x13/0x1000 [kpanic]
[...]
You'll find a 'Not tainted: ' there if the kernel was not tainted at the time of the event; if it was, then it will print 'Tainted: ' and characters either letters or blanks. In the example above it looks like this:
Tainted: P W O
The meaning of those characters is explained in the table below. In this case the kernel got tainted earlier because a proprietary Module (P) was loaded, a warning occurred (W), and an externally-built module was loaded (O). To decode other letters use the table below.
Decoding tainted state at runtime #
At runtime, you can query the tainted state by reading cat /proc/sys/kernel/tainted. If that returns 0, the kernel is not tainted; any other number indicates the reasons why it is. The easiest way to decode that number is the script tools/debugging/kernel-chktaint, which your distribution might ship as part of a package called linux-tools or kernel-tools; if it doesn't, you can download the script from git.kernel.org and execute it with sh kernel-chktaint, which would print something like this on the machine that had the statements in the logs that were quoted earlier:
Kernel is Tainted for following reasons:
* Proprietary module was loaded (#0)
* Kernel issued warning (#9)
* Externally-built ('out-of-tree') module was loaded (#12)
See Documentation/admin-guide/tainted-kernels.rst in the Linux kernel or
https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html for
a more details explanation of the various taint flags.
Raw taint value as int/string: 4609/'P W O '
You can try to decode the number yourself. That's easy if there was only one reason that got your kernel tainted, as in this case you can find the number with the table below. If there were multiple reasons you need to decode the number, as it is a bitfield, where each bit indicates the absence or presence of a particular type of taint. It's best to leave that to the aforementioned script, but if you need something quick you can use this shell command to check which bits are set:
$ for i in $(seq 18); do echo $(($i-1)) $(($(cat /proc/sys/kernel/tainted)>>($i-1)&1));done
Table for decoding tainted state #
|
Bit |
Log |
Number |
Reason that got the kernel tainted |
|---|---|---|---|
|
0 |
G/P |
1 |
proprietary module was loaded |
|
1 |
_/F |
2 |
module was force loaded |
|
2 |
_/S |
4 |
kernel running on an out of specification system |
|
3 |
_/R |
8 |
module was force unloaded |
|
4 |
_/M |
16 |
processor reported a Machine Check Exception (MCE) |
|
5 |
_/B |
32 |
bad page referenced or some unexpected page flags |
|
6 |
_/U |
64 |
taint requested by userspace application |
|
7 |
_/D |
128 |
kernel died recently, i.e. there was an OOPS or BUG |
|
8 |
_/A |
256 |
ACPI table overridden by user |
|
9 |
_/W |
512 |
kernel issued warning |
|
10 |
_/C |
1024 |
staging driver was loaded |
|
11 |
_/I |
2048 |
workaround for bug in platform firmware applied |
|
12 |
_/O |
4096 |
externally-built ("out-of-tree") module was loaded |
|
13 |
_/E |
8192 |
unsigned module was loaded |
|
14 |
_/L |
16384 |
soft lockup occurred |
|
15 |
_/K |
32768 |
kernel has been live patched |
|
16 |
_/X |
65536 |
auxiliary taint, defined for and used by distros |
|
17 |
_/T |
131072 |
kernel was built with the struct randomization plugin |
|
18 |
_/N |
262144 |
an in-kernel test has been run |
|
19 |
_/J |
524288 |
userspace used a mutating debug operation in fwctl |
Note: The character _ is representing a blank in this table to make reading easier.
More detailed explanation for tainting #
Gif all modules loaded have a GPL or compatible license,Pif any proprietary module has been loaded. Modules without a MODULE_LICENSE or with a MODULE_LICENSE that is not recognised by insmod as GPL compatible are assumed to be proprietary.
Fif any module was force loaded byinsmod -f,' 'if all modules were loaded normally.
Sif the kernel is running on a processor or system that is out of specification: hardware has been put into an unsupported configuration, therefore proper execution cannot be guaranteed. Kernel will be tainted if, for example:
on x86: PAE is forced through forcepae on intel CPUs (such as Pentium M) which do not report PAE but may have a functional implementation, an SMP kernel is running on non officially capable SMP Athlon CPUs, MSRs are being poked at from userspace.
on arm: kernel running on certain CPUs (such as Keystone 2) without having certain kernel features enabled.
on arm64: there are mismatched hardware features between CPUs, the bootloader has booted CPUs in different modes.
certain drivers are being used on non supported architectures (such as scsi/snic on something else than x86_64, scsi/ips on non x86/x86_64/itanium, have broken firmware settings for the irqchip/irq-gic on arm64 ...).
x86/x86_64: Microcode late loading is dangerous and will result in tainting the kernel. It requires that all CPUs rendezvous to make sure the update happens when the system is as quiescent as possible. However, a higher priority MCE/SMI/NMI can move control flow away from that rendezvous and interrupt the update, which can be detrimental to the machine.
Rif a module was force unloaded byrmmod -f,' 'if all modules were unloaded normally.
Mif any processor has reported a Machine Check Exception,' 'if no Machine Check Exceptions have occurred.
BIf a page-release function has found a bad page reference or some unexpected page flags. This indicates a hardware problem or a kernel bug; there should be other information in the log indicating why this tainting occurred.
Uif a user or user application specifically requested that the Tainted flag be set,' 'otherwise.
Dif the kernel has died recently, i.e. there was an OOPS or BUG.
Aif an ACPI table has been overridden.
Wif a warning has previously been issued by the kernel. (Though some warnings may set more specific taint flags.)
Cif a staging driver has been loaded.
Iif the kernel is working around a severe bug in the platform firmware (BIOS or similar).
Oif an externally-built ("out-of-tree") module has been loaded.
Eif an unsigned module has been loaded in a kernel supporting module signature.
Lif a soft lockup has previously occurred on the system.
Kif the kernel has been live patched.
XAuxiliary taint, defined for and used by Linux distributors.
TKernel was build with the randstruct plugin, which can intentionally produce extremely unusual kernel structure layouts (even performance pathological ones), which is important to know when debugging. Set at build time.
Nif an in-kernel test, such as a KUnit test, has been run.
Jif userspace opened /dev/fwctl/* and performed a FWTCL_RPC_DEBUG_WRITE to use the devices debugging features. Device debugging features could cause the device to malfunction in undefined ways.
How to verify bugs and bisect regressions
Peios Kernel / Administration / System administration / Troubleshooting and recovery
Peios: The upstream Linux build, report and distribution procedures below apply in that context. Use Building Peios and Peios Standards and Conventions for Peios development and track Peios work in Acta.
This document describes how to check if some Linux kernel problem occurs in code currently supported by developers -- to then explain how to locate the change causing the issue, if it is a regression (e.g. did not happen with earlier versions).
The text aims at people running kernels from mainstream Linux distributions on commodity hardware who want to report a kernel bug to the upstream Linux developers. Despite this intent, the instructions work just as well for users who are already familiar with building their own kernels: they help avoid mistakes occasionally made even by experienced developers.
The essence of the process (aka 'TL;DR') #
[If you are new to building or bisecting Linux, ignore this section and head over to the 'step-by-step guide' below. It utilizes the same commands as this section while describing them in brief fashion. The steps are nevertheless easy to follow and together with accompanying entries in a reference section mention many alternatives, pitfalls, and additional aspects, all of which might be essential in your present case.]
In case you want to check if a bug is present in code currently supported by developers, execute just the preparations and segment 1; while doing so, consider the newest Linux kernel you regularly use to be the 'working' kernel. In the following example that's assumed to be 6.0, which is why its sources will be used to prepare the .config file.
In case you face a regression, follow the steps at least till the end of segment 2. Then you can submit a preliminary report -- or continue with segment 3, which describes how to perform a bisection needed for a full-fledged regression report. In the following example 6.0.13 is assumed to be the 'working' kernel and 6.1.5 to be the first 'broken', which is why 6.0 will be considered the 'good' release and used to prepare the .config file.
-
Preparations: set up everything to build your own kernels:
# * Remove any software that depends on externally maintained kernel modules # or builds any automatically during bootup. # * Ensure Secure Boot permits booting self-compiled Linux kernels. # * If you are not already running the 'working' kernel, reboot into it. # * Install compilers and everything else needed for building Linux. # * Ensure to have 15 Gigabyte free space in your home directory. git clone -o mainline --no-checkout \ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ~/linux/ cd ~/linux/ git remote add -t master stable \ https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git git switch --detach v6.0 # * Hint: if you used an existing clone, ensure no stale .config is around. make olddefconfig # * Ensure the former command picked the .config of the 'working' kernel. # * Connect external hardware (USB keys, tokens, ...), start a VM, bring up # VPNs, mount network shares, and briefly try the feature that is broken. yes '' | make localmodconfig ./scripts/config --set-str CONFIG_LOCALVERSION '-local' ./scripts/config -e CONFIG_LOCALVERSION_AUTO # * Note, when short on storage space, check the guide for an alternative: ./scripts/config -d DEBUG_INFO_NONE -e KALLSYMS_ALL -e DEBUG_KERNEL \ -e DEBUG_INFO -e DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT -e KALLSYMS # * Hint: at this point you might want to adjust the build configuration; # you'll have to, if you are running Debian. make olddefconfig cp .config ~/kernel-config-working -
Segment 1: build a kernel from the latest mainline codebase.
This among others checks if the problem was fixed already and which developers later need to be told about the problem; in case of a regression, this rules out a .config change as root of the problem.
-
a) Checking out latest mainline code:
cd ~/linux/ git switch --discard-changes --detach mainline/master -
b) Build, install, and boot a kernel:
cp ~/kernel-config-working .config make olddefconfig make -j $(nproc --all) # * Make sure there is enough disk space to hold another kernel: df -h /boot/ /lib/modules/ # * Note: on Arch Linux, its derivatives and a few other distributions # the following commands will do nothing at all or only part of the # job. See the step-by-step guide for further details. sudo make modules_install command -v installkernel && sudo make install # * Check how much space your self-built kernel actually needs, which # enables you to make better estimates later: du -ch /boot/*$(make -s kernelrelease)* | tail -n 1 du -sh /lib/modules/$(make -s kernelrelease)/ # * Hint: the output of the following command will help you pick the # right kernel from the boot menu: make -s kernelrelease | tee -a ~/kernels-built reboot # * Once booted, ensure you are running the kernel you just built by # checking if the output of the next two commands matches: tail -n 1 ~/kernels-built uname -r cat /proc/sys/kernel/tainted -
c) Check if the problem occurs with this kernel as well.
-
-
Segment 2: ensure the 'good' kernel is also a 'working' kernel.
This among others verifies the trimmed .config file actually works well, as bisecting with it otherwise would be a waste of time:
-
a) Start by checking out the sources of the 'good' version:
cd ~/linux/ git switch --discard-changes --detach v6.0 -
b) Build, install, and boot a kernel as described earlier in segment 1, section b -- just feel free to skip the 'du' commands, as you have a rough estimate already.
-
c) Ensure the feature that regressed with the 'broken' kernel actually works with this one.
-
-
Segment 3: perform and validate the bisection.
-
a) Retrieve the sources for your 'bad' version:
git remote set-branches --add stable linux-6.1.y git fetch stable -
b) Initialize the bisection:
cd ~/linux/ git bisect start git bisect good v6.0 git bisect bad v6.1.5 -
c) Build, install, and boot a kernel as described earlier in segment 1, section b.
In case building or booting the kernel fails for unrelated reasons, run
git bisect skip. In all other outcomes, check if the regressed feature works with the newly built kernel. If it does, tell Git by executinggit bisect good; if it does not, rungit bisect badinstead.All three commands will make Git check out another commit; then re-execute this step (e.g. build, install, boot, and test a kernel to then tell Git the outcome). Do so again and again until Git shows which commit broke things. If you run short of disk space during this process, check the section 'Complementary tasks: cleanup during and after the process' below.
-
d) Once your finished the bisection, put a few things away:
cd ~/linux/ git bisect log > ~/bisect-log cp .config ~/bisection-config-culprit git bisect reset -
e) Try to verify the bisection result:
git switch --discard-changes --detach mainline/master git revert --no-edit cafec0cacaca0 cp ~/kernel-config-working .config ./scripts/config --set-str CONFIG_LOCALVERSION '-local-cafec0cacaca0-reverted'
This is optional, as some commits are impossible to revert. But if the second command worked flawlessly, build, install, and boot one more kernel kernel; just this time skip the first command copying the base .config file over, as that already has been taken care off.
-
-
Complementary tasks: cleanup during and after the process.
-
a) To avoid running out of disk space during a bisection, you might need to remove some kernels you built earlier. You most likely want to keep those you built during segment 1 and 2 around for a while, but you will most likely no longer need kernels tested during the actual bisection (Segment 3 c). You can list them in build order using:
ls -ltr /lib/modules/*-local*
To then for example erase a kernel that identifies itself as '6.0-rc1-local-gcafec0cacaca0', use this:
sudo rm -rf /lib/modules/6.0-rc1-local-gcafec0cacaca0 sudo kernel-install -v remove 6.0-rc1-local-gcafec0cacaca0 # * Note, on some distributions kernel-install is missing # or does only part of the job.- b) If you performed a bisection and successfully validated the result, feel free to remove all kernels built during the actual bisection (Segment 3 c); the kernels you built earlier and later you might want to keep around for a week or two.
-
-
Optional task: test a debug patch or a proposed fix later:
git fetch mainline git switch --discard-changes --detach mainline/master git apply /tmp/foobars-proposed-fix-v1.patch cp ~/kernel-config-working .config ./scripts/config --set-str CONFIG_LOCALVERSION '-local-foobars-fix-v1'Build, install, and boot a kernel as described in segment 1, section b -- but this time omit the first command copying the build configuration over, as that has been taken care of already.
Step-by-step guide on how to verify bugs and bisect regressions #
This guide describes how to set up your own Linux kernels for investigating bugs or regressions you intend to report. How far you want to follow the instructions depends on your issue:
Execute all steps till the end of segment 1 to verify if your kernel problem is present in code supported by Linux kernel developers. If it is, you are all set to report the bug -- unless it did not happen with earlier kernel versions, as then your want to at least continue with segment 2 to check if the issue qualifies as regression which receive priority treatment. Depending on the outcome you then are ready to report a bug or submit a preliminary regression report; instead of the latter your could also head straight on and follow segment 3 to perform a bisection for a full-fledged regression report developers are obliged to act upon.
Preparations: set up everything to build your own kernels.
Segment 1: try to reproduce the problem with the latest codebase.
Segment 2: check if the kernels you build work fine.
Segment 3: perform a bisection and validate the result.
Complementary tasks: cleanup during and after following this guide.
The steps in each segment illustrate the important aspects of the process, while a comprehensive reference section holds additional details for almost all of the steps. The reference section sometimes also outlines alternative approaches, pitfalls, as well as problems that might occur at the particular step -- and how to get things rolling again.
For further details on how to report Linux kernel issues or regressions check out Documentation/admin-guide/reporting-issues.rst, which works in conjunction with this document. It among others explains why you need to verify bugs with the latest 'mainline' kernel (e.g. versions like 6.0, 6.1-rc1, or 6.1-rc6), even if you face a problem with a kernel from a 'stable/longterm' series (say 6.0.13).
For users facing a regression that document also explains why sending a preliminary report after segment 2 might be wise, as the regression and its culprit might be known already. For further details on what actually qualifies as a regression check out Documentation/admin-guide/reporting-regressions.rst.
If you run into any problems while following this guide or have ideas how to improve it, please let the kernel developers know.
Preparations: set up everything to build your own kernels #
The following steps lay the groundwork for all further tasks.
Note: the instructions assume you are building and testing on the same machine; if you want to compile the kernel on another system, check Build kernels on a different machine below.
-
Create a fresh backup and put system repair and restore tools at hand, just to be prepared for the unlikely case of something going sideways.
[details]
-
Remove all software that depends on externally developed kernel drivers or builds them automatically. That includes but is not limited to DKMS, openZFS, VirtualBox, and Nvidia's graphics drivers (including the GPLed kernel module).
[details]
-
On platforms with 'Secure Boot' or similar solutions, prepare everything to ensure the system will permit your self-compiled kernel to boot. The quickest and easiest way to achieve this on commodity x86 systems is to disable such techniques in the BIOS setup utility; alternatively, remove their restrictions through a process initiated by
mokutil --disable-validation.[details]
-
Determine the kernel versions considered 'good' and 'bad' throughout this guide:
-
Do you follow this guide to verify if a bug is present in the code the primary developers care for? Then consider the version of the newest kernel you regularly use currently as 'good' (e.g. 6.0, 6.0.13, or 6.1-rc2).
-
Do you face a regression, e.g. something broke or works worse after switching to a newer kernel version? In that case it depends on the version range during which the problem appeared:
-
Something regressed when updating from a stable/longterm release (say 6.0.13) to a newer mainline series (like 6.1-rc7 or 6.1) or a stable/longterm version based on one (say 6.1.5)? Then consider the mainline release your working kernel is based on to be the 'good' version (e.g. 6.0) and the first version to be broken as the 'bad' one (e.g. 6.1-rc7, 6.1, or 6.1.5). Note, at this point it is merely assumed that 6.0 is fine; this hypothesis will be checked in segment 2.
-
Something regressed when switching from one mainline version (say 6.0) to a later one (like 6.1-rc1) or a stable/longterm release based on it (say 6.1.5)? Then regard the last working version (e.g. 6.0) as 'good' and the first broken (e.g. 6.1-rc1 or 6.1.5) as 'bad'.
-
Something regressed when updating within a stable/longterm series (say from 6.0.13 to 6.0.15)? Then consider those versions as 'good' and 'bad' (e.g. 6.0.13 and 6.0.15), as you need to bisect within that series.
-
Note, do not confuse 'good' version with 'working' kernel; the latter term throughout this guide will refer to the last kernel that has been working fine.
[details]
-
-
Boot into the 'working' kernel and briefly use the apparently broken feature.
[details]
-
Ensure to have enough free space for building Linux. 15 Gigabyte in your home directory should typically suffice. If you have less available, be sure to pay attention to later steps about retrieving the Linux sources and handling of debug symbols: both explain approaches reducing the amount of space, which should allow you to master these tasks with about 4 Gigabytes free space.
[details]
-
Install all software required to build a Linux kernel. Often you will need: 'bc', 'binutils' ('ld' et al.), 'bison', 'flex', 'gcc', 'git', 'openssl', 'pahole', 'perl', and the development headers for 'libelf' and 'openssl'. The reference section shows how to quickly install those on various popular Linux distributions.
[details]
-
Retrieve the mainline Linux sources; then change into the directory holding them, as all further commands in this guide are meant to be executed from there.
Note, the following describe how to retrieve the sources using a full mainline clone, which downloads about 2,75 GByte as of early 2024. The reference section describes two alternatives : one downloads less than 500 MByte, the other works better with unreliable internet connections.
Execute the following command to retrieve a fresh mainline codebase while preparing things to add branches for stable/longterm series later:
git clone -o mainline --no-checkout \ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ~/linux/ cd ~/linux/ git remote add -t master stable \ https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git[details]
-
Is one of the versions you earlier established as 'good' or 'bad' a stable or longterm release (say 6.1.5)? Then download the code for the series it belongs to ('linux-6.1.y' in this example):
git remote set-branches --add stable linux-6.1.y git fetch stable
-
Start preparing a kernel build configuration (the '.config' file).
Before doing so, ensure you are still running the 'working' kernel an earlier step told you to boot; if you are unsure, check the current kernelrelease identifier using
uname -r.Afterwards check out the source code for the version earlier established as 'good'. In the following example command this is assumed to be 6.0; note that the version number in this and all later Git commands needs to be prefixed with a 'v':
git switch --discard-changes --detach v6.0Now create a build configuration file:
make olddefconfigThe kernel build scripts then will try to locate the build configuration file for the running kernel and then adjust it for the needs of the kernel sources you checked out. While doing so, it will print a few lines you need to check.
Look out for a line starting with '# using defaults found in'. It should be followed by a path to a file in '/boot/' that contains the release identifier of your currently working kernel. If the line instead continues with something like 'arch/x86/configs/x86_64_defconfig', then the build infra failed to find the .config file for your running kernel -- in which case you have to put one there manually, as explained in the reference section.
In case you can not find such a line, look for one containing '# configuration written to .config'. If that's the case you have a stale build configuration lying around. Unless you intend to use it, delete it; afterwards run 'make olddefconfig' again and check if it now picked up the right config file as base.
[details]
-
Disable any kernel modules apparently superfluous for your setup. This is optional, but especially wise for bisections, as it speeds up the build process enormously -- at least unless the .config file picked up in the previous step was already tailored to your and your hardware needs, in which case you should skip this step.
To prepare the trimming, connect external hardware you occasionally use (USB keys, tokens, ...), quickly start a VM, and bring up VPNs. And if you rebooted since you started that guide, ensure that you tried using the feature causing trouble since you started the system. Only then trim your .config:
yes '' | make localmodconfigThere is a catch to this, as the 'apparently' in initial sentence of this step and the preparation instructions already hinted at:
The 'localmodconfig' target easily disables kernel modules for features only used occasionally -- like modules for external peripherals not yet connected since booting, virtualization software not yet utilized, VPN tunnels, and a few other things. That's because some tasks rely on kernel modules Linux only loads when you execute tasks like the aforementioned ones for the first time.
This drawback of localmodconfig is nothing you should lose sleep over, but something to keep in mind: if something is misbehaving with the kernels built during this guide, this is most likely the reason. You can reduce or nearly eliminate the risk with tricks outlined in the reference section; but when building a kernel just for quick testing purposes this is usually not worth spending much effort on, as long as it boots and allows to properly test the feature that causes trouble.
[details]
-
Ensure all the kernels you will build are clearly identifiable using a special tag and a unique version number:
./scripts/config --set-str CONFIG_LOCALVERSION '-local' ./scripts/config -e CONFIG_LOCALVERSION_AUTO[details]
-
Decide how to handle debug symbols.
In the context of this document it is often wise to enable them, as there is a decent chance you will need to decode a stack trace from a 'panic', 'Oops', 'warning', or 'BUG':
./scripts/config -d DEBUG_INFO_NONE -e KALLSYMS_ALL -e DEBUG_KERNEL \ -e DEBUG_INFO -e DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT -e KALLSYMSBut if you are extremely short on storage space, you might want to disable debug symbols instead:
./scripts/config -d DEBUG_INFO -d DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT \ -d DEBUG_INFO_DWARF4 -d DEBUG_INFO_DWARF5 -e CONFIG_DEBUG_INFO_NONE[details]
-
Check if you may want or need to adjust some other kernel configuration options:
-
Are you running Debian? Then you want to avoid known problems by performing additional adjustments explained in the reference section.
[details].
-
If you want to influence other aspects of the configuration, do so now using your preferred tool. Note, to use make targets like 'menuconfig' or 'nconfig', you will need to install the development files of ncurses; for 'xconfig' you likewise need the Qt5 or Qt6 headers.
[details].
-
-
Reprocess the .config after the latest adjustments and store it in a safe place:
make olddefconfig cp .config ~/kernel-config-working[details]
Segment 1: try to reproduce the problem with the latest codebase #
The following steps verify if the problem occurs with the code currently supported by developers. In case you face a regression, it also checks that the problem is not caused by some .config change, as reporting the issue then would be a waste of time. [details]
-
Check out the latest Linux codebase.
-
Are your 'good' and 'bad' versions from the same stable or longterm series? Then check the front page of kernel.org: if it lists a release from that series without an '[EOL]' tag, checkout the series latest version ('linux-6.1.y' in the following example):
cd ~/linux/ git switch --discard-changes --detach stable/linux-6.1.yYour series is unsupported, if is not listed or carrying a 'end of life' tag. In that case you might want to check if a successor series (say linux-6.2.y) or mainline (see next point) fix the bug.
-
In all other cases, run:
cd ~/linux/ git switch --discard-changes --detach mainline/master
[details]
-
-
Build the image and the modules of your first kernel using the config file you prepared:
cp ~/kernel-config-working .config make olddefconfig make -j $(nproc --all)If you want your kernel packaged up as deb, rpm, or tar file, see the reference section for alternatives, which obviously will require other steps to install as well.
[details]
-
Install your newly built kernel.
Before doing so, consider checking if there is still enough space for it:
df -h /boot/ /lib/modules/For now assume 150 MByte in /boot/ and 200 in /lib/modules/ will suffice; how much your kernels actually require will be determined later during this guide.
Now install the kernel's modules and its image, which will be stored in parallel to the your Linux distribution's kernels:
sudo make modules_install command -v installkernel && sudo make installThe second command ideally will take care of three steps required at this point: copying the kernel's image to /boot/, generating an initramfs, and adding an entry for both to the boot loader's configuration.
Sadly some distributions (among them Arch Linux, its derivatives, and many immutable Linux distributions) will perform none or only some of those tasks. You therefore want to check if all of them were taken care of and manually perform those that were not. The reference section provides further details on that; your distribution's documentation might help, too.
Once you figured out the steps needed at this point, consider writing them down: if you will build more kernels as described in segment 2 and 3, you will have to perform those again after executing
command -v installkernel [...].[details]
-
In case you plan to follow this guide further, check how much storage space the kernel, its modules, and other related files like the initramfs consume:
du -ch /boot/*$(make -s kernelrelease)* | tail -n 1 du -sh /lib/modules/$(make -s kernelrelease)/Write down or remember those two values for later: they enable you to prevent running out of disk space accidentally during a bisection.
[details]
-
Show and store the kernelrelease identifier of the kernel you just built:
make -s kernelrelease | tee -a ~/kernels-builtRemember the identifier momentarily, as it will help you pick the right kernel from the boot menu upon restarting.
-
Reboot into your newly built kernel. To ensure your actually started the one you just built, you might want to verify if the output of these commands matches:
tail -n 1 ~/kernels-built uname -r
-
Check if the kernel marked itself as 'tainted':
cat /proc/sys/kernel/taintedIf that command does not return '0', check the reference section, as the cause for this might interfere with your testing.
[details]
-
Verify if your bug occurs with the newly built kernel. If it does not, check out the instructions in the reference section to ensure nothing went sideways during your tests.
[details]
-
Did you just built a stable or longterm kernel? And were you able to reproduce the regression with it? Then you should test the latest mainline codebase as well, because the result determines which developers the bug must be submitted to.
To prepare that test, check out current mainline:
cd ~/linux/ git switch --discard-changes --detach mainline/masterNow use the checked out code to build and install another kernel using the commands the earlier steps already described in more detail:
cp ~/kernel-config-working .config make olddefconfig make -j $(nproc --all) # * Check if the free space suffices holding another kernel: df -h /boot/ /lib/modules/ sudo make modules_install command -v installkernel && sudo make install make -s kernelrelease | tee -a ~/kernels-built rebootConfirm you booted the kernel you intended to start and check its tainted status:
tail -n 1 ~/kernels-built uname -r cat /proc/sys/kernel/taintedNow verify if this kernel is showing the problem. If it does, then you need to report the bug to the primary developers; if it does not, report it to the stable team. See Documentation/admin-guide/reporting-issues.rst for details.
[details]
Do you follow this guide to verify if a problem is present in the code currently supported by Linux kernel developers? Then you are done at this point. If you later want to remove the kernel you just built, check out Complementary tasks: cleanup during and after following this guide.
In case you face a regression, move on and execute at least the next segment as well.
Segment 2: check if the kernels you build work fine #
In case of a regression, you now want to ensure the trimmed configuration file you created earlier works as expected; a bisection with the .config file otherwise would be a waste of time. [details]
-
Build your own variant of the 'working' kernel and check if the feature that regressed works as expected with it.
Start by checking out the sources for the version earlier established as 'good' (once again assumed to be 6.0 here):
cd ~/linux/ git switch --discard-changes --detach v6.0Now use the checked out code to configure, build, and install another kernel using the commands the previous subsection explained in more detail:
cp ~/kernel-config-working .config make olddefconfig make -j $(nproc --all) # * Check if the free space suffices holding another kernel: df -h /boot/ /lib/modules/ sudo make modules_install command -v installkernel && sudo make install make -s kernelrelease | tee -a ~/kernels-built rebootWhen the system booted, you may want to verify once again that the kernel you started is the one you just built:
tail -n 1 ~/kernels-built uname -rNow check if this kernel works as expected; if not, consult the reference section for further instructions.
[details]
Segment 3: perform the bisection and validate the result #
With all the preparations and precaution builds taken care of, you are now ready to begin the bisection. This will make you build quite a few kernels -- usually about 15 in case you encountered a regression when updating to a newer series (say from 6.0.13 to 6.1.5). But do not worry, due to the trimmed build configuration created earlier this works a lot faster than many people assume: overall on average it will often just take about 10 to 15 minutes to compile each kernel on commodity x86 machines.
-
Start the bisection and tell Git about the versions earlier established as 'good' (6.0 in the following example command) and 'bad' (6.1.5):
cd ~/linux/ git bisect start git bisect good v6.0 git bisect bad v6.1.5[details]
-
Now use the code Git checked out to build, install, and boot a kernel using the commands introduced earlier:
cp ~/kernel-config-working .config make olddefconfig make -j $(nproc --all) # * Check if the free space suffices holding another kernel: df -h /boot/ /lib/modules/ sudo make modules_install command -v installkernel && sudo make install make -s kernelrelease | tee -a ~/kernels-built rebootIf compilation fails for some reason, run
git bisect skipand restart executing the stack of commands from the beginning.In case you skipped the 'test latest codebase' step in the guide, check its description as for why the 'df [...]' and 'make -s kernelrelease [...]' commands are here.
Important note: the latter command from this point on will print release identifiers that might look odd or wrong to you -- which they are not, as it's totally normal to see release identifiers like '6.0-rc1-local-gcafec0cacaca0' if you bisect between versions 6.1 and 6.2 for example.
[details]
-
Now check if the feature that regressed works in the kernel you just built.
You again might want to start by making sure the kernel you booted is the one you just built:
cd ~/linux/ tail -n 1 ~/kernels-built uname -rNow verify if the feature that regressed works at this kernel bisection point. If it does, run this:
git bisect goodIf it does not, run this:
git bisect badBe sure about what you tell Git, as getting this wrong just once will send the rest of the bisection totally off course.
While the bisection is ongoing, Git will use the information you provided to find and check out another bisection point for you to test. While doing so, it will print something like 'Bisecting: 675 revisions left to test after this (roughly 10 steps)' to indicate how many further changes it expects to be tested. Now build and install another kernel using the instructions from the previous step; afterwards follow the instructions in this step again.
Repeat this again and again until you finish the bisection -- that's the case when Git after tagging a change as 'good' or 'bad' prints something like 'cafecaca0c0dacafecaca0c0dacafecaca0c0da is the first bad commit'; right afterwards it will show some details about the culprit including the patch description of the change. The latter might fill your terminal screen, so you might need to scroll up to see the message mentioning the culprit; alternatively, run
git bisect log > ~/bisection-log.[details]
-
Store Git's bisection log and the current .config file in a safe place before telling Git to reset the sources to the state before the bisection:
cd ~/linux/ git bisect log > ~/bisection-log cp .config ~/bisection-config-culprit git bisect reset[details]
-
Try reverting the culprit on top of latest mainline to see if this fixes your regression.
This is optional, as it might be impossible or hard to realize. The former is the case, if the bisection determined a merge commit as the culprit; the latter happens if other changes depend on the culprit. But if the revert succeeds, it is worth building another kernel, as it validates the result of a bisection, which can easily deroute; it furthermore will let kernel developers know, if they can resolve the regression with a quick revert.
Begin by checking out the latest codebase depending on the range you bisected:
-
Did you face a regression within a stable/longterm series (say between 6.0.13 and 6.0.15) that does not happen in mainline? Then check out the latest codebase for the affected series like this:
git fetch stable git switch --discard-changes --detach linux-6.0.y -
In all other cases check out latest mainline:
git fetch mainline git switch --discard-changes --detach mainline/masterIf you bisected a regression within a stable/longterm series that also happens in mainline, there is one more thing to do: look up the mainline commit-id. To do so, use a command like
git show abcdcafecabcdto view the patch description of the culprit. There will be a line near the top which looks like 'commit cafec0cacaca0 upstream.' or 'Upstream commit cafec0cacaca0'; use that commit-id in the next command and not the one the bisection blamed.
Now try reverting the culprit by specifying its commit id:
git revert --no-edit cafec0cacaca0If that fails, give up trying and move on to the next step; if it works, adjust the tag to facilitate the identification and prevent accidentally overwriting another kernel:
cp ~/kernel-config-working .config ./scripts/config --set-str CONFIG_LOCALVERSION '-local-cafec0cacaca0-reverted'Build a kernel using the familiar command sequence, just without copying the the base .config over:
make olddefconfig && make -j $(nproc --all) # * Check if the free space suffices holding another kernel: df -h /boot/ /lib/modules/ sudo make modules_install command -v installkernel && sudo make install make -s kernelrelease | tee -a ~/kernels-built rebootNow check one last time if the feature that made you perform a bisection works with that kernel: if everything went well, it should not show the regression.
[details]
-
Complementary tasks: cleanup during and after the bisection #
During and after following this guide you might want or need to remove some of the kernels you installed: the boot menu otherwise will become confusing or space might run out.
-
To remove one of the kernels you installed, look up its 'kernelrelease' identifier. This guide stores them in '~/kernels-built', but the following command will print them as well:
ls -ltr /lib/modules/*-local*You in most situations want to remove the oldest kernels built during the actual bisection (e.g. segment 3 of this guide). The two ones you created beforehand (e.g. to test the latest codebase and the version considered 'good') might become handy to verify something later -- thus better keep them around, unless you are really short on storage space.
To remove the modules of a kernel with the kernelrelease identifier '6.0-rc1-local-gcafec0cacaca0', start by removing the directory holding its modules:
sudo rm -rf /lib/modules/6.0-rc1-local-gcafec0cacaca0Afterwards try the following command:
sudo kernel-install -v remove 6.0-rc1-local-gcafec0cacaca0On quite a few distributions this will delete all other kernel files installed while also removing the kernel's entry from the boot menu. But on some distributions kernel-install does not exist or leaves boot-loader entries or kernel image and related files behind; in that case remove them as described in the reference section.
[details]
-
Once you have finished the bisection, do not immediately remove anything you set up, as you might need a few things again. What is safe to remove depends on the outcome of the bisection:
-
Could you initially reproduce the regression with the latest codebase and after the bisection were able to fix the problem by reverting the culprit on top of the latest codebase? Then you want to keep those two kernels around for a while, but safely remove all others with a '-local' in the release identifier.
-
Did the bisection end on a merge-commit or seems questionable for other reasons? Then you want to keep as many kernels as possible around for a few days: it's pretty likely that you will be asked to recheck something.
-
In other cases it likely is a good idea to keep the following kernels around for some time: the one built from the latest codebase, the one created from the version considered 'good', and the last three or four you compiled during the actual bisection process.
[details]
-
Optional: test reverts, patches, or later versions #
While or after reporting a bug, you might want or potentially will be asked to test reverts, debug patches, proposed fixes, or other versions. In that case follow these instructions.
-
Update your Git clone and check out the latest code.
-
In case you want to test mainline, fetch its latest changes before checking its code out:
git fetch mainline git switch --discard-changes --detach mainline/master -
In case you want to test a stable or longterm kernel, first add the branch holding the series you are interested in (6.2 in the example), unless you already did so earlier:
git remote set-branches --add stable linux-6.2.yThen fetch the latest changes and check out the latest version from the series:
git fetch stable git switch --discard-changes --detach stable/linux-6.2.y
-
-
Copy your kernel build configuration over:
cp ~/kernel-config-working .config -
Your next step depends on what you want to do:
-
In case you just want to test the latest codebase, head to the next step, you are already all set.
-
In case you want to test if a revert fixes an issue, revert one or multiple changes by specifying their commit ids:
git revert --no-edit cafec0cacaca0Now give that kernel a special tag to facilitates its identification and prevent accidentally overwriting another kernel:
./scripts/config --set-str CONFIG_LOCALVERSION '-local-cafec0cacaca0-reverted' -
In case you want to test a patch, store the patch in a file like '/tmp/foobars-proposed-fix-v1.patch' and apply it like this:
git apply /tmp/foobars-proposed-fix-v1.patchIn case of multiple patches, repeat this step with the others.
Now give that kernel a special tag to facilitates its identification and prevent accidentally overwriting another kernel:
./scripts/config --set-str CONFIG_LOCALVERSION '-local-foobars-fix-v1'
-
-
Build a kernel using the familiar commands, just without copying the kernel build configuration over, as that has been taken care of already:
make olddefconfig && make -j $(nproc --all) # * Check if the free space suffices holding another kernel: df -h /boot/ /lib/modules/ sudo make modules_install command -v installkernel && sudo make install make -s kernelrelease | tee -a ~/kernels-built reboot -
Now verify you booted the newly built kernel and check it.
[details]
Conclusion #
You have reached the end of the step-by-step guide.
Did you run into trouble following any of the above steps not cleared up by the reference section below? Did you spot errors? Or do you have ideas how to improve the guide?
If any of that applies, please take a moment and let the maintainer of this document know by email (Thorsten Leemhuis <linux@leemhuis.info>), ideally while CCing the Linux docs mailing list (linux-doc@vger.kernel.org). Such feedback is vital to improve this text further, which is in everybody's interest, as it will enable more people to master the task described here -- and hopefully also improve similar guides inspired by this one.
Reference section for the step-by-step guide #
This section holds additional information for almost all the items in the above step-by-step guide.
Preparations for building your own kernels #
The steps in this section lay the groundwork for all further tests. [...]
The steps in all later sections of this guide depend on those described here.
Prepare for emergencies #
Create a fresh backup and put system repair and restore tools at hand. [...]
Remember, you are dealing with computers, which sometimes do unexpected things -- especially if you fiddle with crucial parts like the kernel of an operating system. That's what you are about to do in this process. Hence, better prepare for something going sideways, even if that should not happen.
Remove anything related to externally maintained kernel modules #
Remove all software that depends on externally developed kernel drivers or builds them automatically. [...]
Externally developed kernel modules can easily cause trouble during a bisection.
But there is a more important reason why this guide contains this step: most kernel developers will not care about reports about regressions occurring with kernels that utilize such modules. That's because such kernels are not considered 'vanilla' anymore, as Documentation/admin-guide/reporting-issues.rst explains in more detail.
Deal with techniques like Secure Boot #
On platforms with 'Secure Boot' or similar techniques, prepare everything to ensure the system will permit your self-compiled kernel to boot later. [...]
Many modern systems allow only certain operating systems to start; that's why they reject booting self-compiled kernels by default.
You ideally deal with this by making your platform trust your self-built kernels with the help of a certificate. How to do that is not described here, as it requires various steps that would take the text too far away from its purpose; 'Documentation/admin-guide/module-signing.rst' and various web sides already explain everything needed in more detail.
Temporarily disabling solutions like Secure Boot is another way to make your own Linux boot. On commodity x86 systems it is possible to do this in the BIOS Setup utility; the required steps vary a lot between machines and therefore cannot be described here.
On mainstream x86 Linux distributions there is a third and universal option: disable all Secure Boot restrictions for your Linux environment. You can initiate this process by running mokutil --disable-validation; this will tell you to create a one-time password, which is safe to write down. Now restart; right after your BIOS performed all self-tests the bootloader Shim will show a blue box with a message 'Press any key to perform MOK management'. Hit some key before the countdown exposes, which will open a menu. Choose 'Change Secure Boot state'. Shim's 'MokManager' will now ask you to enter three randomly chosen characters from the one-time password specified earlier. Once you provided them, confirm you really want to disable the validation. Afterwards, permit MokManager to reboot the machine.
Boot the last kernel that was working #
Boot into the last working kernel and briefly recheck if the feature that regressed really works. [...]
This will make later steps that cover creating and trimming the configuration do the right thing.
Space requirements #
Ensure to have enough free space for building Linux. [...]
The numbers mentioned are rough estimates with a big extra charge to be on the safe side, so often you will need less.
If you have space constraints, be sure to hay attention to the step about debug symbols' and its accompanying reference section', as disabling then will reduce the consumed disk space by quite a few gigabytes.
Bisection range #
Determine the kernel versions considered 'good' and 'bad' throughout this guide. [...]
Establishing the range of commits to be checked is mostly straightforward, except when a regression occurred when switching from a release of one stable series to a release of a later series (e.g. from 6.0.13 to 6.1.5). In that case Git will need some hand holding, as there is no straight line of descent.
That's because with the release of 6.0 mainline carried on to 6.1 while the stable series 6.0.y branched to the side. It's therefore theoretically possible that the issue you face with 6.1.5 only worked in 6.0.13, as it was fixed by a commit that went into one of the 6.0.y releases, but never hit mainline or the 6.1.y series. Thankfully that normally should not happen due to the way the stable/longterm maintainers maintain the code. It's thus pretty safe to assume 6.0 as a 'good' kernel. That assumption will be tested anyway, as that kernel will be built and tested in the segment '2' of this guide; Git would force you to do this as well, if you tried bisecting between 6.0.13 and 6.1.15.
Install build requirements #
Install all software required to build a Linux kernel. [...]
The kernel is pretty stand-alone, but besides tools like the compiler you will sometimes need a few libraries to build one. How to install everything needed depends on your Linux distribution and the configuration of the kernel you are about to build.
Here are a few examples what you typically need on some mainstream distributions:
-
Arch Linux and derivatives:
sudo pacman --needed -S bc binutils bison flex gcc git kmod libelf openssl \ pahole perl zlib ncurses qt6-base -
Debian, Ubuntu, and derivatives:
sudo apt install bc binutils bison dwarves flex gcc git kmod libelf-dev \ libssl-dev make openssl pahole perl-base pkg-config zlib1g-dev \ libncurses-dev qt6-base-dev g++ -
Fedora and derivatives:
sudo dnf install binutils \ /usr/bin/{bc,bison,flex,gcc,git,openssl,make,perl,pahole,rpmbuild} \ /usr/include/{libelf.h,openssl/pkcs7.h,zlib.h,ncurses.h,qt6/QtGui/QAction} -
openSUSE and derivatives:
sudo zypper install bc binutils bison dwarves flex gcc git \ kernel-install-tools libelf-devel make modutils openssl openssl-devel \ perl-base zlib-devel rpm-build ncurses-devel qt6-base-devel
These commands install a few packages that are often, but not always needed. You for example might want to skip installing the development headers for ncurses, which you will only need in case you later might want to adjust the kernel build configuration using make the targets 'menuconfig' or 'nconfig'; likewise omit the headers of Qt6 if you do not plan to adjust the .config using 'xconfig'.
You furthermore might need additional libraries and their development headers for tasks not covered in this guide -- for example when building utilities from the kernel's tools/ directory.
Download the sources using Git #
Retrieve the Linux mainline sources. [...]
The step-by-step guide outlines how to download the Linux sources using a full Git clone of Linus' mainline repository. There is nothing more to say about that -- but there are two alternatives ways to retrieve the sources that might work better for you:
-
If you have an unreliable internet connection, consider using a 'Git bundle'.
-
If downloading the complete repository would take too long or requires too much storage space, consider using a 'shallow clone'.
Downloading Linux mainline sources using a bundle #
Use the following commands to retrieve the Linux mainline sources using a bundle:
wget -c \
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/clone.bundle
git clone --no-checkout clone.bundle ~/linux/
cd ~/linux/
git remote remove origin
git remote add mainline \
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch mainline
git remote add -t master stable \
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
In case the 'wget' command fails, just re-execute it, it will pick up where it left off.
[back to step-by-step guide] [back to section intro]
Downloading Linux mainline sources using a shallow clone #
First, execute the following command to retrieve the latest mainline codebase:
git clone -o mainline --no-checkout --depth 1 -b master \
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ~/linux/
cd ~/linux/
git remote add -t master stable \
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Now deepen your clone's history to the second predecessor of the mainline release of your 'good' version. In case the latter are 6.0 or 6.0.13, 5.19 would be the first predecessor and 5.18 the second -- hence deepen the history up to that version:
git fetch --shallow-exclude=v5.18 mainline
Afterwards add the stable Git repository as remote and all required stable branches as explained in the step-by-step guide.
Note, shallow clones have a few peculiar characteristics:
-
For bisections the history needs to be deepened a few mainline versions farther than it seems necessary, as explained above already. That's because Git otherwise will be unable to revert or describe most of the commits within a range (say 6.1..6.2), as they are internally based on earlier kernels releases (like 6.0-rc2 or 5.19-rc3).
-
This document in most places uses
git fetchwith--shallow-exclude=to specify the earliest version you care about (or to be precise: its git tag). You alternatively can use the parameter--shallow-since=to specify an absolute (say'2023-07-15') or relative ('12 months') date to define the depth of the history you want to download. When using them while bisecting mainline, ensure to deepen the history to at least 7 months before the release of the mainline release your 'good' kernel is based on. -
Be warned, when deepening your clone you might encounter an error like 'fatal: error in object: unshallow cafecaca0c0dacafecaca0c0dacafecaca0c0da'. In that case run
git repack -dand try again.
[back to step-by-step guide] [back to section intro]
Start defining the build configuration for your kernel #
Start preparing a kernel build configuration (the '.config' file). [...]
Note, this is the first of multiple steps in this guide that create or modify build artifacts. The commands used in this guide store them right in the source tree to keep things simple. In case you prefer storing the build artifacts separately, create a directory like '~/linux-builddir/' and add the parameter ``O=~/linux-builddir/`` to all make calls used throughout this guide. You will have to point other commands there as well -- among them the ``./scripts/config [...]`` commands, which will require ``--file ~/linux-builddir/.config`` to locate the right build configuration.
Two things can easily go wrong when creating a .config file as advised:
-
The oldconfig target will use a .config file from your build directory, if one is already present there (e.g. '~/linux/.config'). That's totally fine if that's what you intend (see next step), but in all other cases you want to delete it. This for example is important in case you followed this guide further, but due to problems come back here to redo the configuration from scratch.
-
Sometimes olddefconfig is unable to locate the .config file for your running kernel and will use defaults, as briefly outlined in the guide. In that case check if your distribution ships the configuration somewhere and manually put it in the right place (e.g. '~/linux/.config') if it does. On distributions where /proc/config.gz exists this can be achieved using this command:
zcat /proc/config.gz > .configOnce you put it there, run
make olddefconfigagain to adjust it to the needs of the kernel about to be built.
Note, the olddefconfig target will set any undefined build options to their default value. If you prefer to set such configuration options manually, use make oldconfig instead. Then for each undefined configuration option you will be asked how to proceed; in case you are unsure what to answer, simply hit 'enter' to apply the default value. Note though that for bisections you normally want to go with the defaults, as you otherwise might enable a new feature that causes a problem looking like regressions (for example due to security restrictions).
Occasionally odd things happen when trying to use a config file prepared for one kernel (say 6.1) on an older mainline release -- especially if it is much older (say 5.15). That's one of the reasons why the previous step in the guide told you to boot the kernel where everything works. If you manually add a .config file you thus want to ensure it's from the working kernel and not from a one that shows the regression.
In case you want to build kernels for another machine, locate its kernel build configuration; usually ls /boot/config-$(uname -r) will print its name. Copy that file to the build machine and store it as ~/linux/.config; afterwards run make olddefconfig to adjust it.
Trim the build configuration for your kernel #
Disable any kernel modules apparently superfluous for your setup. [...]
As explained briefly in the step-by-step guide already: with localmodconfig it can easily happen that your self-built kernels will lack modules for tasks you did not perform at least once before utilizing this make target. That happens when a task requires kernel modules which are only autoloaded when you execute it for the first time. So when you never performed that task since starting your kernel the modules will not have been loaded -- and from localmodconfig's point of view look superfluous, which thus disables them to reduce the amount of code to be compiled.
You can try to avoid this by performing typical tasks that often will autoload additional kernel modules: start a VM, establish VPN connections, loop-mount a CD/DVD ISO, mount network shares (CIFS, NFS, ...), and connect all external devices (2FA keys, headsets, webcams, ...) as well as storage devices with file systems you otherwise do not utilize (btrfs, ext4, FAT, NTFS, XFS, ...). But it is hard to think of everything that might be needed -- even kernel developers often forget one thing or another at this point.
Do not let that risk bother you, especially when compiling a kernel only for testing purposes: everything typically crucial will be there. And if you forget something important you can turn on a missing feature manually later and quickly run the commands again to compile and install a kernel that has everything you need.
But if you plan to build and use self-built kernels regularly, you might want to reduce the risk by recording which modules your system loads over the course of a few weeks. You can automate this with modprobed-db. Afterwards use LSMOD=<path> to point localmodconfig to the list of modules modprobed-db noticed being used:
yes '' | make LSMOD='${HOME}'/.config/modprobed.db localmodconfig
That parameter also allows you to build trimmed kernels for another machine in case you copied a suitable .config over to use as base (see previous step). Just run lsmod > lsmod_foo-machine on that system and copy the generated file to your build's host home directory. Then run these commands instead of the one the step-by-step guide mentions:
yes '' | make LSMOD=~/lsmod_foo-machine localmodconfig
Tag the kernels about to be build #
Ensure all the kernels you will build are clearly identifiable using a special tag and a unique version identifier. [...]
This allows you to differentiate your distribution's kernels from those created during this process, as the file or directories for the latter will contain '-local' in the name; it also helps picking the right entry in the boot menu and not lose track of you kernels, as their version numbers will look slightly confusing during the bisection.
Decide to enable or disable debug symbols #
Decide how to handle debug symbols. [...]
Having debug symbols available can be important when your kernel throws a 'panic', 'Oops', 'warning', or 'BUG' later when running, as then you will be able to find the exact place where the problem occurred in the code. But collecting and embedding the needed debug information takes time and consumes quite a bit of space: in late 2022 the build artifacts for a typical x86 kernel trimmed with localmodconfig consumed around 5 Gigabyte of space with debug symbols, but less than 1 when they were disabled. The resulting kernel image and modules are bigger as well, which increases storage requirements for /boot/ and load times.
In case you want a small kernel and are unlikely to decode a stack trace later, you thus might want to disable debug symbols to avoid those downsides. If it later turns out that you need them, just enable them as shown and rebuild the kernel.
You on the other hand definitely want to enable them for this process, if there is a decent chance that you need to decode a stack trace later. The section 'Decode failure messages' in Documentation/admin-guide/reporting-issues.rst explains this process in more detail.
Adjust build configuration #
Check if you may want or need to adjust some other kernel configuration options:
Depending on your needs you at this point might want or have to adjust some kernel configuration options.
Distro specific adjustments #
Are you running [...]
The following sections help you to avoid build problems that are known to occur when following this guide on a few commodity distributions.
Debian:
-
Remove a stale reference to a certificate file that would cause your build to fail:
./scripts/config --set-str SYSTEM_TRUSTED_KEYS ''Alternatively, download the needed certificate and make that configuration option point to it, as the Debian handbook explains in more detail -- or generate your own, as explained in Documentation/admin-guide/module-signing.rst.
Individual adjustments #
If you want to influence the other aspects of the configuration, do so now. [...]
At this point you can use a command like make menuconfig or make nconfig to enable or disable certain features using a text-based user interface; to use a graphical configuration utility, run make xconfig instead. Both of them require development libraries from toolkits they are rely on (ncurses respectively Qt5 or Qt6); an error message will tell you if something required is missing.
Put the .config file aside #
Reprocess the .config after the latest changes and store it in a safe place. [...]
Put the .config you prepared aside, as you want to copy it back to the build directory every time during this guide before you start building another kernel. That's because going back and forth between different versions can alter .config files in odd ways; those occasionally cause side effects that could confuse testing or in some cases render the result of your bisection meaningless.
Try to reproduce the problem with the latest codebase #
Verify the regression is not caused by some .config change and check if it still occurs with the latest codebase. [...]
For some readers it might seem unnecessary to check the latest codebase at this point, especially if you did that already with a kernel prepared by your distributor or face a regression within a stable/longterm series. But it's highly recommended for these reasons:
-
You will run into any problems caused by your setup before you actually begin a bisection. That will make it a lot easier to differentiate between 'this most likely is some problem in my setup' and 'this change needs to be skipped during the bisection, as the kernel sources at that stage contain an unrelated problem that causes building or booting to fail'.
-
These steps will rule out if your problem is caused by some change in the build configuration between the 'working' and the 'broken' kernel. This for example can happen when your distributor enabled an additional security feature in the newer kernel which was disabled or not yet supported by the older kernel. That security feature might get into the way of something you do -- in which case your problem from the perspective of the Linux kernel upstream developers is not a regression, as Documentation/admin-guide/reporting-regressions.rst explains in more detail. You thus would waste your time if you'd try to bisect this.
-
If the cause for your regression was already fixed in the latest mainline codebase, you'd perform the bisection for nothing. This holds true for a regression you encountered with a stable/longterm release as well, as they are often caused by problems in mainline changes that were backported -- in which case the problem will have to be fixed in mainline first. Maybe it already was fixed there and the fix is already in the process of being backported.
-
For regressions within a stable/longterm series it's furthermore crucial to know if the issue is specific to that series or also happens in the mainline kernel, as the report needs to be sent to different people:
-
Regressions specific to a stable/longterm series are the stable team's responsibility; mainline Linux developers might or might not care.
-
Regressions also happening in mainline are something the regular Linux developers and maintainers have to handle; the stable team does not care and does not need to be involved in the report, they just should be told to backport the fix once it's ready.
Your report might be ignored if you send it to the wrong party -- and even when you get a reply there is a decent chance that developers tell you to evaluate which of the two cases it is before they take a closer look.
-
Check out the latest Linux codebase #
Check out the latest Linux codebase. [...]
In case you later want to recheck if an ever newer codebase might fix the problem, remember to run that git fetch --shallow-exclude [...] command again mentioned earlier to update your local Git repository.
Build your kernel #
Build the image and the modules of your first kernel using the config file you prepared. [...]
A lot can go wrong at this stage, but the instructions below will help you help yourself. Another subsection explains how to directly package your kernel up as deb, rpm or tar file.
Dealing with build errors #
When a build error occurs, it might be caused by some aspect of your machine's setup that often can be fixed quickly; other times though the problem lies in the code and can only be fixed by a developer. A close examination of the failure messages coupled with some research on the internet will often tell you which of the two it is. To perform such investigation, restart the build process like this:
make V=1
The V=1 activates verbose output, which might be needed to see the actual error. To make it easier to spot, this command also omits the -j $(nproc --all) used earlier to utilize every CPU core in the system for the job -- but this parallelism also results in some clutter when failures occur.
After a few seconds the build process should run into the error again. Now try to find the most crucial line describing the problem. Then search the internet for the most important and non-generic section of that line (say 4 to 8 words); avoid or remove anything that looks remotely system-specific, like your username or local path names like /home/username/linux/. First try your regular internet search engine with that string, afterwards search Linux kernel mailing lists via lore.kernel.org/all/.
This most of the time will find something that will explain what is wrong; quite often one of the hits will provide a solution for your problem, too. If you do not find anything that matches your problem, try again from a different angle by modifying your search terms or using another line from the error messages.
In the end, most issues you run into have likely been encountered and reported by others already. That includes issues where the cause is not your system, but lies in the code. If you run into one of those, you might thus find a solution (e.g. a patch) or workaround for your issue, too.
Package your kernel up #
The step-by-step guide uses the default make targets (e.g. 'bzImage' and 'modules' on x86) to build the image and the modules of your kernel, which later steps of the guide then install. You instead can also directly build everything and directly package it up by using one of the following targets:
-
make -j $(nproc --all) bindeb-pkgto generate a deb package -
make -j $(nproc --all) binrpm-pkgto generate a rpm package -
make -j $(nproc --all) tarbz2-pkgto generate a bz2 compressed tarball
This is just a selection of available make targets for this purpose, see make help for others. You can also use these targets after running make -j $(nproc --all), as they will pick up everything already built.
If you employ the targets to generate deb or rpm packages, ignore the step-by-step guide's instructions on installing and removing your kernel; instead install and remove the packages using the package utility for the format (e.g. dpkg and rpm) or a package management utility build on top of them (apt, aptitude, dnf/yum, zypper, ...). Be aware that the packages generated using these two make targets are designed to work on various distributions utilizing those formats, they thus will sometimes behave differently than your distribution's kernel packages.
Put the kernel in place #
Install the kernel you just built. [...]
What you need to do after executing the command in the step-by-step guide depends on the existence and the implementation of /sbin/installkernel executable on your distribution.
If installkernel is found, the kernel's build system will delegate the actual installation of your kernel image to this executable, which then performs some or all of these tasks:
-
On almost all Linux distributions installkernel will store your kernel's image in /boot/, usually as '/boot/vmlinuz-<kernelrelease_id>'; often it will put a 'System.map-<kernelrelease_id>' alongside it.
-
On most distributions installkernel will then generate an 'initramfs' (sometimes also called 'initrd'), which usually are stored as '/boot/initramfs-<kernelrelease_id>.img' or '/boot/initrd-<kernelrelease_id>'. Commodity distributions rely on this file for booting, hence ensure to execute the make target 'modules_install' first, as your distribution's initramfs generator otherwise will be unable to find the modules that go into the image.
-
On some distributions installkernel will then add an entry for your kernel to your bootloader's configuration.
You have to take care of some or all of the tasks yourself, if your distribution lacks an installkernel script or does only handle part of them. Consult the distribution's documentation for details. If in doubt, install the kernel manually:
sudo install -m 0600 $(make -s image_name) /boot/vmlinuz-$(make -s kernelrelease)
sudo install -m 0600 System.map /boot/System.map-$(make -s kernelrelease)
Now generate your initramfs using the tools your distribution provides for this process. Afterwards add your kernel to your bootloader configuration and reboot.
Storage requirements per kernel #
Check how much storage space the kernel, its modules, and other related files like the initramfs consume. [...]
The kernels built during a bisection consume quite a bit of space in /boot/ and /lib/modules/, especially if you enabled debug symbols. That makes it easy to fill up volumes during a bisection -- and due to that even kernels which used to work earlier might fail to boot. To prevent that you will need to know how much space each installed kernel typically requires.
Note, most of the time the pattern '/boot/$(make -s kernelrelease)' used in the guide will match all files needed to boot your kernel -- but neither the path nor the naming scheme are mandatory. On some distributions you thus will need to look in different places.
Check if your newly built kernel considers itself 'tainted' #
Check if the kernel marked itself as 'tainted'. [...]
Linux marks itself as tainted when something happens that potentially leads to follow-up errors that look totally unrelated. That is why developers might ignore or react scantly to reports from tainted kernels -- unless of course the kernel set the flag right when the reported bug occurred.
That's why you want check why a kernel is tainted as explained in Documentation/admin-guide/tainted-kernels.rst; doing so is also in your own interest, as your testing might be flawed otherwise.
Check the kernel built from a recent mainline codebase #
Verify if your bug occurs with the newly built kernel. [...]
There are a couple of reasons why your bug or regression might not show up with the kernel you built from the latest codebase. These are the most frequent:
-
The bug was fixed meanwhile.
-
What you suspected to be a regression was caused by a change in the build configuration the provider of your kernel carried out.
-
Your problem might be a race condition that does not show up with your kernel; the trimmed build configuration, a different setting for debug symbols, the compiler used, and various other things can cause this.
-
In case you encountered the regression with a stable/longterm kernel it might be a problem that is specific to that series; the next step in this guide will check this.
Check the kernel built from the latest stable/longterm codebase #
Are you facing a regression within a stable/longterm release, but failed to reproduce it with the kernel you just built using the latest mainline sources? Then check if the latest codebase for the particular series might already fix the problem. [...]
If this kernel does not show the regression either, there most likely is no need for a bisection.
Ensure the 'good' version is really working well #
Check if the kernels you build work fine. [...]
This section will reestablish a known working base. Skipping it might be appealing, but is usually a bad idea, as it does something important:
It will ensure the .config file you prepared earlier actually works as expected. That is in your own interest, as trimming the configuration is not foolproof -- and you might be building and testing ten or more kernels for nothing before starting to suspect something might be wrong with the build configuration.
That alone is reason enough to spend the time on this, but not the only reason.
Many readers of this guide normally run kernels that are patched, use add-on modules, or both. Those kernels thus are not considered 'vanilla' -- therefore it's possible that the thing that regressed might never have worked in vanilla builds of the 'good' version in the first place.
There is a third reason for those that noticed a regression between stable/longterm kernels of different series (e.g. 6.0.13..6.1.5): it will ensure the kernel version you assumed to be 'good' earlier in the process (e.g. 6.0) actually is working.
Build your own version of the 'good' kernel #
Build your own variant of the working kernel and check if the feature that regressed works as expected with it. [...]
In case the feature that broke with newer kernels does not work with your first self-built kernel, find and resolve the cause before moving on. There are a multitude of reasons why this might happen. Some ideas where to look:
-
Check the taint status and the output of
dmesg, maybe something unrelated went wrong. -
Maybe localmodconfig did something odd and disabled the module required to test the feature? Then you might want to recreate a .config file based on the one from the last working kernel and skip trimming it down; manually disabling some features in the .config might work as well to reduce the build time.
-
Maybe it's not a kernel regression and something that is caused by some fluke, a broken initramfs (also known as initrd), new firmware files, or an updated userland software?
-
Maybe it was a feature added to your distributor's kernel which vanilla Linux at that point never supported?
Note, if you found and fixed problems with the .config file, you want to use it to build another kernel from the latest codebase, as your earlier tests with mainline and the latest version from an affected stable/longterm series were most likely flawed.
Perform a bisection and validate the result #
With all the preparations and precaution builds taken care of, you are now ready to begin the bisection. [...]
The steps in this segment perform and validate the bisection.
Start the bisection #
Start the bisection and tell Git about the versions earlier established as 'good' and 'bad'. [...]
This will start the bisection process; the last of the commands will make Git check out a commit round about half-way between the 'good' and the 'bad' changes for you to test.
Build a kernel from the bisection point #
Build, install, and boot a kernel from the code Git checked out using the same commands you used earlier. [...]
There are two things worth of note here:
-
Occasionally building the kernel will fail or it might not boot due some problem in the code at the bisection point. In that case run this command:
git bisect skipGit will then check out another commit nearby which with a bit of luck should work better. Afterwards restart executing this step.
-
Those slightly odd looking version identifiers can happen during bisections, because the Linux kernel subsystems prepare their changes for a new mainline release (say 6.2) before its predecessor (e.g. 6.1) is finished. They thus base them on a somewhat earlier point like 6.1-rc1 or even 6.0 -- and then get merged for 6.2 without rebasing nor squashing them once 6.1 is out. This leads to those slightly odd looking version identifiers coming up during bisections.
Bisection checkpoint #
Check if the feature that regressed works in the kernel you just built. [...]
Ensure what you tell Git is accurate: getting it wrong just one time will bring the rest of the bisection totally off course, hence all testing after that point will be for nothing.
Put the bisection log away #
Store Git's bisection log and the current .config file in a safe place. [...]
As indicated above: declaring just one kernel wrongly as 'good' or 'bad' will render the end result of a bisection useless. In that case you'd normally have to restart the bisection from scratch. The log can prevent that, as it might allow someone to point out where a bisection likely went sideways -- and then instead of testing ten or more kernels you might only have to build a few to resolve things.
The .config file is put aside, as there is a decent chance that developers might ask for it after you report the regression.
Try reverting the culprit #
Try reverting the culprit on top of the latest codebase to see if this fixes your regression. [...]
This is an optional step, but whenever possible one you should try: there is a decent chance that developers will ask you to perform this step when you bring the bisection result up. So give it a try, you are in the flow already, building one more kernel shouldn't be a big deal at this point.
The step-by-step guide covers everything relevant already except one slightly rare thing: did you bisected a regression that also happened with mainline using a stable/longterm series, but Git failed to revert the commit in mainline? Then try to revert the culprit in the affected stable/longterm series -- and if that succeeds, test that kernel version instead.
Cleanup steps during and after following this guide #
During and after following this guide you might want or need to remove some of the kernels you installed. [...]
The steps in this section describe clean-up procedures.
Cleaning up during the bisection #
To remove one of the kernels you installed, look up its 'kernelrelease' identifier. [...]
The kernels you install during this process are easy to remove later, as its parts are only stored in two places and clearly identifiable. You thus do not need to worry to mess up your machine when you install a kernel manually (and thus bypass your distribution's packaging system): all parts of your kernels are relatively easy to remove later.
One of the two places is a directory in /lib/modules/, which holds the modules for each installed kernel. This directory is named after the kernel's release identifier; hence, to remove all modules for one of the kernels you built, simply remove its modules directory in /lib/modules/.
The other place is /boot/, where typically two up to five files will be placed during installation of a kernel. All of them usually contain the release name in their file name, but how many files and their exact names depend somewhat on your distribution's installkernel executable and its initramfs generator. On some distributions the kernel-install remove... command mentioned in the step-by-step guide will delete all of these files for you while also removing the menu entry for the kernel from your bootloader configuration. On others you have to take care of these two tasks yourself. The following command should interactively remove the three main files of a kernel with the release name '6.0-rc1-local-gcafec0cacaca0':
rm -i /boot/{System.map,vmlinuz,initr}-6.0-rc1-local-gcafec0cacaca0
Afterwards check for other files in /boot/ that have '6.0-rc1-local-gcafec0cacaca0' in their name and consider deleting them as well. Now remove the boot entry for the kernel from your bootloader's configuration; the steps to do that vary quite a bit between Linux distributions.
Note, be careful with wildcards like '*' when deleting files or directories for kernels manually: you might accidentally remove files of a 6.0.13 kernel when all you want is to remove 6.0 or 6.0.1.
Cleaning up after the bisection #
Once you have finished the bisection, do not immediately remove anything you set up, as you might need a few things again. [...]
When you are really short of storage space removing the kernels as described in the step-by-step guide might not free as much space as you would like. In that case consider running rm -rf ~/linux/* as well now. This will remove the build artifacts and the Linux sources, but will leave the Git repository (~/linux/.git/) behind -- a simple git reset --hard thus will bring the sources back.
Removing the repository as well would likely be unwise at this point: there is a decent chance developers will ask you to build another kernel to perform additional tests -- like testing a debug patch or a proposed fix. Details on how to perform those can be found in the section Optional tasks: test reverts, patches, or later versions.
Additional tests are also the reason why you want to keep the ~/kernel-config-working file around for a few weeks.
Test reverts, patches, or later versions #
While or after reporting a bug, you might want or potentially will be asked to test reverts, patches, proposed fixes, or other versions. [...]
All the commands used in this section should be pretty straight forward, so there is not much to add except one thing: when setting a kernel tag as instructed, ensure it is not much longer than the one used in the example, as problems will arise if the kernelrelease identifier exceeds 63 characters.
Additional information #
Build kernels on a different machine #
To compile kernels on another system, slightly alter the step-by-step guide's instructions:
-
Start following the guide on the machine where you want to install and test the kernels later.
-
After executing 'Boot into the working kernel and briefly use the apparently broken feature', save the list of loaded modules to a file using
lsmod > ~/test-machine-lsmod. Then locate the build configuration for the running kernel (see 'Start defining the build configuration for your kernel' for hints on where to find it) and store it as '~/test-machine-config-working'. Transfer both files to the home directory of your build host. -
Continue the guide on the build host (e.g. with 'Ensure to have enough free space for building [...]').
-
When you reach 'Start preparing a kernel build configuration[...]': before running
make olddefconfigfor the first time, execute the following command to base your configuration on the one from the test machine's 'working' kernel:cp ~/test-machine-config-working ~/linux/.config -
During the next step to 'disable any apparently superfluous kernel modules' use the following command instead:
yes '' | make localmodconfig LSMOD=~/lsmod_foo-machine localmodconfig -
Continue the guide, but ignore the instructions outlining how to compile, install, and reboot into a kernel every time they come up. Instead build like this:
cp ~/kernel-config-working .config make olddefconfig && make -j $(nproc --all) targz-pkgThis will generate a gzipped tar file whose name is printed in the last line shown; for example, a kernel with the kernelrelease identifier '6.0.0-rc1-local-g928a87efa423' built for x86 machines usually will be stored as '~/linux/linux-6.0.0-rc1-local-g928a87efa423-x86.tar.gz'.
Copy that file to your test machine's home directory.
-
Switch to the test machine to check if you have enough space to hold another kernel. Then extract the file you transferred:
sudo tar -xvzf ~/linux-6.0.0-rc1-local-g928a87efa423-x86.tar.gz -C /Afterwards generate the initramfs and add the kernel to your boot loader's configuration; on some distributions the following command will take care of both these tasks:
sudo /sbin/installkernel 6.0.0-rc1-local-g928a87efa423 /boot/vmlinuz-6.0.0-rc1-local-g928a87efa423Now reboot and ensure you started the intended kernel.
This approach even works when building for another architecture: just install cross-compilers and add the appropriate parameters to every invocation of make (e.g. make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- [...]).
Additional reading material #
-
The man page for 'git bisect' and fighting regressions with 'git bisect' in the Git documentation.
-
Working with git bisect from kernel developer Nathan Chancellor.
-
Using Git bisect to figure out when brokenness was introduced.