From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,gregkh@linuxfoundation.org,jani.nikula@intel.com,akpm@linux-foundation.org
Subject: [merged mm-nonmm-stable] kernel-panic-add-verbose-logging-of-kernel-taints-in-backtraces.patch removed from -mm tree
Date: Mon, 24 Jun 2024 22:26:40 -0700 [thread overview]
Message-ID: <20240625052640.AB82AC32789@smtp.kernel.org> (raw)
The quilt patch titled
Subject: kernel/panic: add verbose logging of kernel taints in backtraces
has been removed from the -mm tree. Its filename was
kernel-panic-add-verbose-logging-of-kernel-taints-in-backtraces.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Jani Nikula <jani.nikula@intel.com>
Subject: kernel/panic: add verbose logging of kernel taints in backtraces
Date: Fri, 31 May 2024 12:04:57 +0300
With nearly 20 taint flags and respective characters, it's getting a bit
difficult to remember what each taint flag character means. Add verbose
logging of the set taints in the format:
Tainted: [P]=PROPRIETARY_MODULE, [W]=WARN
in dump_stack_print_info() when there are taints.
Note that the "negative flag" G is not included.
Link: https://lkml.kernel.org/r/7321e306166cb2ca2807ab8639e665baa2462e9c.1717146197.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/panic.h | 8 ++++---
kernel/panic.c | 45 ++++++++++++++++++++++++++++++----------
lib/dump_stack.c | 3 ++
3 files changed, 42 insertions(+), 14 deletions(-)
--- a/include/linux/panic.h~kernel-panic-add-verbose-logging-of-kernel-taints-in-backtraces
+++ a/include/linux/panic.h
@@ -77,9 +77,10 @@ static inline void set_arch_panic_timeou
#define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1)
struct taint_flag {
- char c_true; /* character printed when tainted */
- char c_false; /* character printed when not tainted */
- bool module; /* also show as a per-module taint flag */
+ char c_true; /* character printed when tainted */
+ char c_false; /* character printed when not tainted */
+ bool module; /* also show as a per-module taint flag */
+ const char *desc; /* verbose description of the set taint flag */
};
extern const struct taint_flag taint_flags[TAINT_FLAGS_COUNT];
@@ -90,6 +91,7 @@ enum lockdep_ok {
};
extern const char *print_tainted(void);
+extern const char *print_tainted_verbose(void);
extern void add_taint(unsigned flag, enum lockdep_ok);
extern int test_taint(unsigned flag);
extern unsigned long get_taint(void);
--- a/kernel/panic.c~kernel-panic-add-verbose-logging-of-kernel-taints-in-backtraces
+++ a/kernel/panic.c
@@ -475,6 +475,7 @@ EXPORT_SYMBOL(panic);
[ TAINT_##taint ] = { \
.c_true = _c_true, .c_false = _c_false, \
.module = _module, \
+ .desc = #taint, \
}
/*
@@ -505,8 +506,9 @@ const struct taint_flag taint_flags[TAIN
#undef TAINT_FLAG
-static void print_tainted_seq(struct seq_buf *s)
+static void print_tainted_seq(struct seq_buf *s, bool verbose)
{
+ const char *sep = "";
int i;
if (!tainted_mask) {
@@ -520,10 +522,32 @@ static void print_tainted_seq(struct seq
bool is_set = test_bit(i, &tainted_mask);
char c = is_set ? t->c_true : t->c_false;
- seq_buf_putc(s, c);
+ if (verbose) {
+ if (is_set) {
+ seq_buf_printf(s, "%s[%c]=%s", sep, c, t->desc);
+ sep = ", ";
+ }
+ } else {
+ seq_buf_putc(s, c);
+ }
}
}
+static const char *_print_tainted(bool verbose)
+{
+ /* FIXME: what should the size be? */
+ static char buf[sizeof(taint_flags)];
+ struct seq_buf s;
+
+ BUILD_BUG_ON(ARRAY_SIZE(taint_flags) != TAINT_FLAGS_COUNT);
+
+ seq_buf_init(&s, buf, sizeof(buf));
+
+ print_tainted_seq(&s, verbose);
+
+ return seq_buf_str(&s);
+}
+
/**
* print_tainted - return a string to represent the kernel taint state.
*
@@ -534,16 +558,15 @@ static void print_tainted_seq(struct seq
*/
const char *print_tainted(void)
{
- static char buf[TAINT_FLAGS_COUNT + sizeof("Tainted: ")];
- struct seq_buf s;
-
- BUILD_BUG_ON(ARRAY_SIZE(taint_flags) != TAINT_FLAGS_COUNT);
-
- seq_buf_init(&s, buf, sizeof(buf));
-
- print_tainted_seq(&s);
+ return _print_tainted(false);
+}
- return seq_buf_str(&s);
+/**
+ * print_tainted_verbose - A more verbose version of print_tainted()
+ */
+const char *print_tainted_verbose(void)
+{
+ return _print_tainted(true);
}
int test_taint(unsigned flag)
--- a/lib/dump_stack.c~kernel-panic-add-verbose-logging-of-kernel-taints-in-backtraces
+++ a/lib/dump_stack.c
@@ -62,6 +62,9 @@ void dump_stack_print_info(const char *l
(int)strcspn(init_utsname()->version, " "),
init_utsname()->version, BUILD_ID_VAL);
+ if (get_taint())
+ printk("%s%s\n", log_lvl, print_tainted_verbose());
+
if (dump_stack_arch_desc_str[0] != '\0')
printk("%sHardware name: %s\n",
log_lvl, dump_stack_arch_desc_str);
_
Patches currently in -mm which might be from jani.nikula@intel.com are
reply other threads:[~2024-06-25 5:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240625052640.AB82AC32789@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=jani.nikula@intel.com \
--cc=mm-commits@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.