mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 05:24:12 +08:00
28e1745b9f
The printk code is already hard enough to understand. Remove an unnecessary indirection by renaming vprintk_func to vprintk (adding the asmlinkage annotation), and removing the vprintk definition from printk.c. That way, printk is implemented in terms of vprintk as one would expect, and there's no "vprintk_func, what's that? Some function pointer that gets set where?" The declaration of vprintk in linux/printk.h already has the __printf(1,0) attribute, there's no point repeating that with the definition - it's for diagnostics in callers. linux/printk.h already contains a static inline {return 0;} definition of vprintk when !CONFIG_PRINTK. Since the corresponding stub definition of vprintk_func was not marked "static inline", any translation unit including internal.h would get a definition of vprintk_func - it just so happens that for !CONFIG_PRINTK, there is precisely one such TU, namely printk.c. Had there been more, it would be a link error; now it's just a silly waste of a few bytes of .text, which one must assume are rather precious to anyone disabling PRINTK. $ objdump -dr kernel/printk/printk.o 00000330 <vprintk_func>: 330: 31 c0 xor %eax,%eax 332: c3 ret 333: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 33a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20210323144201.486050-1-linux@rasmusvillemoes.dk
70 lines
1.8 KiB
C
70 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* internal.h - printk internal definitions
|
|
*/
|
|
#include <linux/percpu.h>
|
|
|
|
#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
|
|
|
|
__printf(4, 0)
|
|
int vprintk_store(int facility, int level,
|
|
const struct dev_printk_info *dev_info,
|
|
const char *fmt, va_list args);
|
|
|
|
__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) \
|
|
do { \
|
|
local_irq_save(flags); \
|
|
__printk_safe_enter(); \
|
|
} while (0)
|
|
|
|
#define printk_safe_exit_irqrestore(flags) \
|
|
do { \
|
|
__printk_safe_exit(); \
|
|
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);
|
|
|
|
#else
|
|
|
|
/*
|
|
* In !PRINTK builds we still export console_sem
|
|
* semaphore and some of console functions (console_unlock()/etc.), so
|
|
* printk-safe must preserve the existing local IRQ guarantees.
|
|
*/
|
|
#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 */
|