aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-07-25 11:50:36 -0400
committerIngo Molnar <mingo@elte.hu>2011-09-13 05:11:54 -0400
commit07354eb1a74d1e1ece29f8bafe0b46e8c77a95ef (patch)
tree4e2370ce5a6eb5eccc20d89dcfca44cc0dafbfa6 /kernel/printk.c
parent5389f6fad27019f2ba78f1b332f719ec05f12a42 (diff)
locking, printk: Annotate logbuf_lock as raw
The logbuf_lock lock can be taken in atomic context and therefore cannot be preempted on -rt - annotate it. In mainline this change documents the low level nature of the lock - otherwise there's no functional difference. Lockdep and Sparse checking will work as usual. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> [ merged and fixed it ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/printk.c')
-rw-r--r--kernel/printk.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 28a40d8171b..b7da18391c3 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;
@@ -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) {
@@ -1257,14 +1257,14 @@ void console_unlock(void)
1257 1257
1258again: 1258again:
1259 for ( ; ; ) { 1259 for ( ; ; ) {
1260 spin_lock_irqsave(&logbuf_lock, flags); 1260 raw_spin_lock_irqsave(&logbuf_lock, flags);
1261 wake_klogd |= log_start - log_end; 1261 wake_klogd |= log_start - log_end;
1262 if (con_start == log_end) 1262 if (con_start == log_end)
1263 break; /* Nothing to print */ 1263 break; /* Nothing to print */
1264 _con_start = con_start; 1264 _con_start = con_start;
1265 _log_end = log_end; 1265 _log_end = log_end;
1266 con_start = log_end; /* Flush */ 1266 con_start = log_end; /* Flush */
1267 spin_unlock(&logbuf_lock); 1267 raw_spin_unlock(&logbuf_lock);
1268 stop_critical_timings(); /* don't trace print latency */ 1268 stop_critical_timings(); /* don't trace print latency */
1269 call_console_drivers(_con_start, _log_end); 1269 call_console_drivers(_con_start, _log_end);
1270 start_critical_timings(); 1270 start_critical_timings();
@@ -1276,7 +1276,7 @@ again:
1276 if (unlikely(exclusive_console)) 1276 if (unlikely(exclusive_console))
1277 exclusive_console = NULL; 1277 exclusive_console = NULL;
1278 1278
1279 spin_unlock(&logbuf_lock); 1279 raw_spin_unlock(&logbuf_lock);
1280 1280
1281 up(&console_sem); 1281 up(&console_sem);
1282 1282
@@ -1286,13 +1286,13 @@ again:
1286 * there's a new owner and the console_unlock() from them will do the 1286 * there's a new owner and the console_unlock() from them will do the
1287 * flush, no worries. 1287 * flush, no worries.
1288 */ 1288 */
1289 spin_lock(&logbuf_lock); 1289 raw_spin_lock(&logbuf_lock);
1290 if (con_start != log_end) 1290 if (con_start != log_end)
1291 retry = 1; 1291 retry = 1;
1292 spin_unlock_irqrestore(&logbuf_lock, flags);
1293 if (retry && console_trylock()) 1292 if (retry && console_trylock())
1294 goto again; 1293 goto again;
1295 1294
1295 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
1296 if (wake_klogd) 1296 if (wake_klogd)
1297 wake_up_klogd(); 1297 wake_up_klogd();
1298} 1298}
@@ -1522,9 +1522,9 @@ void register_console(struct console *newcon)
1522 * console_unlock(); will print out the buffered messages 1522 * console_unlock(); will print out the buffered messages
1523 * for us. 1523 * for us.
1524 */ 1524 */
1525 spin_lock_irqsave(&logbuf_lock, flags); 1525 raw_spin_lock_irqsave(&logbuf_lock, flags);
1526 con_start = log_start; 1526 con_start = log_start;
1527 spin_unlock_irqrestore(&logbuf_lock, flags); 1527 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
1528 /* 1528 /*
1529 * We're about to replay the log buffer. Only do this to the 1529 * We're about to replay the log buffer. Only do this to the
1530 * just-registered console to avoid excessive message spam to 1530 * just-registered console to avoid excessive message spam to
@@ -1731,10 +1731,10 @@ void kmsg_dump(enum kmsg_dump_reason reason)
1731 /* Theoretically, the log could move on after we do this, but 1731 /* 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 1732 there's not a lot we can do about that. The new messages
1733 will overwrite the start of what we dump. */ 1733 will overwrite the start of what we dump. */
1734 spin_lock_irqsave(&logbuf_lock, flags); 1734 raw_spin_lock_irqsave(&logbuf_lock, flags);
1735 end = log_end & LOG_BUF_MASK; 1735 end = log_end & LOG_BUF_MASK;
1736 chars = logged_chars; 1736 chars = logged_chars;
1737 spin_unlock_irqrestore(&logbuf_lock, flags); 1737 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
1738 1738
1739 if (chars > end) { 1739 if (chars > end) {
1740 s1 = log_buf + log_buf_len - chars + end; 1740 s1 = log_buf + log_buf_len - chars + end;