[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220910222300.783722057@linutronix.de>
Date: Sun, 11 Sep 2022 00:27:42 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: John Ogness <john.ogness@...utronix.de>,
Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Linus Torvalds <torvalds@...uxfoundation.org>,
Peter Zijlstra <peterz@...radead.org>,
"Paul E. McKenney" <paulmck@...nel.org>,
Daniel Vetter <daniel@...ll.ch>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Helge Deller <deller@....de>,
Jason Wessel <jason.wessel@...driver.com>,
Daniel Thompson <daniel.thompson@...aro.org>
Subject: [patch RFC 07/29] printk: Convert console list walks for readers to list lock
Facilities which expose console information to sysfs or procfs can use the
new list protection to keep the list stable. No need to hold console lock.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
drivers/tty/tty_io.c | 6 +++---
fs/proc/consoles.c | 6 +++---
kernel/printk/printk.c | 8 ++++----
3 files changed, 10 insertions(+), 10 deletions(-)
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3535,8 +3535,8 @@ static ssize_t show_cons_active(struct d
struct console *c;
ssize_t count = 0;
- console_lock();
- for_each_console(c) {
+ console_list_lock();
+ for_each_registered_console(c) {
if (!c->device)
continue;
if (!c->write)
@@ -3560,7 +3560,7 @@ static ssize_t show_cons_active(struct d
count += sprintf(buf + count, "%c", i ? ' ':'\n');
}
- console_unlock();
+ console_list_unlock();
return count;
}
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -63,8 +63,8 @@ static void *c_start(struct seq_file *m,
struct console *con;
loff_t off = 0;
- console_lock();
- for_each_console(con)
+ console_list_lock();
+ for_each_registered_console(con)
if (off++ == *pos)
break;
@@ -80,7 +80,7 @@ static void *c_next(struct seq_file *m,
static void c_stop(struct seq_file *m, void *v)
{
- console_unlock();
+ console_list_unlock();
}
static const struct seq_operations consoles_op = {
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2985,18 +2985,18 @@ void console_flush_on_panic(enum con_flu
*/
struct tty_driver *console_device(int *index)
{
- struct console *c;
struct tty_driver *driver = NULL;
+ struct console *c;
- console_lock();
- for_each_console(c) {
+ console_list_lock();
+ for_each_registered_console(c) {
if (!c->device)
continue;
driver = c->device(c, index);
if (driver)
break;
}
- console_unlock();
+ console_list_unlock();
return driver;
}
Powered by blists - more mailing lists