From: Petr Mladek <pmladek@suse.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: John Ogness <john.ogness@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Chris Down <chris@chrisdown.name>, Marc Zyngier <maz@kernel.org>,
Andrew Scull <ascull@google.com>, Will Deacon <will@kernel.org>,
Jason Baron <jbaron@akamai.com>,
Peter Zijlstra <peterz@infradead.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
linux-kernel@vger.kernel.org, Petr Mladek <pmladek@suse.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: [RFC 2/2] printk/bug: Remove cyclic dependency between bug.h and printk.h
Date: Tue, 11 Jan 2022 15:30:46 +0100 [thread overview]
Message-ID: <20220111143046.14680-3-pmladek@suse.com> (raw)
In-Reply-To: <20220111143046.14680-1-pmladek@suse.com>
`make headerdep` reports many circular dependencies with the same
pattern:
In file included from linux/bug.h,
from linux/jump_label.h:262
from linux/dynamic_debug.h:6
from linux/printk.h:504
from asm-generic/bug.h:22
from linux/bug.h:32 <-- here
It does not cause real problem because 'asm-generic/bug.h' uses only
plain printk() and no_printk(). And these two functions are defined
in 'printk.h' before 'dynamic_debug.h' is included.
There is no easy solution because all affected code does some inline
tricks:
+ printk() adds struct pi_entry metadata
+ dynamic_pr_debug() adds struct _ddebug metadata
+ static_branch_likely() adds assembly that realizes the jump
+ BUG() prints __FILE__, __LINE__, __func__ where it is inlined
One solution would be to modify BUG() and pass __FILE__, __LINE__,
__func__ into a helper function implemented in a .c source file.
It will not require including "printk.h" in "bug.h". The drawback
is code complication.
Alternative solution is to include "printk_core.h" and use the raw
_printk(). The drawback is that the string will not be listed in
printk index. But it will afftect only few architectires that do
not define HAVE_ARCH_BUG.
This patch uses the alternative solution because it seems to be
easier to maintain. The BUG() definitions are already complicated
enough thanks to all the ifdefs.
Reported-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
include/asm-generic/bug.h | 4 ++--
include/linux/printk.h | 11 -----------
include/linux/printk_core.h | 11 +++++++++++
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index edb0e2a602a8..140afb8bdfe7 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -19,7 +19,7 @@
#ifndef __ASSEMBLY__
#include <linux/panic.h>
-#include <linux/printk.h>
+#include <linux/printk_core.h>
#ifdef CONFIG_BUG
@@ -55,7 +55,7 @@ struct bug_entry {
*/
#ifndef HAVE_ARCH_BUG
#define BUG() do { \
- printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
+ _printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
barrier_before_unreachable(); \
panic("BUG!"); \
} while (0)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index c20f55df7fa6..23530b0a2a07 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -123,17 +123,6 @@ struct va_format {
*/
#define DEPRECATED "[Deprecated]: "
-/*
- * Dummy printk for disabled debugging statements to use whilst maintaining
- * gcc's format checking.
- */
-#define no_printk(fmt, ...) \
-({ \
- if (0) \
- printk(fmt, ##__VA_ARGS__); \
- 0; \
-})
-
#ifdef CONFIG_EARLY_PRINTK
extern asmlinkage __printf(1, 2)
void early_printk(const char *fmt, ...);
diff --git a/include/linux/printk_core.h b/include/linux/printk_core.h
index a2b8727a2873..37fc0e13fdbd 100644
--- a/include/linux/printk_core.h
+++ b/include/linux/printk_core.h
@@ -6,6 +6,17 @@
#include <linux/kern_levels.h>
#include <linux/linkage.h>
+/*
+ * Dummy printk for disabled debugging statements to use whilst maintaining
+ * gcc's format checking.
+ */
+#define no_printk(fmt, ...) \
+({ \
+ if (0) \
+ _printk(fmt, ##__VA_ARGS__); \
+ 0; \
+})
+
/* Low level printk API. Use carefully! */
#ifdef CONFIG_PRINTK
--
2.26.2
next prev parent reply other threads:[~2022-01-11 14:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 14:30 [RFC 0/2] printk: Remove cyclic include dependencies with printk.h Petr Mladek
2022-01-11 14:30 ` [RFC 1/2] printk/dynamic_debug: Remove cyclic dependency between printk.h and dynamic_debug.h Petr Mladek
2022-01-11 14:53 ` Chris Down
2022-01-11 16:01 ` Rasmus Villemoes
2022-01-12 12:12 ` Petr Mladek
2022-01-13 3:38 ` jim.cromie
2022-01-13 8:35 ` Petr Mladek
2022-01-17 22:39 ` jim.cromie
2022-01-13 9:02 ` Rasmus Villemoes
2022-01-11 14:30 ` Petr Mladek [this message]
2022-01-11 14:54 ` [RFC 2/2] printk/bug: Remove cyclic dependency between bug.h and printk.h Chris Down
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=20220111143046.14680-3-pmladek@suse.com \
--to=pmladek@suse.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=ascull@google.com \
--cc=chris@chrisdown.name \
--cc=jbaron@akamai.com \
--cc=john.ogness@linutronix.de \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=maz@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=will@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 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).