From: John Ogness <john.ogness@linutronix.de>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH printk v2 36/38] proc: consoles: use console_list_lock for list iteration
Date: Wed, 19 Oct 2022 17:01:58 +0206 [thread overview]
Message-ID: <20221019145600.1282823-37-john.ogness@linutronix.de> (raw)
In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de>
The console_lock is used in part to guarantee safe list iteration.
The console_list_lock should be used because list synchronization
repsponsibility will be removed from the console_lock in a later
change.
Note, the console_lock is still needed to stop console printing.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
fs/proc/consoles.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c
index 32512b477605..77409b176569 100644
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -33,7 +33,15 @@ static int show_console_dev(struct seq_file *m, void *v)
if (con->device) {
const struct tty_driver *driver;
int index;
+
+ /*
+ * Stop console printing because the device() callback may
+ * assume the console is not within its write() callback.
+ */
+ console_lock();
driver = con->device(con, &index);
+ console_unlock();
+
if (driver) {
dev = MKDEV(driver->major, driver->minor_start);
dev += index;
@@ -64,14 +72,11 @@ static void *c_start(struct seq_file *m, loff_t *pos)
loff_t off = 0;
/*
- * Stop console printing because the device() callback may
- * assume the console is not within its write() callback.
- *
- * Hold the console_lock to guarantee safe traversal of the
+ * Hold the console_list_lock to guarantee safe traversal of the
* console list. SRCU cannot be used because there is no
* place to store the SRCU cookie.
*/
- console_lock();
+ console_list_lock();
for_each_console(con)
if (off++ == *pos)
break;
@@ -89,7 +94,7 @@ static void *c_next(struct seq_file *m, void *v, loff_t *pos)
static void c_stop(struct seq_file *m, void *v)
{
- console_unlock();
+ console_list_unlock();
}
static const struct seq_operations consoles_op = {
--
2.30.2
next prev parent reply other threads:[~2022-10-19 15:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 14:55 [PATCH printk v2 00/38] reduce console_lock scope John Ogness
2022-10-19 14:55 ` [PATCH printk v2 02/38] printk: Convert console_drivers list to hlist John Ogness
2022-10-19 15:44 ` Greg Kroah-Hartman
2022-10-19 21:46 ` John Ogness
2022-10-20 7:43 ` Greg Kroah-Hartman
2022-10-20 12:36 ` Petr Mladek
2022-10-24 5:23 ` Sergey Senozhatsky
2022-10-19 14:55 ` [PATCH printk v2 25/38] proc: consoles: document console_lock usage John Ogness
2022-10-25 14:40 ` Petr Mladek
2022-10-19 14:55 ` John Ogness [this message]
2022-10-27 12:02 ` [PATCH printk v2 36/38] proc: consoles: use console_list_lock for list iteration Petr Mladek
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=20221019145600.1282823-37-john.ogness@linutronix.de \
--to=john.ogness@linutronix.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).