Skip to content

Commit 93d102f

Browse files
jognesspmladek
authored andcommitted
printk: remove safe buffers
With @logbuf_lock removed, the high level printk functions for storing messages are lockless. Messages can be stored from any context, so there is no need for the NMI and safe buffers anymore. Remove the NMI and safe buffers. Although the safe buffers are removed, the NMI and safe context tracking is still in place. In these contexts, store the message immediately but still use irq_work to defer the console printing. Since printk recursion tracking is in place, safe context tracking for most of printk is not needed. Remove it. Only safe context tracking relating to the console and console_owner locks is left in place. This is because the console and console_owner locks are needed for the actual printing. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 002eb6a commit 93d102f

File tree

9 files changed

+48
-450
lines changed

9 files changed

+48
-450
lines changed

arch/powerpc/kernel/traps.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ extern void panic_flush_kmsg_start(void)
170170

171171
extern void panic_flush_kmsg_end(void)
172172
{
173-
printk_safe_flush_on_panic();
174173
kmsg_dump(KMSG_DUMP_PANIC);
175174
bust_spinlocks(0);
176175
debug_locks_off();

arch/powerpc/kernel/watchdog.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,6 @@ static void watchdog_smp_panic(int cpu, u64 tb)
183183

184184
wd_smp_unlock(&flags);
185185

186-
printk_safe_flush();
187-
/*
188-
* printk_safe_flush() seems to require another print
189-
* before anything actually goes out to console.
190-
*/
191186
if (sysctl_hardlockup_all_cpu_backtrace)
192187
trigger_allbutself_cpu_backtrace();
193188

include/linux/printk.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ void dump_stack_print_info(const char *log_lvl);
208208
void show_regs_print_info(const char *log_lvl);
209209
extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold;
210210
extern asmlinkage void dump_stack(void) __cold;
211-
extern void printk_safe_flush(void);
212-
extern void printk_safe_flush_on_panic(void);
213211
#else
214212
static inline __printf(1, 0)
215213
int vprintk(const char *s, va_list args)
@@ -277,14 +275,6 @@ static inline void dump_stack_lvl(const char *log_lvl)
277275
static inline void dump_stack(void)
278276
{
279277
}
280-
281-
static inline void printk_safe_flush(void)
282-
{
283-
}
284-
285-
static inline void printk_safe_flush_on_panic(void)
286-
{
287-
}
288278
#endif
289279

290280
#ifdef CONFIG_SMP

kernel/kexec_core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,6 @@ void crash_kexec(struct pt_regs *regs)
978978
old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu);
979979
if (old_cpu == PANIC_CPU_INVALID) {
980980
/* This is the 1st CPU which comes here, so go ahead. */
981-
printk_safe_flush_on_panic();
982981
__crash_kexec(regs);
983982

984983
/*

kernel/panic.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ void panic(const char *fmt, ...)
247247
* Bypass the panic_cpu check and call __crash_kexec directly.
248248
*/
249249
if (!_crash_kexec_post_notifiers) {
250-
printk_safe_flush_on_panic();
251250
__crash_kexec(NULL);
252251

253252
/*
@@ -271,8 +270,6 @@ void panic(const char *fmt, ...)
271270
*/
272271
atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
273272

274-
/* Call flush even twice. It tries harder with a single online CPU */
275-
printk_safe_flush_on_panic();
276273
kmsg_dump(KMSG_DUMP_PANIC);
277274

278275
/*

kernel/printk/internal.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
2222
void __printk_safe_enter(void);
2323
void __printk_safe_exit(void);
2424

25-
void printk_safe_init(void);
2625
bool printk_percpu_data_ready(void);
2726

2827
#define printk_safe_enter_irqsave(flags) \
@@ -37,18 +36,6 @@ bool printk_percpu_data_ready(void);
3736
local_irq_restore(flags); \
3837
} while (0)
3938

40-
#define printk_safe_enter_irq() \
41-
do { \
42-
local_irq_disable(); \
43-
__printk_safe_enter(); \
44-
} while (0)
45-
46-
#define printk_safe_exit_irq() \
47-
do { \
48-
__printk_safe_exit(); \
49-
local_irq_enable(); \
50-
} while (0)
51-
5239
void defer_console_output(void);
5340

5441
#else
@@ -61,9 +48,5 @@ void defer_console_output(void);
6148
#define printk_safe_enter_irqsave(flags) local_irq_save(flags)
6249
#define printk_safe_exit_irqrestore(flags) local_irq_restore(flags)
6350

64-
#define printk_safe_enter_irq() local_irq_disable()
65-
#define printk_safe_exit_irq() local_irq_enable()
66-
67-
static inline void printk_safe_init(void) { }
6851
static inline bool printk_percpu_data_ready(void) { return false; }
6952
#endif /* CONFIG_PRINTK */

0 commit comments

Comments
 (0)