include/linux/kernel.h: Move logging bits to include/linux/logging.h
PATCH 1/1 include/linux/kernel.h: Move logging bits to include/linux/logging.h
Move the logging bits from kernel.h into logging.h so that there is a bit more logical separation of the generic from the logging specific parts.
Add pr_<level>_once macros to logging.h.
--- include/linux/kernel.h | 246 +----------------------------------- include/linux/logging.h | 322 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 324 insertions(+), 244 deletions(-) create mode 100644 include/linux/logging.h
include/linux/kernel.h +2 -244
@@ -17,13 +17,11 @@#include <linux/bitops.h> #include <linux/log2.h> #include <linux/typecheck.h> +#include <linux/logging.h> #include <linux/dynamic_debug.h> #include <asm/byteorder.h> #include <asm/bug.h> -extern const char linux_banner[]; -extern const char linux_proc_banner[]; -#define USHRT_MAX ((u16)(~0U))#define SHRT_MAX ((s16)(USHRT_MAX>>1))#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
@@ -42,7 +40,7 @@ extern const char linux_proc_banner[];#define ALIGN (x, a) __ALIGN_KERNEL((x), (a))#define __ALIGN_MASK (x, mask) __ALIGN_KERNEL_MASK((x), (mask))#define PTR_ALIGN (p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) -#define IS_ALIGNED (x, a) (((x) & ((typeof(x))(a) - 1)) == 0) +#define IS_ALIGNED (x, a) (((x) & ((typeof(x))(a) - 1)) == 0)#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
@@ -110,31 +108,6 @@ extern const char linux_proc_banner[];*/ #define lower_32_bits (n) ((u32)(n)) -#define KERN_EMERG "<0>"/* system is unusable */ -#define KERN_ALERT "<1>"/* action must be taken immediately */ -#define KERN_CRIT "<2>"/* critical conditions */ -#define KERN_ERR "<3>"/* error conditions */ -#define KERN_WARNING "<4>"/* warning conditions */ -#define KERN_NOTICE "<5>"/* normal but significant condition */ -#define KERN_INFO "<6>"/* informational */ -#define KERN_DEBUG "<7>"/* debug-level messages */ - -/* Use the default kernel loglevel */ -#define KERN_DEFAULT "<d>" -/* -* Annotation for a "continued" line of log printout (only done after a -* line that had no enclosing \n). Only to be used by core/arch code -* during early bootup (a continued line is not SMP-safe otherwise). -*/ -#define KERN_CONT "<c>" - -extern int console_printk[]; - -#define console_loglevel (console_printk[0]) -#define default_message_loglevel (console_printk[1]) -#define minimum_console_loglevel (console_printk[2]) -#define default_console_loglevel (console_printk[3]) -struct completion ;struct pt_regs ;struct user ;
@@ -187,11 +160,6 @@ static inline void might_fault(void) }#endif -struct va_format { -const char *fmt; -va_list *va; -}; -extern struct atomic_notifier_head panic_notifier_list;extern long (*panic_blink)(int state); NORET_TYPE void panic(const char * fmt, ...)
@@ -245,114 +213,8 @@ extern int func_ptr_is_kernel_text(void *ptr);struct pid ;extern struct pid *session_of_pgrp (struct pid *pgrp); -/* -* FW_BUG -* Add this to a message where you are sure the firmware is buggy or behaves -* really stupid or out of spec. Be aware that the responsible BIOS developer -* should be able to fix this issue or at least get a concrete idea of the -* problem by reading your message without the need of looking at the kernel -* code. -* -* Use it for definite and high priority BIOS bugs. -* -* FW_WARN -* Use it for not that clear (e.g. could the kernel messed up things already?) -* and medium priority BIOS bugs. -* -* FW_INFO -* Use this one if you want to tell the user or vendor about something -* suspicious, but generally harmless related to the firmware. -* -* Use it for information or very low priority BIOS bugs. -*/ -#define FW_BUG "[Firmware Bug]: " -#define FW_WARN "[Firmware Warn]: " -#define FW_INFO "[Firmware Info]: " - -/* -* HW_ERR -* Add this to a message for hardware errors, so that user can report -* it to hardware vendor instead of LKML or software vendor. -*/ -#define HW_ERR "[Hardware Error]: " - -#ifdef CONFIG_PRINTK -asmlinkage int vprintk(const char *fmt, va_list args) - __attribute__ ((format (printf,1 ,0 ))); -asmlinkage int printk(const char * fmt, ...) - __attribute__ ((format (printf,1 ,2 )))__cold ; - -/* -* Please don't use printk_ratelimit(), because it shares ratelimiting state -* with all other unrelated printk_ratelimit() callsites. Instead use -* printk_ratelimited() or plain old __ratelimit(). -*/ -extern int __printk_ratelimit (const char *func); -#define printk_ratelimit () __printk_ratelimit(__func__) -extern bool printk_timed_ratelimit (unsigned long *caller_jiffies, -unsigned int interval_msec); - -extern int printk_delay_msec; - -/* -* Print a one-time message (analogous to WARN_ONCE() et al): -*/ -#define printk_once(x...) ({ \ - static bool __print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - printk(x); \ - } \ -}) - -void log_buf_kexec_setup (void ); -#else -static inline int vprintk (const char *s,va_list args) - __attribute__ ((format (printf,1 ,0 ))); -static inline int vprintk (const char *s,va_list args) {return 0 ; } -static inline int printk (const char *s, ...) - __attribute__ ((format (printf,1 ,2 ))); -static inline int __cold printk (const char *s, ...) {return 0 ; } -static inline int printk_ratelimit (void ) {return 0 ; } -static inline bool printk_timed_ratelimit (unsigned long *caller_jiffies, \ -unsigned int interval_msec) \ - {return false; } - -/* No effect, but we still get type checking even in the !PRINTK case: */ -#define printk_once(x...) printk(x) - -static inline void log_buf_kexec_setup (void ) -{ -} -#endif - -/* -* Dummy printk for disabled debugging statements to use whilst maintaining -* gcc's format and side-effect checking. -*/ -static inline __attribute__ ((format (printf,1 ,2 ))) -int no_printk (const char *s, ...) {return 0 ; } - -extern int printk_needs_cpu (int cpu); -extern void printk_tick (void ); - -extern void asmlinkage __attribute__((format(printf, 1, 2))) - early_printk(const char *fmt, ...); -unsigned long int_sqrt (unsigned long ); -static inline void console_silent (void ) -{ - console_loglevel =0 ; -} - -static inline void console_verbose (void ) -{ -if (console_loglevel) - console_loglevel =15 ; -} -extern void bust_spinlocks (int yes);extern void wake_up_klogd (void );extern int oops_in_progress;/* If set, an oops, panic(), BUG() or die() is in progress */
@@ -389,22 +251,6 @@ extern enum system_states {#define TAINT_CRAP 10#define TAINT_FIRMWARE_WORKAROUND 11 -extern void dump_stack (void )__cold ; - -enum { -DUMP_PREFIX_NONE , -DUMP_PREFIX_ADDRESS , -DUMP_PREFIX_OFFSET -}; -extern void hex_dump_to_buffer (const void *buf,size_t len, -int rowsize,int groupsize, -char *linebuf,size_t linebuflen,bool ascii); -extern void print_hex_dump (const char *level,const char *prefix_str, -int prefix_type,int rowsize,int groupsize, -const void *buf,size_t len,bool ascii); -extern void print_hex_dump_bytes (const char *prefix_str,int prefix_type, -const void *buf,size_t len); -extern const char hex_asc[];#define hex_asc_lo (x) hex_asc[((x) & 0x0f)]#define hex_asc_hi (x) hex_asc[((x) & 0xf0) >> 4]
@@ -418,94 +264,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte)extern int hex_to_bin (char ch); -#ifndef pr_fmt -#define pr_fmt (fmt) fmt -#endif - -#define pr_emerg (fmt, ...) \ - printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert (fmt, ...) \ - printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit (fmt, ...) \ - printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err (fmt, ...) \ - printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning (fmt, ...) \ - printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn pr_warning -#define pr_notice (fmt, ...) \ - printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info (fmt, ...) \ - printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -#define pr_cont (fmt, ...) \ - printk(KERN_CONT fmt, ##__VA_ARGS__) - -/* pr_devel() should produce zero code unless DEBUG is defined */ -#ifdef DEBUG -#define pr_devel (fmt, ...) \ - printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_devel (fmt, ...) \ - ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) -#endif - -/* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) -#define pr_debug (fmt, ...) \ - printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#elif defined(CONFIG_DYNAMIC_DEBUG ) -/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ -#define pr_debug (fmt, ...) \ - dynamic_pr_debug(fmt, ##__VA_ARGS__) -#else -#define pr_debug (fmt, ...) \ - ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) -#endif - -/* -* ratelimited messages with local ratelimit_state, -* no local ratelimit_state used in the !PRINTK case -*/ -#ifdef CONFIG_PRINTK -#define printk_ratelimited (fmt, ...) ({ \ - static DEFINE_RATELIMIT_STATE(_rs, \ - DEFAULT_RATELIMIT_INTERVAL, \ - DEFAULT_RATELIMIT_BURST); \ - \ - if (__ratelimit(&_rs)) \ - printk(fmt, ##__VA_ARGS__); \ -}) -#else -/* No effect, but we still get type checking even in the !PRINTK case: */ -#define printk_ratelimited printk -#endif - -#define pr_emerg_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn_ratelimited pr_warning_ratelimited -#define pr_notice_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -/* no pr_cont_ratelimited, don't do that... */ -/* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) -#define pr_debug_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_debug_ratelimited (fmt, ...) \ - ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ - ##__VA_ARGS__); 0; }) -#endif -/* * General tracing related utility functions - trace_printk(), * tracing_on/tracing_off and tracing_start()/tracing_stop
include/linux/logging.h new file +322 -0
322 lines not on this page · raw message
Signature · 1 line
1.7.3.2.146.gca209
Quoted 4 lines · Joe Perches
Move the logging bits from
kernel.hintologging.hso that there is a bit more logical separation of the generic from the logging specific parts.
Quoted 8 lines
Add pr_<level>_once macros to
logging.h.Signed-off-by Joe Perches <[email protected]>---
include/linux/kernel.h | 246 +-----------------------------------include/linux/logging.h| 322 +++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 324 insertions(+), 244 deletions(-)create mode 100644
include/linux/logging.h
I detest patches like this.
The code movement makes it really hard to see what changed. So if you do code movement, please do _only_ code movement, and send a separate patch that actually changes things.
Linus
PATCH v2 1/1 include/linux/kernel.h: Move logging bits to include/linux/logging.h
Move the logging bits from kernel.h into logging.h so that there is a bit more logical separation of the generic from the logging specific parts.
---
diff from V1 - Don't add pr_<level>_once macros
include/linux/kernel.h | 244 +-------------------------------------- include/linux/logging.h | 295 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+), 243 deletions(-) create mode 100644 include/linux/logging.h
include/linux/kernel.h +1 -243
@@ -17,13 +17,11 @@#include <linux/bitops.h> #include <linux/log2.h> #include <linux/typecheck.h> +#include <linux/logging.h> #include <linux/dynamic_debug.h> #include <asm/byteorder.h> #include <asm/bug.h> -extern const char linux_banner[]; -extern const char linux_proc_banner[]; -#define USHRT_MAX ((u16)(~0U))#define SHRT_MAX ((s16)(USHRT_MAX>>1))#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
@@ -110,31 +108,6 @@ extern const char linux_proc_banner[];*/ #define lower_32_bits (n) ((u32)(n)) -#define KERN_EMERG "<0>"/* system is unusable */ -#define KERN_ALERT "<1>"/* action must be taken immediately */ -#define KERN_CRIT "<2>"/* critical conditions */ -#define KERN_ERR "<3>"/* error conditions */ -#define KERN_WARNING "<4>"/* warning conditions */ -#define KERN_NOTICE "<5>"/* normal but significant condition */ -#define KERN_INFO "<6>"/* informational */ -#define KERN_DEBUG "<7>"/* debug-level messages */ - -/* Use the default kernel loglevel */ -#define KERN_DEFAULT "<d>" -/* -* Annotation for a "continued" line of log printout (only done after a -* line that had no enclosing \n). Only to be used by core/arch code -* during early bootup (a continued line is not SMP-safe otherwise). -*/ -#define KERN_CONT "<c>" - -extern int console_printk[]; - -#define console_loglevel (console_printk[0]) -#define default_message_loglevel (console_printk[1]) -#define minimum_console_loglevel (console_printk[2]) -#define default_console_loglevel (console_printk[3]) -struct completion ;struct pt_regs ;struct user ;
@@ -187,11 +160,6 @@ static inline void might_fault(void) }#endif -struct va_format { -const char *fmt; -va_list *va; -}; -extern struct atomic_notifier_head panic_notifier_list;extern long (*panic_blink)(int state); NORET_TYPE void panic(const char * fmt, ...)
@@ -245,114 +213,8 @@ extern int func_ptr_is_kernel_text(void *ptr);struct pid ;extern struct pid *session_of_pgrp (struct pid *pgrp); -/* -* FW_BUG -* Add this to a message where you are sure the firmware is buggy or behaves -* really stupid or out of spec. Be aware that the responsible BIOS developer -* should be able to fix this issue or at least get a concrete idea of the -* problem by reading your message without the need of looking at the kernel -* code. -* -* Use it for definite and high priority BIOS bugs. -* -* FW_WARN -* Use it for not that clear (e.g. could the kernel messed up things already?) -* and medium priority BIOS bugs. -* -* FW_INFO -* Use this one if you want to tell the user or vendor about something -* suspicious, but generally harmless related to the firmware. -* -* Use it for information or very low priority BIOS bugs. -*/ -#define FW_BUG "[Firmware Bug]: " -#define FW_WARN "[Firmware Warn]: " -#define FW_INFO "[Firmware Info]: " - -/* -* HW_ERR -* Add this to a message for hardware errors, so that user can report -* it to hardware vendor instead of LKML or software vendor. -*/ -#define HW_ERR "[Hardware Error]: " - -#ifdef CONFIG_PRINTK -asmlinkage int vprintk(const char *fmt, va_list args) - __attribute__ ((format (printf,1 ,0 ))); -asmlinkage int printk(const char * fmt, ...) - __attribute__ ((format (printf,1 ,2 )))__cold ; - -/* -* Please don't use printk_ratelimit(), because it shares ratelimiting state -* with all other unrelated printk_ratelimit() callsites. Instead use -* printk_ratelimited() or plain old __ratelimit(). -*/ -extern int __printk_ratelimit (const char *func); -#define printk_ratelimit () __printk_ratelimit(__func__) -extern bool printk_timed_ratelimit (unsigned long *caller_jiffies, -unsigned int interval_msec); - -extern int printk_delay_msec; - -/* -* Print a one-time message (analogous to WARN_ONCE() et al): -*/ -#define printk_once(x...) ({ \ - static bool __print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - printk(x); \ - } \ -}) - -void log_buf_kexec_setup (void ); -#else -static inline int vprintk (const char *s,va_list args) - __attribute__ ((format (printf,1 ,0 ))); -static inline int vprintk (const char *s,va_list args) {return 0 ; } -static inline int printk (const char *s, ...) - __attribute__ ((format (printf,1 ,2 ))); -static inline int __cold printk (const char *s, ...) {return 0 ; } -static inline int printk_ratelimit (void ) {return 0 ; } -static inline bool printk_timed_ratelimit (unsigned long *caller_jiffies, \ -unsigned int interval_msec) \ - {return false; } - -/* No effect, but we still get type checking even in the !PRINTK case: */ -#define printk_once(x...) printk(x) - -static inline void log_buf_kexec_setup (void ) -{ -} -#endif - -/* -* Dummy printk for disabled debugging statements to use whilst maintaining -* gcc's format and side-effect checking. -*/ -static inline __attribute__ ((format (printf,1 ,2 ))) -int no_printk (const char *s, ...) {return 0 ; } - -extern int printk_needs_cpu (int cpu); -extern void printk_tick (void ); - -extern void asmlinkage __attribute__((format(printf, 1, 2))) - early_printk(const char *fmt, ...); -unsigned long int_sqrt (unsigned long ); -static inline void console_silent (void ) -{ - console_loglevel =0 ; -} - -static inline void console_verbose (void ) -{ -if (console_loglevel) - console_loglevel =15 ; -} -extern void bust_spinlocks (int yes);extern void wake_up_klogd (void );extern int oops_in_progress;/* If set, an oops, panic(), BUG() or die() is in progress */
@@ -389,22 +251,6 @@ extern enum system_states {#define TAINT_CRAP 10#define TAINT_FIRMWARE_WORKAROUND 11 -extern void dump_stack (void )__cold ; - -enum { -DUMP_PREFIX_NONE , -DUMP_PREFIX_ADDRESS , -DUMP_PREFIX_OFFSET -}; -extern void hex_dump_to_buffer (const void *buf,size_t len, -int rowsize,int groupsize, -char *linebuf,size_t linebuflen,bool ascii); -extern void print_hex_dump (const char *level,const char *prefix_str, -int prefix_type,int rowsize,int groupsize, -const void *buf,size_t len,bool ascii); -extern void print_hex_dump_bytes (const char *prefix_str,int prefix_type, -const void *buf,size_t len); -extern const char hex_asc[];#define hex_asc_lo (x) hex_asc[((x) & 0x0f)]#define hex_asc_hi (x) hex_asc[((x) & 0xf0) >> 4]
@@ -418,94 +264,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte)extern int hex_to_bin (char ch); -#ifndef pr_fmt -#define pr_fmt (fmt) fmt -#endif - -#define pr_emerg (fmt, ...) \ - printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert (fmt, ...) \ - printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit (fmt, ...) \ - printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err (fmt, ...) \ - printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning (fmt, ...) \ - printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn pr_warning -#define pr_notice (fmt, ...) \ - printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info (fmt, ...) \ - printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -#define pr_cont (fmt, ...) \ - printk(KERN_CONT fmt, ##__VA_ARGS__) - -/* pr_devel() should produce zero code unless DEBUG is defined */ -#ifdef DEBUG -#define pr_devel (fmt, ...) \ - printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_devel (fmt, ...) \ - ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) -#endif - -/* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) -#define pr_debug (fmt, ...) \ - printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#elif defined(CONFIG_DYNAMIC_DEBUG ) -/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ -#define pr_debug (fmt, ...) \ - dynamic_pr_debug(fmt, ##__VA_ARGS__) -#else -#define pr_debug (fmt, ...) \ - ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) -#endif - -/* -* ratelimited messages with local ratelimit_state, -* no local ratelimit_state used in the !PRINTK case -*/ -#ifdef CONFIG_PRINTK -#define printk_ratelimited (fmt, ...) ({ \ - static DEFINE_RATELIMIT_STATE(_rs, \ - DEFAULT_RATELIMIT_INTERVAL, \ - DEFAULT_RATELIMIT_BURST); \ - \ - if (__ratelimit(&_rs)) \ - printk(fmt, ##__VA_ARGS__); \ -}) -#else -/* No effect, but we still get type checking even in the !PRINTK case: */ -#define printk_ratelimited printk -#endif - -#define pr_emerg_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn_ratelimited pr_warning_ratelimited -#define pr_notice_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -/* no pr_cont_ratelimited, don't do that... */ -/* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) -#define pr_debug_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_debug_ratelimited (fmt, ...) \ - ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ - ##__VA_ARGS__); 0; }) -#endif -/* * General tracing related utility functions - trace_printk(), * tracing_on/tracing_off and tracing_start()/tracing_stop
include/linux/logging.h new file +295 -0
295 lines not on this page · raw message
Signature · 1 line
1.7.3.1.g432b3.dirty
Quoted 7 lines · Joe Perches
diff from V1 - Don't add pr_<level>_once macros
include/linux/kernel.h | 244 +--------------------------------------
include/linux/logging.h| 295 +++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 296 insertions(+), 243 deletions(-)create mode 100644
include/linux/logging.h
So where do the extra 53 lines come from now?
This still is clearly not just code movement, and it's impossible for me to see what actually changed. Something must have.
Linus
Quoted 7 lines · Linus Torvalds
Quoted 5 lines · Joe Perches
diff from V1 - Don't add pr_<level>_once macros
include/linux/kernel.h | 244 +-------------------------------------- include/linux/logging.h | 295 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+), 243 deletions(-) create mode 100644 include/linux/logging.hSo where do the extra 53 lines come from now?
Differences in logging.h to original kernel.h were done for cleanliness and checkpatch.
o comment added for purpose of struct va_format
o function no_print() broken into multiple lines
o #ifdef CONFIG_PRINTK vprintk/printk block and #else block moved together
o printk_ratelimit and related now have another CONFIG_PRINTK and #else block
o pr_debug and pr_debug_ratelimit statement expressions are broken into multiple lines
Quoted 2 lines
This still is clearly not just code movement, and it's impossible for me to see what actually changed. Something must have.
If you want a nearly identical line count for logging.h, followed by a cleanup only pass of logging.h, I'll do that.
Is that what you want?
I didn't recompile and verify this second patch as all I did was remove the unused for now pr_<level>_once macros I added.
It takes my slowish setup quite a while to do full compiles for allyesconfig/allmodconfig/ allnoconfig/defconfig/CONFIG_EMBEDDED/CONFIG_PRINTK=n variants though so it'd be another day or so before it'd be verified.
Quoted 3 lines · Joe Perches
Differences in
logging.hto originalkernel.h
were done for cleanliness and checkpatch.
Yet another reason why I detest mindless use of checkpatch. And as a maintainer, I balance the value of code movement patches in particular against how it breaks other people's patches, and how unless I do *very* careful review, people can sneak in changes that could either
(a) break code accidentally, or even (b) introduce security holes deliberately. (i.e., if I was in charge of the cyber warfare division of some large nation state, a really obvious way of trying to insert vulnerabilities into code is to send "cleanup" patches that move code around, and introduce some subtle buffer overrun or other security change.)
As a result, I spend extra time reviewing patches that move code around, and I **really** dislike patches that try to do any kind of cleanup (checkpatch.pl or otherwise) at the same time as they move code around.
- Ted
Quoted 4 lines · Ted Ts'o
Quoted 2 lines · Joe Perches
Differences in
logging.hto originalkernel.h
were done for cleanliness and checkpatch.Yet another reason why I detest mindless use of checkpatch.
If it makes you happier, I didn't use it here nor do I generally use checkpatch, (just ask Andrew Morton), I just wrote that more as a shorthand for kernel style conformance.
Quoted 3 lines
I **really** dislike patches that try to do any kind of cleanup (checkpatch.pl or otherwise) at the same time as they move code around.
So fine, I'll do a minimal code movement only patch followed by a style cleansing patch.
Anyone else have an opinion on using logging.h vs printk.h as an include name?
PATCH v3 1/1 include/linux/kernel.h: Move logging bits to include/linux/printk.h
In reply to Ted Ts'oMove the logging bits from kernel.h into printk.h so that there is a bit more logical separation of the generic from the printk logging specific parts.
---
v3 differences:
Rename logging.h to printk.h
Direct movement of lines from kernel.h to printk.h One trailing space deleted from a comment to keep git am quiet
Compiled x86 defconfig, allnoconfig, allmodconfig and CONFIG_PRINTK=n only
include/linux/kernel.h | 244 +----------------------------------------------- include/linux/printk.h | 247 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+), 243 deletions(-)
include/linux/kernel.h +1 -243
@@ -17,13 +17,11 @@#include <linux/bitops.h> #include <linux/log2.h> #include <linux/typecheck.h> +#include <linux/printk.h> #include <linux/dynamic_debug.h> #include <asm/byteorder.h> #include <asm/bug.h> -extern const char linux_banner[]; -extern const char linux_proc_banner[]; -#define USHRT_MAX ((u16)(~0U))#define SHRT_MAX ((s16)(USHRT_MAX>>1))#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
@@ -110,31 +108,6 @@ extern const char linux_proc_banner[];*/ #define lower_32_bits (n) ((u32)(n)) -#define KERN_EMERG "<0>"/* system is unusable */ -#define KERN_ALERT "<1>"/* action must be taken immediately */ -#define KERN_CRIT "<2>"/* critical conditions */ -#define KERN_ERR "<3>"/* error conditions */ -#define KERN_WARNING "<4>"/* warning conditions */ -#define KERN_NOTICE "<5>"/* normal but significant condition */ -#define KERN_INFO "<6>"/* informational */ -#define KERN_DEBUG "<7>"/* debug-level messages */ - -/* Use the default kernel loglevel */ -#define KERN_DEFAULT "<d>" -/* -* Annotation for a "continued" line of log printout (only done after a -* line that had no enclosing \n). Only to be used by core/arch code -* during early bootup (a continued line is not SMP-safe otherwise). -*/ -#define KERN_CONT "<c>" - -extern int console_printk[]; - -#define console_loglevel (console_printk[0]) -#define default_message_loglevel (console_printk[1]) -#define minimum_console_loglevel (console_printk[2]) -#define default_console_loglevel (console_printk[3]) -struct completion ;struct pt_regs ;struct user ;
@@ -187,11 +160,6 @@ static inline void might_fault(void) }#endif -struct va_format { -const char *fmt; -va_list *va; -}; -extern struct atomic_notifier_head panic_notifier_list;extern long (*panic_blink)(int state); NORET_TYPE void panic(const char * fmt, ...)
@@ -245,114 +213,8 @@ extern int func_ptr_is_kernel_text(void *ptr);struct pid ;extern struct pid *session_of_pgrp (struct pid *pgrp); -/* -* FW_BUG -* Add this to a message where you are sure the firmware is buggy or behaves -* really stupid or out of spec. Be aware that the responsible BIOS developer -* should be able to fix this issue or at least get a concrete idea of the -* problem by reading your message without the need of looking at the kernel -* code. -* -* Use it for definite and high priority BIOS bugs. -* -* FW_WARN -* Use it for not that clear (e.g. could the kernel messed up things already?) -* and medium priority BIOS bugs. -* -* FW_INFO -* Use this one if you want to tell the user or vendor about something -* suspicious, but generally harmless related to the firmware. -* -* Use it for information or very low priority BIOS bugs. -*/ -#define FW_BUG "[Firmware Bug]: " -#define FW_WARN "[Firmware Warn]: " -#define FW_INFO "[Firmware Info]: " - -/* -* HW_ERR -* Add this to a message for hardware errors, so that user can report -* it to hardware vendor instead of LKML or software vendor. -*/ -#define HW_ERR "[Hardware Error]: " - -#ifdef CONFIG_PRINTK -asmlinkage int vprintk(const char *fmt, va_list args) - __attribute__ ((format (printf,1 ,0 ))); -asmlinkage int printk(const char * fmt, ...) - __attribute__ ((format (printf,1 ,2 )))__cold ; - -/* -* Please don't use printk_ratelimit(), because it shares ratelimiting state -* with all other unrelated printk_ratelimit() callsites. Instead use -* printk_ratelimited() or plain old __ratelimit(). -*/ -extern int __printk_ratelimit (const char *func); -#define printk_ratelimit () __printk_ratelimit(__func__) -extern bool printk_timed_ratelimit (unsigned long *caller_jiffies, -unsigned int interval_msec); - -extern int printk_delay_msec; - -/* -* Print a one-time message (analogous to WARN_ONCE() et al): -*/ -#define printk_once(x...) ({ \ - static bool __print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - printk(x); \ - } \ -}) - -void log_buf_kexec_setup (void ); -#else -static inline int vprintk (const char *s,va_list args) - __attribute__ ((format (printf,1 ,0 ))); -static inline int vprintk (const char *s,va_list args) {return 0 ; } -static inline int printk (const char *s, ...) - __attribute__ ((format (printf,1 ,2 ))); -static inline int __cold printk (const char *s, ...) {return 0 ; } -static inline int printk_ratelimit (void ) {return 0 ; } -static inline bool printk_timed_ratelimit (unsigned long *caller_jiffies, \ -unsigned int interval_msec) \ - {return false; } - -/* No effect, but we still get type checking even in the !PRINTK case: */ -#define printk_once(x...) printk(x) - -static inline void log_buf_kexec_setup (void ) -{ -} -#endif - -/* -* Dummy printk for disabled debugging statements to use whilst maintaining -* gcc's format and side-effect checking. -*/ -static inline __attribute__ ((format (printf,1 ,2 ))) -int no_printk (const char *s, ...) {return 0 ; } - -extern int printk_needs_cpu (int cpu); -extern void printk_tick (void ); - -extern void asmlinkage __attribute__((format(printf, 1, 2))) - early_printk(const char *fmt, ...); -unsigned long int_sqrt (unsigned long ); -static inline void console_silent (void ) -{ - console_loglevel =0 ; -} - -static inline void console_verbose (void ) -{ -if (console_loglevel) - console_loglevel =15 ; -} -extern void bust_spinlocks (int yes);extern void wake_up_klogd (void );extern int oops_in_progress;/* If set, an oops, panic(), BUG() or die() is in progress */
@@ -389,22 +251,6 @@ extern enum system_states {#define TAINT_CRAP 10#define TAINT_FIRMWARE_WORKAROUND 11 -extern void dump_stack (void )__cold ; - -enum { -DUMP_PREFIX_NONE , -DUMP_PREFIX_ADDRESS , -DUMP_PREFIX_OFFSET -}; -extern void hex_dump_to_buffer (const void *buf,size_t len, -int rowsize,int groupsize, -char *linebuf,size_t linebuflen,bool ascii); -extern void print_hex_dump (const char *level,const char *prefix_str, -int prefix_type,int rowsize,int groupsize, -const void *buf,size_t len,bool ascii); -extern void print_hex_dump_bytes (const char *prefix_str,int prefix_type, -const void *buf,size_t len); -extern const char hex_asc[];#define hex_asc_lo (x) hex_asc[((x) & 0x0f)]#define hex_asc_hi (x) hex_asc[((x) & 0xf0) >> 4]
@@ -418,94 +264,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte)extern int hex_to_bin (char ch); -#ifndef pr_fmt -#define pr_fmt (fmt) fmt -#endif - -#define pr_emerg (fmt, ...) \ - printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert (fmt, ...) \ - printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit (fmt, ...) \ - printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err (fmt, ...) \ - printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning (fmt, ...) \ - printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn pr_warning -#define pr_notice (fmt, ...) \ - printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info (fmt, ...) \ - printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -#define pr_cont (fmt, ...) \ - printk(KERN_CONT fmt, ##__VA_ARGS__) - -/* pr_devel() should produce zero code unless DEBUG is defined */ -#ifdef DEBUG -#define pr_devel (fmt, ...) \ - printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_devel (fmt, ...) \ - ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) -#endif - -/* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) -#define pr_debug (fmt, ...) \ - printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#elif defined(CONFIG_DYNAMIC_DEBUG ) -/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ -#define pr_debug (fmt, ...) \ - dynamic_pr_debug(fmt, ##__VA_ARGS__) -#else -#define pr_debug (fmt, ...) \ - ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) -#endif - -/* -* ratelimited messages with local ratelimit_state, -* no local ratelimit_state used in the !PRINTK case -*/ -#ifdef CONFIG_PRINTK -#define printk_ratelimited (fmt, ...) ({ \ - static DEFINE_RATELIMIT_STATE(_rs, \ - DEFAULT_RATELIMIT_INTERVAL, \ - DEFAULT_RATELIMIT_BURST); \ - \ - if (__ratelimit(&_rs)) \ - printk(fmt, ##__VA_ARGS__); \ -}) -#else -/* No effect, but we still get type checking even in the !PRINTK case: */ -#define printk_ratelimited printk -#endif - -#define pr_emerg_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn_ratelimited pr_warning_ratelimited -#define pr_notice_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -/* no pr_cont_ratelimited, don't do that... */ -/* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) -#define pr_debug_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_debug_ratelimited (fmt, ...) \ - ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ - ##__VA_ARGS__); 0; }) -#endif -/* * General tracing related utility functions - trace_printk(), * tracing_on/tracing_off and tracing_start()/tracing_stop
include/linux/printk.h new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
1.7.3.2.146.gca209
Quoted 9 lines · Linus Torvalds
Quoted 7 lines · Joe Perches
diff from V1 - Don't add pr_<level>_once macros
include/linux/kernel.h | 244 +--------------------------------------
include/linux/logging.h| 295 +++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 296 insertions(+), 243 deletions(-)create mode 100644
include/linux/logging.h
Quoted 4 lines
So where do the extra 53 lines come from now?
This still is clearly not just code movement, and it's impossible for me to see what actually changed. Something must have.
Why linux_banner is moved?
Why linux_proc_banner is moved?
Why header is not named printk.h?
Why random stuff like log_buf_kexec_setup() and hexdump is moved?
Quoted 10 lines · Alexey Dobriyan
Quoted 9 lines · Linus Torvalds
Quoted 7 lines · Joe Perches
diff from V1 - Don't add pr_<level>_once macros
include/linux/kernel.h | 244 +-------------------------------------- include/linux/logging.h | 295 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+), 243 deletions(-) create mode 100644 include/linux/logging.h
Quoted 7 lines
Quoted 4 lines
So where do the extra 53 lines come from now?
This still is clearly not just code movement, and it's impossible for me to see what actually changed. Something must have.
Why
linux_banneris moved?
Whylinux_proc_banneris moved?
It's only used by a printk.
Quoted 1 line
Why header is not named
printk.h?
No particular reason nor any particular objection.
Quoted 1 line
Why random stuff like
log_buf_kexec_setup()and hexdump is moved?
hexdump functions are logging message related
as is log_buf_kexec_setup.
hexdump should/will eventually have an
#ifdef CONFIG_PRINTK
external function prototypes
#else
static inline void
hex_dump_to_buffer(const void *buf, size_t len,
int rowsize, int groupsize,
char *linebuf, size_t linebuflen, bool ascii) {}
static inline void
print_hex_dump(const char *level, const char *prefix_str,
int prefix_type, int rowsize, int groupsize,
const void *buf, size_t len, bool ascii) {}
static inline void
print_hex_dump_bytes(const char *prefix_str, int prefix_type,
const void *buf, size_t len) {}#endif
so the static strings of the call sites can be eliminated when !CONFIG_PRINTK.
Quoted 3 lines · Joe Perches
Quoted 1 line · Alexey Dobriyan
Why
linux_proc_banneris moved?It's only used by a printk.
Checking again, linux_proc_banner is only
used in one seq_printf and is not used in
a printk.
$ git grep -w linux_proc_banner * fs/proc/version.c: seq_printf(m, linux_proc_banner, include/linux/logging.h:extern const char linux_proc_banner[]; init/version.c:const char linux_proc_banner[] =
I supposed it could be removed from kernel.h
or logging.h/printk.h and just declared extern
in fs/proc/version.c or moved to init.h or
maybe even version.h.
init.h already has other extern variables that
are declared in init/main.c so that might
make some sense.
PATCH v4 1/1 include/linux/kernel.h: Move logging bits to include/linux/printk.h
In reply to Linus TorvaldsMove the logging bits from kernel.h into printk.h so that there is a bit more logical separation of the generic kernel.h contents from the printk/logging specific parts.
---
V4: Update for dmesg_restrict
V3: Rename logging.h to printk.h
Direct movement of lines from kernel.h to printk.h One trailing space deleted from a comment to keep git am quiet
Compiled x86 defconfig, allnoconfig, allmodconfig and CONFIG_PRINTK=n only
include/linux/kernel.h | 245 +----------------------------------------------- include/linux/printk.h | 248 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 244 deletions(-) create mode 100644 include/linux/printk.h
include/linux/kernel.h +1 -244
@@ -17,13 +17,11 @@#include <linux/bitops.h> #include <linux/log2.h> #include <linux/typecheck.h> +#include <linux/printk.h> #include <linux/dynamic_debug.h> #include <asm/byteorder.h> #include <asm/bug.h> -extern const char linux_banner[]; -extern const char linux_proc_banner[]; -#define USHRT_MAX ((u16)(~0U))#define SHRT_MAX ((s16)(USHRT_MAX>>1))#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
@@ -110,31 +108,6 @@ extern const char linux_proc_banner[];*/ #define lower_32_bits (n) ((u32)(n)) -#define KERN_EMERG "<0>"/* system is unusable */ -#define KERN_ALERT "<1>"/* action must be taken immediately */ -#define KERN_CRIT "<2>"/* critical conditions */ -#define KERN_ERR "<3>"/* error conditions */ -#define KERN_WARNING "<4>"/* warning conditions */ -#define KERN_NOTICE "<5>"/* normal but significant condition */ -#define KERN_INFO "<6>"/* informational */ -#define KERN_DEBUG "<7>"/* debug-level messages */ - -/* Use the default kernel loglevel */ -#define KERN_DEFAULT "<d>" -/* -* Annotation for a "continued" line of log printout (only done after a -* line that had no enclosing \n). Only to be used by core/arch code -* during early bootup (a continued line is not SMP-safe otherwise). -*/ -#define KERN_CONT "<c>" - -extern int console_printk[]; - -#define console_loglevel (console_printk[0]) -#define default_message_loglevel (console_printk[1]) -#define minimum_console_loglevel (console_printk[2]) -#define default_console_loglevel (console_printk[3]) -struct completion ;struct pt_regs ;struct user ;
@@ -187,11 +160,6 @@ static inline void might_fault(void) }#endif -struct va_format { -const char *fmt; -va_list *va; -}; -extern struct atomic_notifier_head panic_notifier_list;extern long (*panic_blink)(int state); NORET_TYPE void panic(const char * fmt, ...)
@@ -245,115 +213,8 @@ extern int func_ptr_is_kernel_text(void *ptr);struct pid ;extern struct pid *session_of_pgrp (struct pid *pgrp); -/* -* FW_BUG -* Add this to a message where you are sure the firmware is buggy or behaves -* really stupid or out of spec. Be aware that the responsible BIOS developer -* should be able to fix this issue or at least get a concrete idea of the -* problem by reading your message without the need of looking at the kernel -* code. -* -* Use it for definite and high priority BIOS bugs. -* -* FW_WARN -* Use it for not that clear (e.g. could the kernel messed up things already?) -* and medium priority BIOS bugs. -* -* FW_INFO -* Use this one if you want to tell the user or vendor about something -* suspicious, but generally harmless related to the firmware. -* -* Use it for information or very low priority BIOS bugs. -*/ -#define FW_BUG "[Firmware Bug]: " -#define FW_WARN "[Firmware Warn]: " -#define FW_INFO "[Firmware Info]: " - -/* -* HW_ERR -* Add this to a message for hardware errors, so that user can report -* it to hardware vendor instead of LKML or software vendor. -*/ -#define HW_ERR "[Hardware Error]: " - -#ifdef CONFIG_PRINTK -asmlinkage int vprintk(const char *fmt, va_list args) - __attribute__ ((format (printf,1 ,0 ))); -asmlinkage int printk(const char * fmt, ...) - __attribute__ ((format (printf,1 ,2 )))__cold ; - -/* -* Please don't use printk_ratelimit(), because it shares ratelimiting state -* with all other unrelated printk_ratelimit() callsites. Instead use -* printk_ratelimited() or plain old __ratelimit(). -*/ -extern int __printk_ratelimit (const char *func); -#define printk_ratelimit () __printk_ratelimit(__func__) -extern bool printk_timed_ratelimit (unsigned long *caller_jiffies, -unsigned int interval_msec); - -extern int printk_delay_msec; -extern int dmesg_restrict; - -/* -* Print a one-time message (analogous to WARN_ONCE() et al): -*/ -#define printk_once(x...) ({ \ - static bool __print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - printk(x); \ - } \ -}) - -void log_buf_kexec_setup (void ); -#else -static inline int vprintk (const char *s,va_list args) - __attribute__ ((format (printf,1 ,0 ))); -static inline int vprintk (const char *s,va_list args) {return 0 ; } -static inline int printk (const char *s, ...) - __attribute__ ((format (printf,1 ,2 ))); -static inline int __cold printk (const char *s, ...) {return 0 ; } -static inline int printk_ratelimit (void ) {return 0 ; } -static inline bool printk_timed_ratelimit (unsigned long *caller_jiffies, \ -unsigned int interval_msec) \ - {return false; } - -/* No effect, but we still get type checking even in the !PRINTK case: */ -#define printk_once(x...) printk(x) - -static inline void log_buf_kexec_setup (void ) -{ -} -#endif - -/* -* Dummy printk for disabled debugging statements to use whilst maintaining -* gcc's format and side-effect checking. -*/ -static inline __attribute__ ((format (printf,1 ,2 ))) -int no_printk (const char *s, ...) {return 0 ; } - -extern int printk_needs_cpu (int cpu); -extern void printk_tick (void ); - -extern void asmlinkage __attribute__((format(printf, 1, 2))) - early_printk(const char *fmt, ...); -unsigned long int_sqrt (unsigned long ); -static inline void console_silent (void ) -{ - console_loglevel =0 ; -} - -static inline void console_verbose (void ) -{ -if (console_loglevel) - console_loglevel =15 ; -} -extern void bust_spinlocks (int yes);extern void wake_up_klogd (void );extern int oops_in_progress;/* If set, an oops, panic(), BUG() or die() is in progress */
@@ -390,22 +251,6 @@ extern enum system_states {#define TAINT_CRAP 10#define TAINT_FIRMWARE_WORKAROUND 11 -extern void dump_stack (void )__cold ; - -enum { -DUMP_PREFIX_NONE , -DUMP_PREFIX_ADDRESS , -DUMP_PREFIX_OFFSET -}; -extern void hex_dump_to_buffer (const void *buf,size_t len, -int rowsize,int groupsize, -char *linebuf,size_t linebuflen,bool ascii); -extern void print_hex_dump (const char *level,const char *prefix_str, -int prefix_type,int rowsize,int groupsize, -const void *buf,size_t len,bool ascii); -extern void print_hex_dump_bytes (const char *prefix_str,int prefix_type, -const void *buf,size_t len); -extern const char hex_asc[];#define hex_asc_lo (x) hex_asc[((x) & 0x0f)]#define hex_asc_hi (x) hex_asc[((x) & 0xf0) >> 4]
@@ -419,94 +264,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte)extern int hex_to_bin (char ch); -#ifndef pr_fmt -#define pr_fmt (fmt) fmt -#endif - -#define pr_emerg (fmt, ...) \ - printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert (fmt, ...) \ - printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit (fmt, ...) \ - printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err (fmt, ...) \ - printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning (fmt, ...) \ - printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn pr_warning -#define pr_notice (fmt, ...) \ - printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info (fmt, ...) \ - printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -#define pr_cont (fmt, ...) \ - printk(KERN_CONT fmt, ##__VA_ARGS__) - -/* pr_devel() should produce zero code unless DEBUG is defined */ -#ifdef DEBUG -#define pr_devel (fmt, ...) \ - printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_devel (fmt, ...) \ - ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) -#endif - -/* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) -#define pr_debug (fmt, ...) \ - printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#elif defined(CONFIG_DYNAMIC_DEBUG ) -/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ -#define pr_debug (fmt, ...) \ - dynamic_pr_debug(fmt, ##__VA_ARGS__) -#else -#define pr_debug (fmt, ...) \ - ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) -#endif - -/* -* ratelimited messages with local ratelimit_state, -* no local ratelimit_state used in the !PRINTK case -*/ -#ifdef CONFIG_PRINTK -#define printk_ratelimited (fmt, ...) ({ \ - static DEFINE_RATELIMIT_STATE(_rs, \ - DEFAULT_RATELIMIT_INTERVAL, \ - DEFAULT_RATELIMIT_BURST); \ - \ - if (__ratelimit(&_rs)) \ - printk(fmt, ##__VA_ARGS__); \ -}) -#else -/* No effect, but we still get type checking even in the !PRINTK case: */ -#define printk_ratelimited printk -#endif - -#define pr_emerg_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn_ratelimited pr_warning_ratelimited -#define pr_notice_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -/* no pr_cont_ratelimited, don't do that... */ -/* If you are writing a driver, please use dev_dbg instead */ -#if defined(DEBUG ) -#define pr_debug_ratelimited (fmt, ...) \ - printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_debug_ratelimited (fmt, ...) \ - ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ - ##__VA_ARGS__); 0; }) -#endif -/* * General tracing related utility functions - trace_printk(), * tracing_on/tracing_off and tracing_start()/tracing_stop
include/linux/printk.h new file +248 -0
248 lines not on this page · raw message