Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
Merge branch 'rework/printk_safe-removal' into for-linus
Browse files Browse the repository at this point in the history
  • Loading branch information
pmladek committed Aug 30, 2021
2 parents 715d3ed + 26d1982 commit c985aaf
Show file tree
Hide file tree
Showing 14 changed files with 192 additions and 544 deletions.
4 changes: 2 additions & 2 deletions arch/arm/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@ static void do_handle_IPI(int ipinr)
break;

case IPI_CPU_BACKTRACE:
printk_nmi_enter();
printk_deferred_enter();
nmi_cpu_backtrace(get_irq_regs());
printk_nmi_exit();
printk_deferred_exit();
break;

default:
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ extern void panic_flush_kmsg_start(void)

extern void panic_flush_kmsg_end(void)
{
printk_safe_flush_on_panic();
kmsg_dump(KMSG_DUMP_PANIC);
bust_spinlocks(0);
debug_locks_off();
Expand Down
5 changes: 0 additions & 5 deletions arch/powerpc/kernel/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ static void watchdog_smp_panic(int cpu, u64 tb)

wd_smp_unlock(&flags);

printk_safe_flush();
/*
* printk_safe_flush() seems to require another print
* before anything actually goes out to console.
*/
if (sysctl_hardlockup_all_cpu_backtrace)
trigger_allbutself_cpu_backtrace();

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kexec/crash.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
int (*old_handler)(struct pt_regs *regs);

/* Avoid hardlocking with irresponsive CPU holding logbuf_lock */
printk_nmi_enter();
printk_deferred_enter();

/*
* This function is only called after the system
Expand Down
2 changes: 0 additions & 2 deletions include/linux/hardirq.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ extern void rcu_nmi_exit(void);
do { \
lockdep_off(); \
arch_nmi_enter(); \
printk_nmi_enter(); \
BUG_ON(in_nmi() == NMI_MASK); \
__preempt_count_add(NMI_OFFSET + HARDIRQ_OFFSET); \
} while (0)
Expand All @@ -135,7 +134,6 @@ extern void rcu_nmi_exit(void);
do { \
BUG_ON(!in_nmi()); \
__preempt_count_sub(NMI_OFFSET + HARDIRQ_OFFSET); \
printk_nmi_exit(); \
arch_nmi_exit(); \
lockdep_on(); \
} while (0)
Expand Down
41 changes: 19 additions & 22 deletions include/linux/printk.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,6 @@ static inline __printf(1, 2) __cold
void early_printk(const char *s, ...) { }
#endif

#ifdef CONFIG_PRINTK_NMI
extern void printk_nmi_enter(void);
extern void printk_nmi_exit(void);
extern void printk_nmi_direct_enter(void);
extern void printk_nmi_direct_exit(void);
#else
static inline void printk_nmi_enter(void) { }
static inline void printk_nmi_exit(void) { }
static inline void printk_nmi_direct_enter(void) { }
static inline void printk_nmi_direct_exit(void) { }
#endif /* PRINTK_NMI */

struct dev_printk_info;

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

extern void __printk_safe_enter(void);
extern void __printk_safe_exit(void);
/*
* The printk_deferred_enter/exit macros are available only as a hack for
* some code paths that need to defer all printk console printing. Interrupts
* must be disabled for the deferred duration.
*/
#define printk_deferred_enter __printk_safe_enter
#define printk_deferred_exit __printk_safe_exit

/*
* Please don't use printk_ratelimit(), because it shares ratelimiting state
* with all other unrelated printk_ratelimit() callsites. Instead use
Expand Down Expand Up @@ -200,8 +198,6 @@ void dump_stack_print_info(const char *log_lvl);
void show_regs_print_info(const char *log_lvl);
extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold;
extern asmlinkage void dump_stack(void) __cold;
extern void printk_safe_flush(void);
extern void printk_safe_flush_on_panic(void);
#else
static inline __printf(1, 0)
int vprintk(const char *s, va_list args)
Expand All @@ -218,6 +214,15 @@ int _printk_deferred(const char *s, ...)
{
return 0;
}

static inline void printk_deferred_enter(void)
{
}

static inline void printk_deferred_exit(void)
{
}

static inline int printk_ratelimit(void)
{
return 0;
Expand Down Expand Up @@ -269,14 +274,6 @@ static inline void dump_stack_lvl(const char *log_lvl)
static inline void dump_stack(void)
{
}

static inline void printk_safe_flush(void)
{
}

static inline void printk_safe_flush_on_panic(void)
{
}
#endif

#ifdef CONFIG_SMP
Expand Down
5 changes: 0 additions & 5 deletions init/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1523,11 +1523,6 @@ config PRINTK
very difficult to diagnose system problems, saying N here is
strongly discouraged.

config PRINTK_NMI
def_bool y
depends on PRINTK
depends on HAVE_NMI

config BUG
bool "BUG() support" if EXPERT
default y
Expand Down
1 change: 0 additions & 1 deletion kernel/kexec_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,6 @@ void crash_kexec(struct pt_regs *regs)
old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu);
if (old_cpu == PANIC_CPU_INVALID) {
/* This is the 1st CPU which comes here, so go ahead. */
printk_safe_flush_on_panic();
__crash_kexec(regs);

/*
Expand Down
3 changes: 0 additions & 3 deletions kernel/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ void panic(const char *fmt, ...)
* Bypass the panic_cpu check and call __crash_kexec directly.
*/
if (!_crash_kexec_post_notifiers) {
printk_safe_flush_on_panic();
__crash_kexec(NULL);

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

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

/*
Expand Down
25 changes: 0 additions & 25 deletions kernel/printk/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@

#ifdef CONFIG_PRINTK

#define PRINTK_SAFE_CONTEXT_MASK 0x007ffffff
#define PRINTK_NMI_DIRECT_CONTEXT_MASK 0x008000000
#define PRINTK_NMI_CONTEXT_MASK 0xff0000000

#define PRINTK_NMI_CONTEXT_OFFSET 0x010000000

/* Flags for a single printk record. */
enum printk_info_flags {
LOG_NEWLINE = 2, /* text ended with a newline */
Expand All @@ -25,10 +19,7 @@ int vprintk_store(int facility, int level,

__printf(1, 0) int vprintk_default(const char *fmt, va_list args);
__printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
void __printk_safe_enter(void);
void __printk_safe_exit(void);

void printk_safe_init(void);
bool printk_percpu_data_ready(void);

#define printk_safe_enter_irqsave(flags) \
Expand All @@ -43,18 +34,6 @@ bool printk_percpu_data_ready(void);
local_irq_restore(flags); \
} while (0)

#define printk_safe_enter_irq() \
do { \
local_irq_disable(); \
__printk_safe_enter(); \
} while (0)

#define printk_safe_exit_irq() \
do { \
__printk_safe_exit(); \
local_irq_enable(); \
} while (0)

void defer_console_output(void);

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

#define printk_safe_enter_irq() local_irq_disable()
#define printk_safe_exit_irq() local_irq_enable()

static inline void printk_safe_init(void) { }
static inline bool printk_percpu_data_ready(void) { return false; }
#endif /* CONFIG_PRINTK */
Loading

0 comments on commit c985aaf

Please sign in to comment.