From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Petr Mladek <pmladek@suse.com>, Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Tejun Heo <tj@kernel.org>, Calvin Owens <calvinowens@fb.com>,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: [RFC][PATCH 4/7] printk: make alt_printk available when config printk set
Date: Tue, 27 Sep 2016 23:22:34 +0900 [thread overview]
Message-ID: <20160927142237.5539-5-sergey.senozhatsky@gmail.com> (raw)
In-Reply-To: <20160927142237.5539-1-sergey.senozhatsky@gmail.com>
alt_printk must be enabled on systems that have CONFIG_PRINTK set,
while NMI related functions must depend on CONFIG_PRINTK_NMI.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
include/linux/printk.h | 14 ++++++++------
kernel/printk/Makefile | 2 +-
kernel/printk/alt_printk.c | 23 +++++++++++++++++------
kernel/printk/internal.h | 31 +++++++++++++------------------
4 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 7510613..fae308a 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -131,17 +131,11 @@ void early_printk(const char *s, ...) { }
#endif
#ifdef CONFIG_PRINTK_NMI
-extern void alt_printk_init(void);
extern void printk_nmi_enter(void);
extern void printk_nmi_exit(void);
-extern void alt_printk_flush(void);
-extern void alt_printk_flush_on_panic(void);
#else
-static inline void alt_printk_init(void) { }
static inline void printk_nmi_enter(void) { }
static inline void printk_nmi_exit(void) { }
-static inline void alt_printk_flush(void) { }
-static inline void alt_printk_flush_on_panic(void) { }
#endif /* PRINTK_NMI */
#ifdef CONFIG_PRINTK
@@ -193,6 +187,10 @@ void __init setup_log_buf(int early);
__printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);
void dump_stack_print_info(const char *log_lvl);
void show_regs_print_info(const char *log_lvl);
+
+extern void alt_printk_init(void);
+extern void alt_printk_flush(void);
+extern void alt_printk_flush_on_panic(void);
#else
static inline __printf(1, 0)
int vprintk(const char *s, va_list args)
@@ -252,6 +250,10 @@ static inline void dump_stack_print_info(const char *log_lvl)
static inline void show_regs_print_info(const char *log_lvl)
{
}
+
+static inline void alt_printk_init(void) { }
+static inline void alt_printk_flush(void) { }
+static inline void alt_printk_flush_on_panic(void) { }
#endif
extern asmlinkage void dump_stack(void) __cold;
diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
index 3fc5e4e..d11838c 100644
--- a/kernel/printk/Makefile
+++ b/kernel/printk/Makefile
@@ -1,3 +1,3 @@
obj-y = printk.o
-obj-$(CONFIG_PRINTK_NMI) += alt_printk.o
+obj-$(CONFIG_PRINTK) += alt_printk.o
obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o
diff --git a/kernel/printk/alt_printk.c b/kernel/printk/alt_printk.c
index 8978390..8ac1daa 100644
--- a/kernel/printk/alt_printk.c
+++ b/kernel/printk/alt_printk.c
@@ -40,7 +40,6 @@
*/
DEFINE_PER_CPU(printk_func_t, printk_func) = vprintk_default;
static int alt_printk_irq_ready;
-atomic_t nmi_message_lost;
#define ALT_LOG_BUF_LEN ((1 << CONFIG_ALT_PRINTK_LOG_BUF_SHIFT) - \
sizeof(atomic_t) - sizeof(struct irq_work))
@@ -50,7 +49,11 @@ struct alt_printk_seq_buf {
struct irq_work work; /* IRQ work that flushes the buffer */
unsigned char buffer[ALT_LOG_BUF_LEN];
};
+
+#ifdef CONFIG_PRINTK_NMI
static DEFINE_PER_CPU(struct alt_printk_seq_buf, nmi_print_seq);
+atomic_t nmi_message_lost;
+#endif
/*
* There can be two alt_printk contexts at most - a `normal' alt_printk
@@ -320,8 +323,12 @@ void alt_printk_flush(void)
{
int cpu;
- for_each_possible_cpu(cpu)
- __alt_printk_flush(&per_cpu(nmi_print_seq, cpu).work);
+ for_each_possible_cpu(cpu) {
+ if (IS_ENABLED(CONFIG_PRINTK_NMI))
+ __alt_printk_flush(&per_cpu(nmi_print_seq, cpu).work);
+
+ __alt_printk_flush(&per_cpu(alt_print_seq, cpu).work);
+ }
}
/**
@@ -356,12 +363,14 @@ void __init alt_printk_init(void)
int cpu;
for_each_possible_cpu(cpu) {
- struct alt_printk_seq_buf *s = &per_cpu(nmi_print_seq, cpu);
+ struct alt_printk_seq_buf *s = &per_cpu(alt_print_seq, cpu);
init_irq_work(&s->work, __alt_printk_flush);
- s = &per_cpu(alt_print_seq, cpu);
- init_irq_work(&s->work, __alt_printk_flush);
+ if (IS_ENABLED(CONFIG_PRINTK_NMI)) {
+ s = &per_cpu(nmi_print_seq, cpu);
+ init_irq_work(&s->work, __alt_printk_flush);
+ }
}
/* Make sure that IRQ works are initialized before enabling. */
@@ -372,6 +381,7 @@ void __init alt_printk_init(void)
alt_printk_flush();
}
+#ifdef CONFIG_PRINTK_NMI
/*
* Safe printk() for NMI context. It uses a per-CPU buffer to
* store the message. NMIs are not nested, so there is always only
@@ -399,3 +409,4 @@ void printk_nmi_exit(void)
{
__lockless_printk_exit();
}
+#endif /* CONFIG_PRINTK_NMI */
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index c5f970e..3eebf6d 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -18,21 +18,9 @@
typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
-int __printf(1, 0) vprintk_default(const char *fmt, va_list args);
-
#ifdef CONFIG_PRINTK
-void alt_printk_enter(void);
-void alt_printk_exit(void);
-
-#else
-
-void alt_printk_enter(void) { }
-void alt_printk_exit(void) { }
-
-#endif /* CONFIG_PRINTK */
-
-#ifdef CONFIG_PRINTK_NMI
+int __printf(1, 0) vprintk_default(const char *fmt, va_list args);
extern raw_spinlock_t logbuf_lock;
@@ -48,6 +36,18 @@ static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
return this_cpu_read(printk_func)(fmt, args);
}
+void alt_printk_enter(void);
+void alt_printk_exit(void);
+
+#else
+
+void alt_printk_enter(void) { }
+void alt_printk_exit(void) { }
+
+#endif /* CONFIG_PRINTK */
+
+#ifdef CONFIG_PRINTK_NMI
+
extern atomic_t nmi_message_lost;
static inline int get_nmi_message_lost(void)
{
@@ -56,11 +56,6 @@ static inline int get_nmi_message_lost(void)
#else /* CONFIG_PRINTK_NMI */
-static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
-{
- return vprintk_default(fmt, args);
-}
-
static inline int get_nmi_message_lost(void)
{
return 0;
--
2.10.0.372.g6fe1b14
next prev parent reply other threads:[~2016-09-27 14:25 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-27 14:22 [RFC][PATCH 0/7] printk: use alt_printk to handle printk() recursive calls Sergey Senozhatsky
2016-09-27 14:22 ` [RFC][PATCH 1/7] printk: use vprintk_func in vprintk() Sergey Senozhatsky
2016-09-27 14:22 ` [RFC][PATCH 2/7] printk: rename nmi.c and exported api Sergey Senozhatsky
2016-09-27 14:22 ` [RFC][PATCH 3/7] printk: introduce per-cpu alt_print seq buffer Sergey Senozhatsky
2016-09-29 12:26 ` Petr Mladek
2016-09-30 1:05 ` Sergey Senozhatsky
2016-09-30 11:35 ` Petr Mladek
2016-09-27 14:22 ` Sergey Senozhatsky [this message]
2016-09-27 14:22 ` [RFC][PATCH 5/7] printk: drop vprintk_func function Sergey Senozhatsky
2016-09-27 14:22 ` [RFC][PATCH 6/7] printk: use alternative printk buffers Sergey Senozhatsky
2016-09-29 13:00 ` Petr Mladek
2016-09-30 1:15 ` Sergey Senozhatsky
2016-09-30 11:15 ` Petr Mladek
2016-10-01 2:48 ` Sergey Senozhatsky
2016-10-04 12:22 ` Petr Mladek
2016-10-05 1:36 ` Sergey Senozhatsky
2016-10-05 10:18 ` Petr Mladek
2016-10-03 7:53 ` Sergey Senozhatsky
2016-10-04 14:52 ` Petr Mladek
2016-10-05 1:27 ` Sergey Senozhatsky
2016-10-05 9:50 ` Petr Mladek
2016-10-06 4:22 ` Sergey Senozhatsky
2016-10-06 11:32 ` Petr Mladek
2016-10-10 4:09 ` Sergey Senozhatsky
2016-10-10 11:17 ` Petr Mladek
2016-10-11 7:35 ` Sergey Senozhatsky
2016-10-11 9:30 ` Petr Mladek
2016-09-27 14:22 ` [RFC][PATCH 7/7] printk: new printk() recursion detection Sergey Senozhatsky
2016-09-29 13:19 ` Petr Mladek
2016-09-30 2:00 ` Sergey Senozhatsky
2016-09-29 13:25 ` [RFC][PATCH 0/7] printk: use alt_printk to handle printk() recursive calls Petr Mladek
2016-09-30 2:43 ` Sergey Senozhatsky
2016-09-30 11:27 ` Petr Mladek
2016-10-01 3:02 ` Sergey Senozhatsky
2016-10-04 11:35 ` Petr Mladek
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=20160927142237.5539-5-sergey.senozhatsky@gmail.com \
--to=sergey.senozhatsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=calvinowens@fb.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=tj@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
all inboxes | Powered by JetHome®