History

kernel/printk: use symbolic defines for console loglevels

... instead of naked numbers. Stuff in sysrq.c used to set it to 8 which is supposed to mean above default level so set it to DEBUG instead as we're terminating/killing all tasks and we want to be verbose there. Also, correct the check in x86_64_start_kernel which should be >= as we're clearly issuing the string there for all debug levels, not only the magical 10.

Borislav Petkov committed 12 years ago

Commit a8fe19e1 parent 84b5ec810 files · +36 −32Browse files

Unified · Split

10 files
  1. arch/x86/kernel/head64.c +1 −1
  2. arch/x86/platform/uv/uv_nmi.c +1 −1
  3. drivers/nubus/nubus.c +9 −9
  4. drivers/tty/sysrq.c +4 −4
  5. include/linux/printk.h +13 −2
  6. init/main.c +2 −2
  7. kernel/debug/kdb/kdb_bt.c +1 −1
  8. kernel/debug/kdb/kdb_io.c +1 −1
  9. kernel/debug/kdb/kdb_main.c +1 −1
  10. kernel/printk/printk.c +3 −10
arch/x86/kernel/head64.c+1−1
@@ -172,7 +172,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) · 171 unmodified lines
172172 */
173173 load_ucode_bsp();
174174
175− if (console_loglevel == 10)
175+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
176176 early_printk("Kernel alive\n");
177177
178178 clear_page(init_level4_pgt);
arch/x86/platform/uv/uv_nmi.c+1−1
@@ -85,7 +85,7 @@ static cpumask_var_t uv_nmi_cpu_mask; · 84 unmodified lines
8585 * Default is all stack dumps go to the console and buffer.
8686 * Lower level to send to log buffer only.
8787 */
88−static int uv_nmi_loglevel = 7;
88+static int uv_nmi_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
8989 module_param_named(dump_loglevel, uv_nmi_loglevel, int, 0644);
9090
9191 /*
drivers/nubus/nubus.c+9−9
@@ -473,7 +473,7 @@ static struct nubus_dev* __init · 472 unmodified lines
473473 if (slot == 0 && (unsigned long)dir.base % 2)
474474 dir.base += 1;
475475
476− if (console_loglevel >= 10)
476+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
477477 printk(KERN_DEBUG "nubus_get_functional_resource: parent is 0x%p, dir is 0x%p\n",
478478 parent->base, dir.base);
479479
@@ -568,7 +568,7 @@ static int __init nubus_get_vidnames(struct nubus_board* board, · 88 unmodified lines
568568
569569 printk(KERN_INFO " video modes supported:\n");
570570 nubus_get_subdir(parent, &dir);
571− if (console_loglevel >= 10)
571+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
572572 printk(KERN_DEBUG "nubus_get_vidnames: parent is 0x%p, dir is 0x%p\n",
573573 parent->base, dir.base);
574574
@@ -629,7 +629,7 @@ static int __init nubus_get_vendorinfo(struct nubus_board* board, · 54 unmodified lines
629629
630630 printk(KERN_INFO " vendor info:\n");
631631 nubus_get_subdir(parent, &dir);
632− if (console_loglevel >= 10)
632+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
633633 printk(KERN_DEBUG "nubus_get_vendorinfo: parent is 0x%p, dir is 0x%p\n",
634634 parent->base, dir.base);
635635
@@ -654,7 +654,7 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot, · 18 unmodified lines
654654 struct nubus_dirent ent;
655655
656656 nubus_get_subdir(parent, &dir);
657− if (console_loglevel >= 10)
657+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
658658 printk(KERN_DEBUG "nubus_get_board_resource: parent is 0x%p, dir is 0x%p\n",
659659 parent->base, dir.base);
660660
@@ -753,19 +753,19 @@ static void __init nubus_find_rom_dir(struct nubus_board* board) · 92 unmodified lines
753753 if (nubus_readdir(&dir, &ent) == -1)
754754 goto badrom;
755755
756− if (console_loglevel >= 10)
756+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
757757 printk(KERN_INFO "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data);
758758 /* This one takes us to where we want to go. */
759759 if (nubus_readdir(&dir, &ent) == -1)
760760 goto badrom;
761− if (console_loglevel >= 10)
761+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
762762 printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data);
763763 nubus_get_subdir(&ent, &dir);
764764
765765 /* Resource ID 01, also an "Unknown Macintosh" */
766766 if (nubus_readdir(&dir, &ent) == -1)
767767 goto badrom;
768− if (console_loglevel >= 10)
768+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
769769 printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data);
770770
771771 /* FIXME: the first one is *not* always the right one. We
@@ -780,7 +780,7 @@ static void __init nubus_find_rom_dir(struct nubus_board* board) · 8 unmodified lines
780780 path to that address... */
781781 if (nubus_readdir(&dir, &ent) == -1)
782782 goto badrom;
783− if (console_loglevel >= 10)
783+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
784784 printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data);
785785
786786 /* Bwahahahaha... */
@@ -816,7 +816,7 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) · 29 unmodified lines
816816 board->fblock = rp;
817817
818818 /* Dump the format block for debugging purposes */
819− if (console_loglevel >= 10) {
819+ if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) {
820820 int i;
821821 printk(KERN_DEBUG "Slot %X, format block at 0x%p\n",
822822 slot, rp);
drivers/tty/sysrq.c+4−4
@@ -88,7 +88,7 @@ static void sysrq_handle_loglevel(int key) · 87 unmodified lines
8888 int i;
8989
9090 i = key - '0';
91− console_loglevel = 7;
91+ console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
9292 printk("Loglevel set to %d\n", i);
9393 console_loglevel = i;
9494 }
@@ -343,7 +343,7 @@ static void send_sig_all(int sig) · 248 unmodified lines
343343 static void sysrq_handle_term(int key)
344344 {
345345 send_sig_all(SIGTERM);
346− console_loglevel = 8;
346+ console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
347347 }
348348 static struct sysrq_key_op sysrq_term_op = {
349349 .handler = sysrq_handle_term,
@@ -387,7 +387,7 @@ static struct sysrq_key_op sysrq_thaw_op = { · 37 unmodified lines
387387 static void sysrq_handle_kill(int key)
388388 {
389389 send_sig_all(SIGKILL);
390− console_loglevel = 8;
390+ console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
391391 }
392392 static struct sysrq_key_op sysrq_kill_op = {
393393 .handler = sysrq_handle_kill,
@@ -520,7 +520,7 @@ void __handle_sysrq(int key, bool check_mask) · 126 unmodified lines
520520 * routing in the consumers of /proc/kmsg.
521521 */
522522 orig_log_level = console_loglevel;
523− console_loglevel = 7;
523+ console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
524524 printk(KERN_INFO "SysRq : ");
525525
526526 op_p = __sysrq_get_key_op(key);
include/linux/printk.h+13−2
@@ -30,6 +30,17 @@ static inline const char *printk_skip_level(const char *buffer) · 29 unmodified lines
3030 return buffer;
3131 }
3232
33+/* printk's without a loglevel use this.. */
34+#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
35+
36+/* We show everything that is MORE important than this.. */
37+#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
38+#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
39+#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */
40+#define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */
41+#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
42+#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
43+
3344 extern int console_printk[];
3445
3546 #define console_loglevel (console_printk[0])
@@ -39,13 +50,13 @@ extern int console_printk[]; · 3 unmodified lines
3950
4051 static inline void console_silent(void)
4152 {
42− console_loglevel = 0;
53+ console_loglevel = CONSOLE_LOGLEVEL_SILENT;
4354 }
4455
4556 static inline void console_verbose(void)
4657 {
4758 if (console_loglevel)
48− console_loglevel = 15;
59+ console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
4960 }
5061
5162 struct va_format {
init/main.c+2−2
@@ -203,13 +203,13 @@ EXPORT_SYMBOL(loops_per_jiffy); · 202 unmodified lines
203203
204204 static int __init debug_kernel(char *str)
205205 {
206− console_loglevel = 10;
206+ console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
207207 return 0;
208208 }
209209
210210 static int __init quiet_kernel(char *str)
211211 {
212− console_loglevel = 4;
212+ console_loglevel = CONSOLE_LOGLEVEL_QUIET;
213213 return 0;
214214 }
215215
kernel/debug/kdb/kdb_bt.c+1−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
2121 static void kdb_show_stack(struct task_struct *p, void *addr)
2222 {
2323 int old_lvl = console_loglevel;
24− console_loglevel = 15;
24+ console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
2525 kdb_trap_printk++;
2626 kdb_set_current_task(p);
2727 if (addr) {
kernel/debug/kdb/kdb_io.c+1−1
@@ -710,7 +710,7 @@ kdb_printit: · 709 unmodified lines
710710 }
711711 if (logging) {
712712 saved_loglevel = console_loglevel;
713− console_loglevel = 0;
713+ console_loglevel = CONSOLE_LOGLEVEL_SILENT;
714714 printk(KERN_INFO "%s", kdb_buffer);
715715 }
716716
kernel/debug/kdb/kdb_main.c+1−1
@@ -1091,7 +1091,7 @@ static int kdb_reboot(int argc, const char **argv) · 1090 unmodified lines
10911091 static void kdb_dumpregs(struct pt_regs *regs)
10921092 {
10931093 int old_lvl = console_loglevel;
1094− console_loglevel = 15;
1094+ console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
10951095 kdb_trap_printk++;
10961096 show_regs(regs);
10971097 kdb_trap_printk--;
kernel/printk/printk.c+3−10
@@ -54,18 +54,11 @@ · 53 unmodified lines
5454 #include "console_cmdline.h"
5555 #include "braille.h"
5656
57−/* printk's without a loglevel use this.. */
58−#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
59−
60−/* We show everything that is MORE important than this.. */
61−#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
62−#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
63−
6457 int console_printk[4] = {
65− DEFAULT_CONSOLE_LOGLEVEL, /* console_loglevel */
58+ CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
6659 DEFAULT_MESSAGE_LOGLEVEL, /* default_message_loglevel */
67− MINIMUM_CONSOLE_LOGLEVEL, /* minimum_console_loglevel */
68− DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */
60+ CONSOLE_LOGLEVEL_MIN, /* minimum_console_loglevel */
61+ CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */
6962 };
7063
7164 /* Deferred messaged from sched code are marked by this special level */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t