6

I always have /proc/sys/kernel/panic set up to 0. Looking at description of this option in kernel.org we can see:

panic:

The value in this file represents the number of seconds the kernel waits before rebooting on a panic. When you use the software watchdog, the recommended setting is 60.

From here one can conclude that 0 is 0 seconds waiting before reboot - immediate reboot.
But proc MAN page states the following:

/proc/sys/kernel/panic
This file gives read/write access to the kernel variable panic_timeout. If this is zero, the kernel will loop on a panic; if nonzero, it indicates that the kernel should autore‐ boot after this number of seconds. When you use the software watchdog device driver, the recommended setting is 60.

Here 0 means antipodal thing - never reboot.

So why such a trusted source gives such a misleading info? Or maybe the MAN page is inaccurate?

P.S. just from a hint in panic_on_oops section (if you happen to read this) you can guess that MAN page is right. Or if you are technically skilled enough to investigate something in kernel source code.

12
  • 9
    "Inaccurate" or perhaps "too general" seems like a much better characterization of this than "lying", which is a harsh accusation to levy against a project maintained by volunteers. Have you looked into submitting a patch with more accurate language?
    – larsks
    Jan 29, 2020 at 12:41
  • 2
    @larsks Edited to be more friendly. But it has nothing to do with "accusation" at all. It was a regular question perhaps a little incorrectly worded because of my poor English
    – red0ct
    Jan 29, 2020 at 12:45
  • 3
    @rastafile nobody is paid to maintain the kernel documentation; while much of the rest of the kernel is not maintained by “pure volunteers”, the documentation still is. See this talk on the subject by the kernel documentation maintainer, Jonathan Corbet, given at KR 2019. Jan 29, 2020 at 14:55
  • 1
    Did you notice "This file contains documentation for the sysctl files in /proc/sys/kernel/ and is valid for Linux kernel version 2.2." ? Are you running Linux kernel version 2.2?
    – hobbs
    Jan 30, 2020 at 2:54
  • 1
    @rastafile or wait until the article becomes freely available, later today — all the content on LWN is freely accessible after a week. Incidentally the article you’re complaining about is a summary of the talk I linked to above, so you could also watch that instead. (But if you find LWN content useful, it’s worth supporting it. People are allowed to make a living from their work.) Jan 30, 2020 at 5:39

2 Answers 2

18

The authoritative source is the implementation in the kernel, so let’s look at that first.

The panic entry in sysctl corresponds to a kernel variable called panic_timeout. This is a signed integer, used to control behaviour on panic as follows:

  • if panic_timeout is strictly positive, the kernel waits after a panic, for panic_timeout seconds;
  • if panic_timeout is non-zero, the kernel reboots after a panic (after waiting, if appropriate);
  • if the kernel hasn’t rebooted, it prints a message and loops forever.

So the manpage is correct, and the kernel’s own documentation was incomplete; but sysctl/kernel.rst now documents panic in more detail. This was fixed in version 5.7-rc1 of the kernel.

1
  • Upvoted because i love responses that point source code: source code never lie and nothing can be more factual ;-)
    – binarym
    Jan 30, 2020 at 9:58
2

So why such a trusted source gives such a misleading info?

First it is only slightly misleading - you rather jump to your conclusion - than a misktake. I would say the kernel.org neglects the special case "0".

I don't know the details of kernel.org, but in essence it is a mix of official kernel Documentation/ (web formatted, grouped), plus some additional info. Best example is the boot params list, which is "gathered" from different places, as they put it.

"kernel.org" lists the "Documentation" link under "Other Resources". It takes you to doc/html/latest/. There is also a mixed bag of links under /doc.

Right at the start the (sphinx formatted) Documentation says:

Kernel documentation, like the kernel itself, is very much a work in progress; that is especially true as we work to integrate our many scattered documents into a coherent whole. Please note that improvements to the documentation are welcome;...

The man 5 proc is part of man-pages project (or package), and there is this guy with the book-to-stun-an-ox who is maintaining it. These pages all have "COLOPHON" as subtitle (section) at the end. They are also heterogenous, some just collected (all the POSIX "1p" pages), and some written to fill the gaps.

On man7.org you directly see Mr. Kerrisk's oeuvre -- I think he does a good job, selling his book but maintaining a collection of open source man pages.

I this case, he is more precise. Both seem related, of course ("When you...device driver... 60").


we work to integrate our many scattered documents into a coherent whole.

This only makes halfways sense. Whose documents were scattered, and by whom?


My pseudocode goes like this:

if timeout > 0   then loop for 'timeout' seconds
if timeout != 0  then reboot
loop for ever

Which means a negative value is immediate reboot, and a positive one has both ifs true. And zero leads directly to the final loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.