workflows.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Documentation: coding-style: don't encourage WARN*()
@ 2024-04-14 17:08 Alex Elder
  2024-04-14 19:48 ` Laurent Pinchart
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Alex Elder @ 2024-04-14 17:08 UTC (permalink / raw)
  To: corbet; +Cc: gregkh, workflows, linux-doc, linux-kernel

Several times recently Greg KH has admonished that variants of WARN()
should not be used, because when the panic_on_warn kernel option is set,
their use can lead to a panic. His reasoning was that the majority of
Linux instances (including Android and cloud systems) run with this option
enabled. And therefore a condition leading to a warning will frequently
cause an undesirable panic.

The "coding-style.rst" document says not to worry about this kernel
option.  Update it to provide a more nuanced explanation.

Signed-off-by: Alex Elder <elder@linaro.org>
---
 Documentation/process/coding-style.rst | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst
index 9c7cf73473943..bce43b01721cb 100644
--- a/Documentation/process/coding-style.rst
+++ b/Documentation/process/coding-style.rst
@@ -1235,17 +1235,18 @@ example. Again: WARN*() must not be used for a condition that is expected
 to trigger easily, for example, by user space actions. pr_warn_once() is a
 possible alternative, if you need to notify the user of a problem.
 
-Do not worry about panic_on_warn users
-**************************************
+The panic_on_warn kernel option
+********************************
 
-A few more words about panic_on_warn: Remember that ``panic_on_warn`` is an
-available kernel option, and that many users set this option. This is why
-there is a "Do not WARN lightly" writeup, above. However, the existence of
-panic_on_warn users is not a valid reason to avoid the judicious use
-WARN*(). That is because, whoever enables panic_on_warn has explicitly
-asked the kernel to crash if a WARN*() fires, and such users must be
-prepared to deal with the consequences of a system that is somewhat more
-likely to crash.
+Note that ``panic_on_warn`` is an available kernel option. If it is enabled,
+a WARN*() call whose condition holds leads to a kernel panic.  Many users
+(including Android and many cloud providers) set this option, and this is
+why there is a "Do not WARN lightly" writeup, above.
+
+The existence of this option is not a valid reason to avoid the judicious
+use of warnings. There are other options: ``dev_warn*()`` and ``pr_warn*()``
+issue warnings but do **not** cause the kernel to crash. Use these if you
+want to prevent such panics.
 
 Use BUILD_BUG_ON() for compile-time assertions
 **********************************************
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-04-19  7:16 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-14 17:08 [PATCH] Documentation: coding-style: don't encourage WARN*() Alex Elder
2024-04-14 19:48 ` Laurent Pinchart
2024-04-14 20:06   ` Alex Elder
2024-04-15  5:21   ` Greg KH
2024-04-15  8:25     ` Laurent Pinchart
2024-04-15  8:33       ` Greg KH
2024-04-15  8:42         ` Laurent Pinchart
2024-04-15  5:22 ` Greg KH
2024-04-15  8:07 ` Christoph Hellwig
2024-04-15  8:35   ` Greg KH
2024-04-15  8:46     ` Christoph Hellwig
2024-04-15 16:26     ` Kees Cook
2024-04-18 15:57       ` Jason Gunthorpe
2024-04-18 16:14 ` Eric Biggers
2024-04-18 17:12   ` Kees Cook
2024-04-18 22:33   ` John Hubbard
2024-04-19  7:16 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).