aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ratelimit.h6
-rw-r--r--kernel/printk.c46
-rw-r--r--lib/ratelimit.c4
3 files changed, 28 insertions, 28 deletions
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h
index 2f007157fab9..e11ccb4cf48d 100644
--- a/include/linux/ratelimit.h
+++ b/include/linux/ratelimit.h
@@ -8,7 +8,7 @@
8#define DEFAULT_RATELIMIT_BURST 10 8#define DEFAULT_RATELIMIT_BURST 10
9 9
10struct ratelimit_state { 10struct ratelimit_state {
11 spinlock_t lock; /* protect the state */ 11 raw_spinlock_t lock; /* protect the state */
12 12
13 int interval; 13 int interval;
14 int burst; 14 int burst;
@@ -20,7 +20,7 @@ struct ratelimit_state {
20#define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \ 20#define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \
21 \ 21 \
22 struct ratelimit_state name = { \ 22 struct ratelimit_state name = { \
23 .lock = __SPIN_LOCK_UNLOCKED(name.lock), \ 23 .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \
24 .interval = interval_init, \ 24 .interval = interval_init, \
25 .burst = burst_init, \ 25 .burst = burst_init, \
26 } 26 }
@@ -28,7 +28,7 @@ struct ratelimit_state {
28static inline void ratelimit_state_init(struct ratelimit_state *rs, 28static inline void ratelimit_state_init(struct ratelimit_state *rs,
29 int interval, int burst) 29 int interval, int burst)
30{ 30{
31 spin_lock_init(&rs->lock); 31 raw_spin_lock_init(&rs->lock);
32 rs->interval = interval; 32 rs->interval = interval;
33 rs->burst = burst; 33 rs->burst = burst;
34 rs->printed = 0; 34 rs->printed = 0;
diff --git a/kernel/printk.c b/kernel/printk.c
index 28a40d8171b8..b7da18391c38 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;
diff --git a/lib/ratelimit.c b/lib/ratelimit.c
index 027a03f4c56d..c96d500577de 100644
--- a/lib/ratelimit.c
+++ b/lib/ratelimit.c
@@ -39,7 +39,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
39 * in addition to the one that will be printed by 39 * in addition to the one that will be printed by
40 * the entity that is holding the lock already: 40 * the entity that is holding the lock already:
41 */ 41 */
42 if (!spin_trylock_irqsave(&rs->lock, flags)) 42 if (!raw_spin_trylock_irqsave(&rs->lock, flags))
43 return 0; 43 return 0;
44 44
45 if (!rs->begin) 45 if (!rs->begin)
@@ -60,7 +60,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
60 rs->missed++; 60 rs->missed++;
61 ret = 0; 61 ret = 0;
62 } 62 }
63 spin_unlock_irqrestore(&rs->lock, flags); 63 raw_spin_unlock_irqrestore(&rs->lock, flags);
64 64
65 return ret; 65 return ret;
66} 66}