Cleanup console loglevels
Borislav Petkov
maintainerHi,
so I was staring at
12544697f12e ("x86_64: be less annoying on boot, v2")
and how naked numbers mean sh*t and how I have to grep sources to find out what this 10 thing means. So how about the following cleanup? We can do it this way, we can do accessors and stuff, whatever. But the naked numbers are plain misleading.
So how about it? I'm asking whether it makes sense first before I go and replace all tests of console_loglevel with naked numbers around the tree.
Thanks.
---
arch/x86/kernel/head64.c +1 -1
@@ -172,7 +172,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)*/ load_ucode_bsp (); -if (console_loglevel ==10 ) +if (console_loglevel >=CONSOLE_LOGLEVEL_QUIET )early_printk ("Kernel alive\n" );clear_page (init_level4_pgt);
include/linux/printk.h +13 -2
@@ -30,6 +30,17 @@ static inline const char *printk_skip_level(const char *buffer)return buffer; } +/* printk's without a loglevel use this.. */ +#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL + +/* We show everything that is MORE important than this.. */ +#define CONSOLE_LOGLEVEL_SILENT 0/* Mum's the word */ +#define CONSOLE_LOGLEVEL_MIN 1/* Minimum loglevel we let people use */ +#define CONSOLE_LOGLEVEL_QUIET 4/* Shhh ..., when booted with "quiet" */ +#define CONSOLE_LOGLEVEL_DEFAULT 7/* anything MORE serious than KERN_DEBUG */ +#define CONSOLE_LOGLEVEL_DEBUG 10/* issue debug messages */ +#define CONSOLE_LOGLEVEL_MOTORMOUTH 15/* You can't shut this one up */ +extern int console_printk[];#define console_loglevel (console_printk[0])
@@ -39,13 +50,13 @@ extern int console_printk[];static inline void console_silent (void ) { - console_loglevel =0 ; + console_loglevel =CONSOLE_LOGLEVEL_SILENT ; }static inline void console_verbose (void ) {if (console_loglevel) - console_loglevel =15 ; + console_loglevel =CONSOLE_LOGLEVEL_MOTORMOUTH ; }struct va_format {
init/main.c +2 -2
@@ -203,13 +203,13 @@ EXPORT_SYMBOL(loops_per_jiffy);static int __init debug_kernel (char *str) { - console_loglevel =10 ; + console_loglevel =CONSOLE_LOGLEVEL_DEBUG ;return 0 ; }static int __init quiet_kernel (char *str) { - console_loglevel =4 ; + console_loglevel =CONSOLE_LOGLEVEL_QUIET ;return 0 ; }
kernel/printk/printk.c +3 -10
@@ -54,18 +54,11 @@#include "console_cmdline.h" #include "braille.h" -/* printk's without a loglevel use this.. */ -#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL - -/* We show everything that is MORE important than this.. */ -#define MINIMUM_CONSOLE_LOGLEVEL 1/* Minimum loglevel we let people use */ -#define DEFAULT_CONSOLE_LOGLEVEL 7/* anything MORE serious than KERN_DEBUG */ -int console_printk[4 ] = { -DEFAULT_CONSOLE_LOGLEVEL ,/* console_loglevel */ +CONSOLE_LOGLEVEL_DEFAULT ,/* console_loglevel */ DEFAULT_MESSAGE_LOGLEVEL ,/* default_message_loglevel */ -MINIMUM_CONSOLE_LOGLEVEL ,/* minimum_console_loglevel */ -DEFAULT_CONSOLE_LOGLEVEL ,/* default_console_loglevel */ +CONSOLE_LOGLEVEL_MIN ,/* minimum_console_loglevel */ +CONSOLE_LOGLEVEL_DEFAULT ,/* default_console_loglevel */ };/*
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Borislav Petkov
maintainerQuoted 23 lines · Borislav Petkov
Hi,
so I was staring at
12544697f12e("x86_64: be less annoying on boot, v2")and how naked numbers mean sh*t and how I have to grep sources to find out what this 10 thing means. So how about the following cleanup? We can do it this way, we can do accessors and stuff, whatever. But the naked numbers are plain misleading.
So how about it? I'm asking whether it makes sense first before I go and replace all tests of
console_loglevelwith naked numbers around the tree.Thanks.
---
arch/x86/kernel/head64.c +0
-0
arch/x86/kernel/head64.c asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) · line 175
Quoted 5 lines
arch/x86/kernel/head64.c +1
-1@@ -172,7 +172,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)*/ load_ucode_bsp (); -if (console_loglevel ==10 ) +if (console_loglevel >=CONSOLE_LOGLEVEL_QUIET )
That's CONSOLE_LOGLEVEL_DEBUG, of course.
See, misleading. :-P
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 27 lines · Borislav Petkov
Quoted 26 lines · Borislav Petkov
Hi,
so I was staring at
12544697f12e("x86_64: be less annoying on boot, v2")and how naked numbers mean sh*t and how I have to grep sources to find out what this 10 thing means. So how about the following cleanup? We can do it this way, we can do accessors and stuff, whatever. But the naked numbers are plain misleading.
So how about it? I'm asking whether it makes sense first before I go and replace all tests of
console_loglevelwith naked numbers around the tree.Thanks.
---
arch/x86/kernel/head64.c +0
-0@@ -172,7 +172,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)*/ load_ucode_bsp ();
Quoted 7 lines
arch/x86/kernel/head64.c asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) · line 175
Quoted 2 lines
arch/x86/kernel/head64.c +1
-1-if (console_loglevel ==10 ) +if (console_loglevel >=CONSOLE_LOGLEVEL_QUIET )That's
CONSOLE_LOGLEVEL_DEBUG, of course.See, misleading. :-P
Absolutely. I'll ack it with that change.
Signature · 1 line
~Randy