summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0010-console-Improve-console_srcu_read_flags-comments.patch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:11:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:11:49 +0000
commitf25552c1068a054f2d99afd67a671d5991bf19c1 (patch)
treed70de5c7262ad572f8323fc4184b8a10522e81ec /debian/patches-rt/0010-console-Improve-console_srcu_read_flags-comments.patch
parentMerging upstream version 6.9.7. (diff)
downloadlinux-f25552c1068a054f2d99afd67a671d5991bf19c1.tar.xz
linux-f25552c1068a054f2d99afd67a671d5991bf19c1.zip
Merging debian version 6.9.7-1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches-rt/0010-console-Improve-console_srcu_read_flags-comments.patch')
-rw-r--r--debian/patches-rt/0010-console-Improve-console_srcu_read_flags-comments.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/debian/patches-rt/0010-console-Improve-console_srcu_read_flags-comments.patch b/debian/patches-rt/0010-console-Improve-console_srcu_read_flags-comments.patch
new file mode 100644
index 0000000000..ea346ac04c
--- /dev/null
+++ b/debian/patches-rt/0010-console-Improve-console_srcu_read_flags-comments.patch
@@ -0,0 +1,72 @@
+From: John Ogness <john.ogness@linutronix.de>
+Date: Wed, 17 Apr 2024 14:34:50 +0000
+Subject: [PATCH 10/46] console: Improve console_srcu_read_flags() comments
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.9/older/patches-6.9-rt5.tar.xz
+
+It was not clear when exactly console_srcu_read_flags() must be
+used vs. directly reading @console->flags.
+
+Refactor and clarify that console_srcu_read_flags() is only
+needed if the console is registered or the caller is in a
+context where the registration status of the console may change
+(due to another context).
+
+The function requires the caller holds @console_srcu, which will
+ensure that the caller sees an appropriate @flags value for the
+registered console and that exit/cleanup routines will not run
+if the console is in the process of unregistration.
+
+Signed-off-by: John Ogness <john.ogness@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ include/linux/console.h | 28 +++++++++++++++++-----------
+ 1 file changed, 17 insertions(+), 11 deletions(-)
+
+--- a/include/linux/console.h
++++ b/include/linux/console.h
+@@ -446,28 +446,34 @@ extern void console_list_unlock(void) __
+ extern struct hlist_head console_list;
+
+ /**
+- * console_srcu_read_flags - Locklessly read the console flags
++ * console_srcu_read_flags - Locklessly read flags of a possibly registered
++ * console
+ * @con: struct console pointer of console to read flags from
+ *
+- * This function provides the necessary READ_ONCE() and data_race()
+- * notation for locklessly reading the console flags. The READ_ONCE()
+- * in this function matches the WRITE_ONCE() when @flags are modified
+- * for registered consoles with console_srcu_write_flags().
++ * Locklessly reading @con->flags provides a consistent read value because
++ * there is at most one CPU modifying @con->flags and that CPU is using only
++ * read-modify-write operations to do so.
+ *
+- * Only use this function to read console flags when locklessly
+- * iterating the console list via srcu.
++ * Requires console_srcu_read_lock to be held, which implies that @con might
++ * be a registered console. The purpose of holding console_srcu_read_lock is
++ * to guarantee that the console state is valid (CON_SUSPENDED/CON_ENABLED)
++ * and that no exit/cleanup routines will run if the console is currently
++ * undergoing unregistration.
++ *
++ * If the caller is holding the console_list_lock or it is _certain_ that
++ * @con is not and will not become registered, the caller may read
++ * @con->flags directly instead.
+ *
+ * Context: Any context.
++ * Return: The current value of the @con->flags field.
+ */
+ static inline short console_srcu_read_flags(const struct console *con)
+ {
+ WARN_ON_ONCE(!console_srcu_read_lock_is_held());
+
+ /*
+- * Locklessly reading console->flags provides a consistent
+- * read value because there is at most one CPU modifying
+- * console->flags and that CPU is using only read-modify-write
+- * operations to do so.
++ * The READ_ONCE() matches the WRITE_ONCE() when @flags are modified
++ * for registered consoles with console_srcu_write_flags().
+ */
+ return data_race(READ_ONCE(con->flags));
+ }