Skip to content

Commit c985aaf

Browse files
committed
Merge branch 'rework/printk_safe-removal' into for-linus
2 parents 715d3ed + 26d1982 commit c985aaf

File tree

14 files changed

+192
-544
lines changed

14 files changed

+192
-544
lines changed

arch/arm/kernel/smp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,9 @@ static void do_handle_IPI(int ipinr)
667667
break;
668668

669669
case IPI_CPU_BACKTRACE:
670-
printk_nmi_enter();
670+
printk_deferred_enter();
671671
nmi_cpu_backtrace(get_irq_regs());
672-
printk_nmi_exit();
672+
printk_deferred_exit();
673673
break;
674674

675675
default:

arch/powerpc/kernel/traps.c

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

172172
extern void panic_flush_kmsg_end(void)
173173
{
174-
printk_safe_flush_on_panic();
175174
kmsg_dump(KMSG_DUMP_PANIC);
176175
bust_spinlocks(0);
177176
debug_locks_off();

arch/powerpc/kernel/watchdog.c

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

185185
wd_smp_unlock(&flags);
186186

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

arch/powerpc/kexec/crash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
313313
int (*old_handler)(struct pt_regs *regs);
314314

315315
/* Avoid hardlocking with irresponsive CPU holding logbuf_lock */
316-
printk_nmi_enter();
316+
printk_deferred_enter();
317317

318318
/*
319319
* This function is only called after the system

include/linux/hardirq.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ extern void rcu_nmi_exit(void);
116116
do { \
117117
lockdep_off(); \
118118
arch_nmi_enter(); \
119-
printk_nmi_enter(); \
120119
BUG_ON(in_nmi() == NMI_MASK); \
121120
__preempt_count_add(NMI_OFFSET + HARDIRQ_OFFSET); \
122121
} while (0)
@@ -135,7 +134,6 @@ extern void rcu_nmi_exit(void);
135134
do { \
136135
BUG_ON(!in_nmi()); \
137136
__preempt_count_sub(NMI_OFFSET + HARDIRQ_OFFSET); \
138-
printk_nmi_exit(); \
139137
arch_nmi_exit(); \
140138
lockdep_on(); \
141139
} while (0)

include/linux/printk.h

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,6 @@ static inline __printf(1, 2) __cold
141141
void early_printk(const char *s, ...) { }
142142
#endif
143143

144-
#ifdef CONFIG_PRINTK_NMI
145-
extern void printk_nmi_enter(void);
146-
extern void printk_nmi_exit(void);
147-
extern void printk_nmi_direct_enter(void);
148-
extern void printk_nmi_direct_exit(void);
149-
#else
150-
static inline void printk_nmi_enter(void) { }
151-
static inline void printk_nmi_exit(void) { }
152-
static inline void printk_nmi_direct_enter(void) { }
153-
static inline void printk_nmi_direct_exit(void) { }
154-
#endif /* PRINTK_NMI */
155-
156144
struct dev_printk_info;
157145

158146
#ifdef CONFIG_PRINTK
@@ -172,6 +160,16 @@ int _printk(const char *fmt, ...);
172160
*/
173161
__printf(1, 2) __cold int _printk_deferred(const char *fmt, ...);
174162

163+
extern void __printk_safe_enter(void);
164+
extern void __printk_safe_exit(void);
165+
/*
166+
* The printk_deferred_enter/exit macros are available only as a hack for
167+
* some code paths that need to defer all printk console printing. Interrupts
168+
* must be disabled for the deferred duration.
169+
*/
170+
#define printk_deferred_enter __printk_safe_enter
171+
#define printk_deferred_exit __printk_safe_exit
172+
175173
/*
176174
* Please don't use printk_ratelimit(), because it shares ratelimiting state
177175
* with all other unrelated printk_ratelimit() callsites. Instead use
@@ -200,8 +198,6 @@ void dump_stack_print_info(const char *log_lvl);
200198
void show_regs_print_info(const char *log_lvl);
201199
extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold;
202200
extern asmlinkage void dump_stack(void) __cold;
203-
extern void printk_safe_flush(void);
204-
extern void printk_safe_flush_on_panic(void);
205201
#else
206202
static inline __printf(1, 0)
207203
int vprintk(const char *s, va_list args)
@@ -218,6 +214,15 @@ int _printk_deferred(const char *s, ...)
218214
{
219215
return 0;
220216
}
217+
218+
static inline void printk_deferred_enter(void)
219+
{
220+
}
221+
222+
static inline void printk_deferred_exit(void)
223+
{
224+
}
225+
221226
static inline int printk_ratelimit(void)
222227
{
223228
return 0;
@@ -269,14 +274,6 @@ static inline void dump_stack_lvl(const char *log_lvl)
269274
static inline void dump_stack(void)
270275
{
271276
}
272-
273-
static inline void printk_safe_flush(void)
274-
{
275-
}
276-
277-
static inline void printk_safe_flush_on_panic(void)
278-
{
279-
}
280277
#endif
281278

282279
#ifdef CONFIG_SMP

init/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,11 +1523,6 @@ config PRINTK
15231523
very difficult to diagnose system problems, saying N here is
15241524
strongly discouraged.
15251525

1526-
config PRINTK_NMI
1527-
def_bool y
1528-
depends on PRINTK
1529-
depends on HAVE_NMI
1530-
15311526
config BUG
15321527
bool "BUG() support" if EXPERT
15331528
default y

kernel/kexec_core.c

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

985984
/*

kernel/panic.c

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

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

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

279276
/*

kernel/printk/internal.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
#ifdef CONFIG_PRINTK
88

9-
#define PRINTK_SAFE_CONTEXT_MASK 0x007ffffff
10-
#define PRINTK_NMI_DIRECT_CONTEXT_MASK 0x008000000
11-
#define PRINTK_NMI_CONTEXT_MASK 0xff0000000
12-
13-
#define PRINTK_NMI_CONTEXT_OFFSET 0x010000000
14-
159
/* Flags for a single printk record. */
1610
enum printk_info_flags {
1711
LOG_NEWLINE = 2, /* text ended with a newline */
@@ -25,10 +19,7 @@ int vprintk_store(int facility, int level,
2519

2620
__printf(1, 0) int vprintk_default(const char *fmt, va_list args);
2721
__printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
28-
void __printk_safe_enter(void);
29-
void __printk_safe_exit(void);
3022

31-
void printk_safe_init(void);
3223
bool printk_percpu_data_ready(void);
3324

3425
#define printk_safe_enter_irqsave(flags) \
@@ -43,18 +34,6 @@ bool printk_percpu_data_ready(void);
4334
local_irq_restore(flags); \
4435
} while (0)
4536

46-
#define printk_safe_enter_irq() \
47-
do { \
48-
local_irq_disable(); \
49-
__printk_safe_enter(); \
50-
} while (0)
51-
52-
#define printk_safe_exit_irq() \
53-
do { \
54-
__printk_safe_exit(); \
55-
local_irq_enable(); \
56-
} while (0)
57-
5837
void defer_console_output(void);
5938

6039
u16 printk_parse_prefix(const char *text, int *level,
@@ -69,9 +48,5 @@ u16 printk_parse_prefix(const char *text, int *level,
6948
#define printk_safe_enter_irqsave(flags) local_irq_save(flags)
7049
#define printk_safe_exit_irqrestore(flags) local_irq_restore(flags)
7150

72-
#define printk_safe_enter_irq() local_irq_disable()
73-
#define printk_safe_exit_irq() local_irq_enable()
74-
75-
static inline void printk_safe_init(void) { }
7651
static inline bool printk_percpu_data_ready(void) { return false; }
7752
#endif /* CONFIG_PRINTK */

0 commit comments

Comments
 (0)