mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Andreas Bombe <aeb@debian.org>
Cc: linux-kernel@vger.kernel.org, Jan Kara <jack@suse.cz>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [REGRESSION] Boot hang with 939f04bec printk: enable interrupts before calling console_trylock_for_printk()
Date: Mon, 30 Jun 2014 13:20:30 -0700	[thread overview]
Message-ID: <20140630132030.fa6ac8c8f040e6f5b05071f3@linux-foundation.org> (raw)
In-Reply-To: <20140628225050.GA3484@amos.fritz.box>

On Sun, 29 Jun 2014 00:50:50 +0200 Andreas Bombe <aeb@debian.org> wrote:

> None of the post 3.15 kernel boot for me. They all hang at the GRUB
> screen telling me it loaded and started the kernel, but the kernel
> itself stops before it prints anything (or even replaces the GRUB
> background graphics).
> 
> I bisected it down to 939f04bec1a4ef6ba4370b0f34b01decc844b1b1 "printk:
> enable interrupts before calling console_trylock_for_printk()".
> Reverting that patch on the latest kernel (git 24b414d5a7) allows me to
> boot normally.

OK, thanks, I queued the below reversion.  I'll hold off for a week or
two in case we come up with a fix.

> I fixed the conflict in the revert by leaving in the "if
> (in_sched) return printed_len;".

hm, that might have been buggy - we still need to the lockdep_on() and
local_irq_restore().  You're a victim of
someone-stuck-a-random-return-in-the-middle-of-a-function.

Please review this and if possible, run-time test it?  Against current
mainline.


From: Andrew Morton <akpm@linux-foundation.org>
Subject: kernel/printk/printk.c: revert "printk: enable interrupts before calling console_trylock_for_printk()"

Revert 939f04bec1a4 ("printk: enable interrupts before calling
console_trylock_for_printk()").

Andreas reported:

: None of the post 3.15 kernel boot for me. They all hang at the GRUB
: screen telling me it loaded and started the kernel, but the kernel
: itself stops before it prints anything (or even replaces the GRUB
: background graphics).

939f04bec1a4 is modest latency reduction.  Revert it until we understand
the reason for these failures.

Reported-by: Andreas Bombe <aeb@debian.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/printk/printk.c |   44 +++++++++++++++------------------------
 1 file changed, 18 insertions(+), 26 deletions(-)

diff -puN kernel/printk/printk.c~kernel-printk-printkc-revert-printk-enable-interrupts-before-calling-console_trylock_for_printk kernel/printk/printk.c
--- a/kernel/printk/printk.c~kernel-printk-printkc-revert-printk-enable-interrupts-before-calling-console_trylock_for_printk
+++ a/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(unsign
  * 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
 		 */
 		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
 
 	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);
_


  reply	other threads:[~2014-06-30 20:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-28 22:50 Andreas Bombe
2014-06-30 20:20 ` Andrew Morton [this message]
2014-07-03  0:57   ` Andreas Bombe
2014-07-14  8:35 ` Jan Kara
2014-07-16 21:34   ` Andreas Bombe
2014-07-17  8:31     ` Jan Kara
2014-07-18 22:50       ` Andreas Bombe
2014-07-21 10:04         ` Jan Kara
2014-07-22 23:29           ` Andreas Bombe
2014-07-23  7:43             ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140630132030.fa6ac8c8f040e6f5b05071f3@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=aeb@debian.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome