aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/printk.c')
-rw-r--r--kernel/printk.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 28a40d8171b8..1455a0d4eedd 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -100,7 +100,7 @@ static int console_locked, console_suspended;
100 * It is also used in interesting ways to provide interlocking in 100 * It is also used in interesting ways to provide interlocking in
101 * console_unlock();. 101 * console_unlock();.
102 */ 102 */
103static DEFINE_SPINLOCK(logbuf_lock); 103static DEFINE_RAW_SPINLOCK(logbuf_lock);
104 104
105#define LOG_BUF_MASK (log_buf_len-1) 105#define LOG_BUF_MASK (log_buf_len-1)
106#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) 106#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
@@ -212,7 +212,7 @@ void __init setup_log_buf(int early)
212 return; 212 return;
213 } 213 }
214 214
215 spin_lock_irqsave(&logbuf_lock, flags); 215 raw_spin_lock_irqsave(&logbuf_lock, flags);
216 log_buf_len = new_log_buf_len; 216 log_buf_len = new_log_buf_len;
217 log_buf = new_log_buf; 217 log_buf = new_log_buf;
218 new_log_buf_len = 0; 218 new_log_buf_len = 0;
@@ -230,7 +230,7 @@ void __init setup_log_buf(int early)
230 log_start -= offset; 230 log_start -= offset;
231 con_start -= offset; 231 con_start -= offset;
232 log_end -= offset; 232 log_end -= offset;
233 spin_unlock_irqrestore(&logbuf_lock, flags); 233 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
234 234
235 pr_info("log_buf_len: %d\n", log_buf_len); 235 pr_info("log_buf_len: %d\n", log_buf_len);
236 pr_info("early log buf free: %d(%d%%)\n", 236 pr_info("early log buf free: %d(%d%%)\n",
@@ -365,18 +365,18 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
365 if (error) 365 if (error)
366 goto out; 366 goto out;
367 i = 0; 367 i = 0;
368 spin_lock_irq(&logbuf_lock); 368 raw_spin_lock_irq(&logbuf_lock);
369 while (!error && (log_start != log_end) && i < len) { 369 while (!error && (log_start != log_end) && i < len) {
370 c = LOG_BUF(log_start); 370 c = LOG_BUF(log_start);
371 log_start++; 371 log_start++;
372 spin_unlock_irq(&logbuf_lock); 372 raw_spin_unlock_irq(&logbuf_lock);
373 error = __put_user(c,buf); 373 error = __put_user(c,buf);
374 buf++; 374 buf++;
375 i++; 375 i++;
376 cond_resched(); 376 cond_resched();
377 spin_lock_irq(&logbuf_lock); 377 raw_spin_lock_irq(&logbuf_lock);
378 } 378 }
379 spin_unlock_irq(&logbuf_lock); 379 raw_spin_unlock_irq(&logbuf_lock);
380 if (!error) 380 if (!error)
381 error = i; 381 error = i;
382 break; 382 break;
@@ -399,7 +399,7 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
399 count = len; 399 count = len;
400 if (count > log_buf_len) 400 if (count > log_buf_len)
401 count = log_buf_len; 401 count = log_buf_len;
402 spin_lock_irq(&logbuf_lock); 402 raw_spin_lock_irq(&logbuf_lock);
403 if (count > logged_chars) 403 if (count > logged_chars)
404 count = logged_chars; 404 count = logged_chars;
405 if (do_clear) 405 if (do_clear)
@@ -416,12 +416,12 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
416 if (j + log_buf_len < log_end) 416 if (j + log_buf_len < log_end)
417 break; 417 break;
418 c = LOG_BUF(j); 418 c = LOG_BUF(j);
419 spin_unlock_irq(&logbuf_lock); 419 raw_spin_unlock_irq(&logbuf_lock);
420 error = __put_user(c,&buf[count-1-i]); 420 error = __put_user(c,&buf[count-1-i]);
421 cond_resched(); 421 cond_resched();
422 spin_lock_irq(&logbuf_lock); 422 raw_spin_lock_irq(&logbuf_lock);
423 } 423 }
424 spin_unlock_irq(&logbuf_lock); 424 raw_spin_unlock_irq(&logbuf_lock);
425 if (error) 425 if (error)
426 break; 426 break;
427 error = i; 427 error = i;
@@ -532,6 +532,9 @@ static int __init ignore_loglevel_setup(char *str)
532} 532}
533 533
534early_param("ignore_loglevel", ignore_loglevel_setup); 534early_param("ignore_loglevel", ignore_loglevel_setup);
535module_param_named(ignore_loglevel, ignore_loglevel, bool, S_IRUGO | S_IWUSR);
536MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to"
537 "print all kernel messages to the console.");
535 538
536/* 539/*
537 * Write out chars from start to end - 1 inclusive 540 * Write out chars from start to end - 1 inclusive
@@ -592,9 +595,6 @@ static size_t log_prefix(const char *p, unsigned int *level, char *special)
592 /* multi digit including the level and facility number */ 595 /* multi digit including the level and facility number */
593 char *endp = NULL; 596 char *endp = NULL;
594 597
595 if (p[1] < '0' && p[1] > '9')
596 return 0;
597
598 lev = (simple_strtoul(&p[1], &endp, 10) & 7); 598 lev = (simple_strtoul(&p[1], &endp, 10) & 7);
599 if (endp == NULL || endp[0] != '>') 599 if (endp == NULL || endp[0] != '>')
600 return 0; 600 return 0;
@@ -689,7 +689,7 @@ static void zap_locks(void)
689 oops_timestamp = jiffies; 689 oops_timestamp = jiffies;
690 690
691 /* If a crash is occurring, make sure we can't deadlock */ 691 /* If a crash is occurring, make sure we can't deadlock */
692 spin_lock_init(&logbuf_lock); 692 raw_spin_lock_init(&logbuf_lock);
693 /* And make sure that we print immediately */ 693 /* And make sure that we print immediately */
694 sema_init(&console_sem, 1); 694 sema_init(&console_sem, 1);
695} 695}
@@ -802,9 +802,9 @@ static int console_trylock_for_printk(unsigned int cpu)
802 } 802 }
803 } 803 }
804 printk_cpu = UINT_MAX; 804 printk_cpu = UINT_MAX;
805 spin_unlock(&logbuf_lock);
806 if (wake) 805 if (wake)
807 up(&console_sem); 806 up(&console_sem);
807 raw_spin_unlock(&logbuf_lock);
808 return retval; 808 return retval;
809} 809}
810static const char recursion_bug_msg [] = 810static const char recursion_bug_msg [] =
@@ -864,7 +864,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
864 } 864 }
865 865
866 lockdep_off(); 866 lockdep_off();
867 spin_lock(&logbuf_lock); 867 raw_spin_lock(&logbuf_lock);
868 printk_cpu = this_cpu; 868 printk_cpu = this_cpu;
869 869
870 if (recursion_bug) { 870 if (recursion_bug) {
@@ -1108,6 +1108,10 @@ static int __init console_suspend_disable(char *str)
1108 return 1; 1108 return 1;
1109} 1109}
1110__setup("no_console_suspend", console_suspend_disable); 1110__setup("no_console_suspend", console_suspend_disable);
1111module_param_named(console_suspend, console_suspend_enabled,
1112 bool, S_IRUGO | S_IWUSR);
1113MODULE_PARM_DESC(console_suspend, "suspend console during suspend"
1114 " and hibernate operations");
1111 1115
1112/** 1116/**
1113 * suspend_console - suspend the console subsystem 1117 * suspend_console - suspend the console subsystem
@@ -1257,14 +1261,14 @@ void console_unlock(void)
1257 1261
1258again: 1262again:
1259 for ( ; ; ) { 1263 for ( ; ; ) {
1260 spin_lock_irqsave(&logbuf_lock, flags); 1264 raw_spin_lock_irqsave(&logbuf_lock, flags);
1261 wake_klogd |= log_start - log_end; 1265 wake_klogd |= log_start - log_end;
1262 if (con_start == log_end) 1266 if (con_start == log_end)
1263 break; /* Nothing to print */ 1267 break; /* Nothing to print */
1264 _con_start = con_start; 1268 _con_start = con_start;
1265 _log_end = log_end; 1269 _log_end = log_end;
1266 con_start = log_end; /* Flush */ 1270 con_start = log_end; /* Flush */
1267 spin_unlock(&logbuf_lock); 1271 raw_spin_unlock(&logbuf_lock);
1268 stop_critical_timings(); /* don't trace print latency */ 1272 stop_critical_timings(); /* don't trace print latency */
1269 call_console_drivers(_con_start, _log_end); 1273 call_console_drivers(_con_start, _log_end);
1270 start_critical_timings(); 1274 start_critical_timings();
@@ -1276,7 +1280,7 @@ again:
1276 if (unlikely(exclusive_console)) 1280 if (unlikely(exclusive_console))
1277 exclusive_console = NULL; 1281 exclusive_console = NULL;
1278 1282
1279 spin_unlock(&logbuf_lock); 1283 raw_spin_unlock(&logbuf_lock);
1280 1284
1281 up(&console_sem); 1285 up(&console_sem);
1282 1286
@@ -1286,13 +1290,13 @@ again:
1286 * there's a new owner and the console_unlock() from them will do the 1290 * there's a new owner and the console_unlock() from them will do the
1287 * flush, no worries. 1291 * flush, no worries.
1288 */ 1292 */
1289 spin_lock(&logbuf_lock); 1293 raw_spin_lock(&logbuf_lock);
1290 if (con_start != log_end) 1294 if (con_start != log_end)
1291 retry = 1; 1295 retry = 1;
1292 spin_unlock_irqrestore(&logbuf_lock, flags);
1293 if (retry && console_trylock()) 1296 if (retry && console_trylock())
1294 goto again; 1297 goto again;
1295 1298
1299 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
1296 if (wake_klogd) 1300 if (wake_klogd)
1297 wake_up_klogd(); 1301 wake_up_klogd();
1298} 1302}
@@ -1522,9 +1526,9 @@ void register_console(struct console *newcon)
1522 * console_unlock(); will print out the buffered messages 1526 * console_unlock(); will print out the buffered messages
1523 * for us. 1527 * for us.
1524 */ 1528 */
1525 spin_lock_irqsave(&logbuf_lock, flags); 1529 raw_spin_lock_irqsave(&logbuf_lock, flags);
1526 con_start = log_start; 1530 con_start = log_start;
1527 spin_unlock_irqrestore(&logbuf_lock, flags); 1531 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
1528 /* 1532 /*
1529 * We're about to replay the log buffer. Only do this to the 1533 * We're about to replay the log buffer. Only do this to the
1530 * just-registered console to avoid excessive message spam to 1534 * just-registered console to avoid excessive message spam to
@@ -1731,10 +1735,10 @@ void kmsg_dump(enum kmsg_dump_reason reason)
1731 /* Theoretically, the log could move on after we do this, but 1735 /* Theoretically, the log could move on after we do this, but
1732 there's not a lot we can do about that. The new messages 1736 there's not a lot we can do about that. The new messages
1733 will overwrite the start of what we dump. */ 1737 will overwrite the start of what we dump. */
1734 spin_lock_irqsave(&logbuf_lock, flags); 1738 raw_spin_lock_irqsave(&logbuf_lock, flags);
1735 end = log_end & LOG_BUF_MASK; 1739 end = log_end & LOG_BUF_MASK;
1736 chars = logged_chars; 1740 chars = logged_chars;
1737 spin_unlock_irqrestore(&logbuf_lock, flags); 1741 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
1738 1742
1739 if (chars > end) { 1743 if (chars > end) {
1740 s1 = log_buf + log_buf_len - chars + end; 1744 s1 = log_buf + log_buf_len - chars + end;