From: Petr Mladek Date: Mon, 30 Aug 2021 14:36:10 +0000 (+0200) Subject: Merge branch 'rework/printk_safe-removal' into for-linus X-Git-Tag: accepted/tizen/unified/20230118.172025~6506^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c985aafb60e972c0a6b8d0bd65e03af5890b748a;p=platform%2Fkernel%2Flinux-rpi.git Merge branch 'rework/printk_safe-removal' into for-linus --- c985aafb60e972c0a6b8d0bd65e03af5890b748a diff --cc include/linux/printk.h index da7a1de,a1379df..259af4f --- a/include/linux/printk.h +++ b/include/linux/printk.h @@@ -170,8 -166,18 +158,18 @@@ int _printk(const char *fmt, ...) /* * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ ! */ -__printf(1, 2) __cold int printk_deferred(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 diff --cc kernel/printk/internal.h index 1596e28,b6d310c..9f3ed2f --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@@ -6,18 -6,6 +6,12 @@@ #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 */ + LOG_CONT = 8, /* text is a fragment of a continuation line */ +}; + __printf(4, 0) int vprintk_store(int facility, int level, const struct dev_printk_info *dev_info, @@@ -43,22 -28,8 +34,10 @@@ 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, + enum printk_info_flags *flags); #else /* diff --cc kernel/printk/printk.c index 776e356,65fffa6..825277e --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@@ -350,8 -350,13 +350,8 @@@ static int console_msg_format = MSG_FOR * non-prinatable characters are escaped in the "\xff" notation. */ -enum log_flags { - LOG_NEWLINE = 2, /* text ended with a newline */ - LOG_CONT = 8, /* text is a fragment of a continuation line */ -}; - /* syslog_lock protects syslog_* variables and write access to clear_seq. */ - static DEFINE_RAW_SPINLOCK(syslog_lock); + static DEFINE_MUTEX(syslog_lock); #ifdef CONFIG_PRINTK DECLARE_WAIT_QUEUE_HEAD(log_wait); @@@ -2035,10 -2104,12 +2101,12 @@@ int vprintk_store(int facility, int lev { const u32 caller_id = printk_caller_id(); struct prb_reserved_entry e; - enum log_flags lflags = 0; + enum printk_info_flags flags = 0; struct printk_record r; + unsigned long irqflags; u16 trunc_msg_len = 0; char prefix_buf[8]; + u8 *recursion_ptr; u16 reserve_size; va_list args2; u16 text_len; @@@ -2655,9 -2740,7 +2731,7 @@@ skip * there's a new owner and the console_unlock() from them will do the * flush, no worries. */ - retry = prb_read_valid(prb, console_seq, NULL); + retry = prb_read_valid(prb, next_seq, NULL); - printk_safe_exit_irqrestore(flags); - if (retry && console_trylock()) goto again; }