Commit 0835f1f8 authored by Thomas Gleixner's avatar Thomas Gleixner

printk: Connvert logbuf_lock to atomic_spinlock

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent fd2bde5d
...@@ -92,7 +92,7 @@ static int console_locked, console_suspended; ...@@ -92,7 +92,7 @@ static int console_locked, console_suspended;
* It is also used in interesting ways to provide interlocking in * It is also used in interesting ways to provide interlocking in
* release_console_sem(). * release_console_sem().
*/ */
static DEFINE_SPINLOCK(logbuf_lock); static DEFINE_ATOMIC_SPINLOCK(logbuf_lock);
#define LOG_BUF_MASK (log_buf_len-1) #define LOG_BUF_MASK (log_buf_len-1)
#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
...@@ -171,7 +171,7 @@ static int __init log_buf_len_setup(char *str) ...@@ -171,7 +171,7 @@ static int __init log_buf_len_setup(char *str)
goto out; goto out;
} }
spin_lock_irqsave(&logbuf_lock, flags); atomic_spin_lock_irqsave(&logbuf_lock, flags);
log_buf_len = size; log_buf_len = size;
log_buf = new_log_buf; log_buf = new_log_buf;
...@@ -185,7 +185,7 @@ static int __init log_buf_len_setup(char *str) ...@@ -185,7 +185,7 @@ static int __init log_buf_len_setup(char *str)
log_start -= offset; log_start -= offset;
con_start -= offset; con_start -= offset;
log_end -= offset; log_end -= offset;
spin_unlock_irqrestore(&logbuf_lock, flags); atomic_spin_unlock_irqrestore(&logbuf_lock, flags);
printk(KERN_NOTICE "log_buf_len: %d\n", log_buf_len); printk(KERN_NOTICE "log_buf_len: %d\n", log_buf_len);
} }
...@@ -297,18 +297,18 @@ int do_syslog(int type, char __user *buf, int len) ...@@ -297,18 +297,18 @@ int do_syslog(int type, char __user *buf, int len)
if (error) if (error)
goto out; goto out;
i = 0; i = 0;
spin_lock_irq(&logbuf_lock); atomic_spin_lock_irq(&logbuf_lock);
while (!error && (log_start != log_end) && i < len) { while (!error && (log_start != log_end) && i < len) {
c = LOG_BUF(log_start); c = LOG_BUF(log_start);
log_start++; log_start++;
spin_unlock_irq(&logbuf_lock); atomic_spin_unlock_irq(&logbuf_lock);
error = __put_user(c,buf); error = __put_user(c,buf);
buf++; buf++;
i++; i++;
cond_resched(); cond_resched();
spin_lock_irq(&logbuf_lock); atomic_spin_lock_irq(&logbuf_lock);
} }
spin_unlock_irq(&logbuf_lock); atomic_spin_unlock_irq(&logbuf_lock);
if (!error) if (!error)
error = i; error = i;
break; break;
...@@ -329,7 +329,7 @@ int do_syslog(int type, char __user *buf, int len) ...@@ -329,7 +329,7 @@ int do_syslog(int type, char __user *buf, int len)
count = len; count = len;
if (count > log_buf_len) if (count > log_buf_len)
count = log_buf_len; count = log_buf_len;
spin_lock_irq(&logbuf_lock); atomic_spin_lock_irq(&logbuf_lock);
if (count > logged_chars) if (count > logged_chars)
count = logged_chars; count = logged_chars;
if (do_clear) if (do_clear)
...@@ -346,12 +346,12 @@ int do_syslog(int type, char __user *buf, int len) ...@@ -346,12 +346,12 @@ int do_syslog(int type, char __user *buf, int len)
if (j + log_buf_len < log_end) if (j + log_buf_len < log_end)
break; break;
c = LOG_BUF(j); c = LOG_BUF(j);
spin_unlock_irq(&logbuf_lock); atomic_spin_unlock_irq(&logbuf_lock);
error = __put_user(c,&buf[count-1-i]); error = __put_user(c,&buf[count-1-i]);
cond_resched(); cond_resched();
spin_lock_irq(&logbuf_lock); atomic_spin_lock_irq(&logbuf_lock);
} }
spin_unlock_irq(&logbuf_lock); atomic_spin_unlock_irq(&logbuf_lock);
if (error) if (error)
break; break;
error = i; error = i;
...@@ -527,7 +527,7 @@ static void zap_locks(void) ...@@ -527,7 +527,7 @@ static void zap_locks(void)
oops_timestamp = jiffies; oops_timestamp = jiffies;
/* If a crash is occurring, make sure we can't deadlock */ /* If a crash is occurring, make sure we can't deadlock */
spin_lock_init(&logbuf_lock); atomic_spin_lock_init(&logbuf_lock);
/* And make sure that we print immediately */ /* And make sure that we print immediately */
init_MUTEX(&console_sem); init_MUTEX(&console_sem);
} }
...@@ -631,7 +631,7 @@ static int acquire_console_semaphore_for_printk(unsigned int cpu) ...@@ -631,7 +631,7 @@ static int acquire_console_semaphore_for_printk(unsigned int cpu)
} }
} }
printk_cpu = UINT_MAX; printk_cpu = UINT_MAX;
spin_unlock(&logbuf_lock); atomic_spin_unlock(&logbuf_lock);
return retval; return retval;
} }
static const char recursion_bug_msg [] = static const char recursion_bug_msg [] =
...@@ -674,7 +674,7 @@ asmlinkage int vprintk(const char *fmt, va_list args) ...@@ -674,7 +674,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
} }
lockdep_off(); lockdep_off();
spin_lock(&logbuf_lock); atomic_spin_lock(&logbuf_lock);
printk_cpu = this_cpu; printk_cpu = this_cpu;
if (recursion_bug) { if (recursion_bug) {
...@@ -1023,14 +1023,14 @@ void release_console_sem(void) ...@@ -1023,14 +1023,14 @@ void release_console_sem(void)
console_may_schedule = 0; console_may_schedule = 0;
for ( ; ; ) { for ( ; ; ) {
spin_lock_irqsave(&logbuf_lock, flags); atomic_spin_lock_irqsave(&logbuf_lock, flags);
wake_klogd |= log_start - log_end; wake_klogd |= log_start - log_end;
if (con_start == log_end) if (con_start == log_end)
break; /* Nothing to print */ break; /* Nothing to print */
_con_start = con_start; _con_start = con_start;
_log_end = log_end; _log_end = log_end;
con_start = log_end; /* Flush */ con_start = log_end; /* Flush */
spin_unlock(&logbuf_lock); atomic_spin_unlock(&logbuf_lock);
stop_critical_timings(); /* don't trace print latency */ stop_critical_timings(); /* don't trace print latency */
call_console_drivers(_con_start, _log_end); call_console_drivers(_con_start, _log_end);
start_critical_timings(); start_critical_timings();
...@@ -1038,7 +1038,7 @@ void release_console_sem(void) ...@@ -1038,7 +1038,7 @@ void release_console_sem(void)
} }
console_locked = 0; console_locked = 0;
up(&console_sem); up(&console_sem);
spin_unlock_irqrestore(&logbuf_lock, flags); atomic_spin_unlock_irqrestore(&logbuf_lock, flags);
if (wake_klogd) if (wake_klogd)
wake_up_klogd(); wake_up_klogd();
} }
...@@ -1240,9 +1240,9 @@ void register_console(struct console *console) ...@@ -1240,9 +1240,9 @@ void register_console(struct console *console)
* release_console_sem() will print out the buffered messages * release_console_sem() will print out the buffered messages
* for us. * for us.
*/ */
spin_lock_irqsave(&logbuf_lock, flags); atomic_spin_lock_irqsave(&logbuf_lock, flags);
con_start = log_start; con_start = log_start;
spin_unlock_irqrestore(&logbuf_lock, flags); atomic_spin_unlock_irqrestore(&logbuf_lock, flags);
} }
release_console_sem(); release_console_sem();
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/module.h> #include <linux/module.h>
static DEFINE_SPINLOCK(ratelimit_lock); static DEFINE_ATOMIC_SPINLOCK(ratelimit_lock);
/* /*
* __ratelimit - rate limiting * __ratelimit - rate limiting
...@@ -30,7 +30,7 @@ int __ratelimit(struct ratelimit_state *rs) ...@@ -30,7 +30,7 @@ int __ratelimit(struct ratelimit_state *rs)
if (!rs->interval) if (!rs->interval)
return 1; return 1;
spin_lock_irqsave(&ratelimit_lock, flags); atomic_spin_lock_irqsave(&ratelimit_lock, flags);
if (!rs->begin) if (!rs->begin)
rs->begin = jiffies; rs->begin = jiffies;
...@@ -46,12 +46,12 @@ int __ratelimit(struct ratelimit_state *rs) ...@@ -46,12 +46,12 @@ int __ratelimit(struct ratelimit_state *rs)
goto print; goto print;
rs->missed++; rs->missed++;
spin_unlock_irqrestore(&ratelimit_lock, flags); atomic_spin_unlock_irqrestore(&ratelimit_lock, flags);
return 0; return 0;
print: print:
rs->printed++; rs->printed++;
spin_unlock_irqrestore(&ratelimit_lock, flags); atomic_spin_unlock_irqrestore(&ratelimit_lock, flags);
return 1; return 1;
} }
EXPORT_SYMBOL(__ratelimit); EXPORT_SYMBOL(__ratelimit);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment