aboutsummaryrefslogtreecommitdiff
path: root/kernel/printk/printk.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-07-03 09:22:00 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-07-03 09:22:00 -0700
commit5170a3b24a9141e2349a3420448743b7c68f2223 (patch)
treef88f5f1cb303a5983013154f7713972408ace60e /kernel/printk/printk.c
parente55a379827ed02c4982250fc815fed47def53a45 (diff)
parent66d2f4d28cd030220e7ea2a628993fcabcb956d1 (diff)
Merge branch 'akpm' (patches from Andrew Morton)
Merge fixes from Andrew Morton: "14 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: shmem: fix init_page_accessed use to stop !PageLRU bug kernel/printk/printk.c: revert "printk: enable interrupts before calling console_trylock_for_printk()" tools/testing/selftests/ipc/msgque.c: improve error handling when not running as root fs/seq_file: fallback to vmalloc allocation /proc/stat: convert to single_open_size() hwpoison: fix the handling path of the victimized page frame that belong to non-LRU mm:vmscan: update the trace-vmscan-postprocess.pl for event vmscan/mm_vmscan_lru_isolate msync: fix incorrect fstart calculation zram: revalidate disk after capacity change tools: memory-hotplug fix unexpected operator error tools: cpu-hotplug fix unexpected operator error autofs4: fix false positive compile error slub: fix off by one in number of slab tests mm: page_alloc: fix CMA area initialisation when pageblock > MAX_ORDER
Diffstat (limited to 'kernel/printk/printk.c')
-rw-r--r--kernel/printk/printk.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index ea2d5f6962e..13e839dbca0 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1416,9 +1416,10 @@ static int have_callable_console(void)
/*
* Can we actually use the console at this time on this cpu?
*
- * Console drivers may assume that per-cpu resources have been allocated. So
- * unless they're explicitly marked as being able to cope (CON_ANYTIME) don't
- * call them until this CPU is officially up.
+ * Console drivers may assume that per-cpu resources have
+ * been allocated. So unless they're explicitly marked as
+ * being able to cope (CON_ANYTIME) don't call them until
+ * this CPU is officially up.
*/
static inline int can_use_console(unsigned int cpu)
{
@@ -1431,10 +1432,8 @@ static inline int can_use_console(unsigned int cpu)
* console_lock held, and 'console_locked' set) if it
* is successful, false otherwise.
*/
-static int console_trylock_for_printk(void)
+static int console_trylock_for_printk(unsigned int cpu)
{
- unsigned int cpu = smp_processor_id();
-
if (!console_trylock())
return 0;
/*
@@ -1609,8 +1608,7 @@ asmlinkage int vprintk_emit(int facility, int level,
*/
if (!oops_in_progress && !lockdep_recursing(current)) {
recursion_bug = 1;
- local_irq_restore(flags);
- return 0;
+ goto out_restore_irqs;
}
zap_locks();
}
@@ -1718,27 +1716,21 @@ asmlinkage int vprintk_emit(int facility, int level,
logbuf_cpu = UINT_MAX;
raw_spin_unlock(&logbuf_lock);
- lockdep_on();
- local_irq_restore(flags);
/* If called from the scheduler, we can not call up(). */
- if (in_sched)
- return printed_len;
-
- /*
- * Disable preemption to avoid being preempted while holding
- * console_sem which would prevent anyone from printing to console
- */
- preempt_disable();
- /*
- * Try to acquire and then immediately release the console semaphore.
- * The release will print out buffers and wake up /dev/kmsg and syslog()
- * users.
- */
- if (console_trylock_for_printk())
- console_unlock();
- preempt_enable();
+ if (!in_sched) {
+ /*
+ * Try to acquire and then immediately release the console
+ * semaphore. The release will print out buffers and wake up
+ * /dev/kmsg and syslog() users.
+ */
+ if (console_trylock_for_printk(this_cpu))
+ console_unlock();
+ }
+ lockdep_on();
+out_restore_irqs:
+ local_irq_restore(flags);
return printed_len;
}
EXPORT_SYMBOL(vprintk_emit);