mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>, Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [RFC][PATCH 2/2] printk: take console_sem when accessing console drivers list
Date: Thu, 25 Apr 2019 15:47:41 +0900	[thread overview]
Message-ID: <20190425064741.GB27270@jagdpanzerIV> (raw)
In-Reply-To: <20190425051944.GB8532@jagdpanzerIV>

On (04/25/19 14:19), Sergey Senozhatsky wrote:
> 
> So may be we can move the whole thing under console_sem.
> 

Something like below. I'll re-spin the series in a day or two,
we have time.

---
 kernel/printk/printk.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 52d1123d9fdc..0c2eb161e793 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2666,7 +2666,7 @@ static int __unregister_console(struct console *console)
  *  - Once a "real" console is registered, any attempt to register a
  *    bootconsoles will be rejected
  */
-void register_console(struct console *newcon)
+static void __register_console(struct console *newcon)
 {
 	int i;
 	unsigned long flags;
@@ -2771,7 +2771,6 @@ void register_console(struct console *newcon)
 	 *	Put this console in the list - keep the
 	 *	preferred driver at the head of the list.
 	 */
-	console_lock();
 	if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) {
 		newcon->next = console_drivers;
 		console_drivers = newcon;
@@ -2820,19 +2819,25 @@ void register_console(struct console *newcon)
 
 	console_unlock();
 	console_sysfs_notify();
+	console_lock();
 
 	if (keep_bootcon)
 		return;
 
 	if (bcon && (newcon->flags & (CON_CONSDEV|CON_BOOT)) == CON_CONSDEV) {
-		console_lock();
 		for_each_console(bcon)
 			if (bcon->flags & CON_BOOT)
 				__unregister_console(bcon);
-		console_unlock();
-		console_sysfs_notify();
 	}
 }
+
+void register_console(struct console *newcon)
+{
+	console_lock();
+	__register_console(newcon);
+	console_unlock();
+	console_sysfs_notify();
+}
 EXPORT_SYMBOL(register_console);
 
 int unregister_console(struct console *console)
-- 
2.21.0

  reply	other threads:[~2019-04-25  6:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23  6:25 [RFC][PATCH 0/2] Access console drivers list under console_sem Sergey Senozhatsky
2019-04-23  6:25 ` [RFC][PATCH 1/2] printk: lock console_sem before we unregister boot consoles Sergey Senozhatsky
2019-04-24 14:49   ` Petr Mladek
2019-04-25  3:52     ` Sergey Senozhatsky
2019-04-25  6:43       ` Sergey Senozhatsky
2019-04-25  9:20         ` Petr Mladek
2019-04-25 16:05           ` Steven Rostedt
2019-04-25  7:50       ` Petr Mladek
2019-04-25  7:56         ` Sergey Senozhatsky
2019-04-25  9:37           ` Sergey Senozhatsky
2019-04-23  6:25 ` [RFC][PATCH 2/2] printk: take console_sem when accessing console drivers list Sergey Senozhatsky
2019-04-24 15:13   ` Petr Mladek
2019-04-25  5:19     ` Sergey Senozhatsky
2019-04-25  6:47       ` Sergey Senozhatsky [this message]
2019-04-25  8:53       ` Petr Mladek
2019-04-23 13:48 ` [RFC][PATCH 0/2] Access console drivers list under console_sem Steven Rostedt
2019-04-24  5:43   ` Sergey Senozhatsky

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=20190425064741.GB27270@jagdpanzerIV \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    /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

all inboxes | Powered by JetHome®