diff options
Diffstat (limited to 'kernel/printk.c')
| -rw-r--r-- | kernel/printk.c | 13 | 
1 files changed, 12 insertions, 1 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 5092397fac29..a967605bc2e3 100644 --- a/kernel/printk.c +++ b/kernel/printk.c  | |||
| @@ -514,6 +514,9 @@ asmlinkage int printk(const char *fmt, ...) | |||
| 514 | return r; | 514 | return r; | 
| 515 | } | 515 | } | 
| 516 | 516 | ||
| 517 | /* cpu currently holding logbuf_lock */ | ||
| 518 | static volatile unsigned int printk_cpu = UINT_MAX; | ||
| 519 | |||
| 517 | asmlinkage int vprintk(const char *fmt, va_list args) | 520 | asmlinkage int vprintk(const char *fmt, va_list args) | 
| 518 | { | 521 | { | 
| 519 | unsigned long flags; | 522 | unsigned long flags; | 
| @@ -522,11 +525,15 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
| 522 | static char printk_buf[1024]; | 525 | static char printk_buf[1024]; | 
| 523 | static int log_level_unknown = 1; | 526 | static int log_level_unknown = 1; | 
| 524 | 527 | ||
| 525 | if (unlikely(oops_in_progress)) | 528 | preempt_disable(); | 
| 529 | if (unlikely(oops_in_progress) && printk_cpu == smp_processor_id()) | ||
| 530 | /* If a crash is occurring during printk() on this CPU, | ||
| 531 | * make sure we can't deadlock */ | ||
| 526 | zap_locks(); | 532 | zap_locks(); | 
| 527 | 533 | ||
| 528 | /* This stops the holder of console_sem just where we want him */ | 534 | /* This stops the holder of console_sem just where we want him */ | 
| 529 | spin_lock_irqsave(&logbuf_lock, flags); | 535 | spin_lock_irqsave(&logbuf_lock, flags); | 
| 536 | printk_cpu = smp_processor_id(); | ||
| 530 | 537 | ||
| 531 | /* Emit the output into the temporary buffer */ | 538 | /* Emit the output into the temporary buffer */ | 
| 532 | printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args); | 539 | printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args); | 
| @@ -595,6 +602,7 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
| 595 | * CPU until it is officially up. We shouldn't be calling into | 602 | * CPU until it is officially up. We shouldn't be calling into | 
| 596 | * random console drivers on a CPU which doesn't exist yet.. | 603 | * random console drivers on a CPU which doesn't exist yet.. | 
| 597 | */ | 604 | */ | 
| 605 | printk_cpu = UINT_MAX; | ||
| 598 | spin_unlock_irqrestore(&logbuf_lock, flags); | 606 | spin_unlock_irqrestore(&logbuf_lock, flags); | 
| 599 | goto out; | 607 | goto out; | 
| 600 | } | 608 | } | 
| @@ -604,6 +612,7 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
| 604 | * We own the drivers. We can drop the spinlock and let | 612 | * We own the drivers. We can drop the spinlock and let | 
| 605 | * release_console_sem() print the text | 613 | * release_console_sem() print the text | 
| 606 | */ | 614 | */ | 
| 615 | printk_cpu = UINT_MAX; | ||
| 607 | spin_unlock_irqrestore(&logbuf_lock, flags); | 616 | spin_unlock_irqrestore(&logbuf_lock, flags); | 
| 608 | console_may_schedule = 0; | 617 | console_may_schedule = 0; | 
| 609 | release_console_sem(); | 618 | release_console_sem(); | 
| @@ -613,9 +622,11 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
| 613 | * allows the semaphore holder to proceed and to call the | 622 | * allows the semaphore holder to proceed and to call the | 
| 614 | * console drivers with the output which we just produced. | 623 | * console drivers with the output which we just produced. | 
| 615 | */ | 624 | */ | 
| 625 | printk_cpu = UINT_MAX; | ||
| 616 | spin_unlock_irqrestore(&logbuf_lock, flags); | 626 | spin_unlock_irqrestore(&logbuf_lock, flags); | 
| 617 | } | 627 | } | 
| 618 | out: | 628 | out: | 
| 629 | preempt_enable(); | ||
| 619 | return printed_len; | 630 | return printed_len; | 
| 620 | } | 631 | } | 
| 621 | EXPORT_SYMBOL(printk); | 632 | EXPORT_SYMBOL(printk); | 
