[Devel] [PATCH RHEL7 COMMIT] ms/tty: Make lock subclasses available for other tty locks
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Aug 1 12:32:02 MSK 2022
The commit is pushed to "branch-rh7-3.10.0-1160.66.1.vz7.188.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.66.1.vz7.188.8
------>
commit b060d6d6ebce72c069ddf7d2956d583256fecc0c
Author: Peter Hurley <peter at hurleysoftware.com>
Date: Sat Jan 17 15:42:04 2015 -0500
ms/tty: Make lock subclasses available for other tty locks
Besides nested legacy_mutex locking which is required on pty pair
teardown, other nested pty operations require lock subclassing.
Move lock subclass definition to tty interface header, include/linux/tty.h,
and document its use.
Signed-off-by: Peter Hurley <peter at hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
(cherry picked from ms commit 3abf87cd3e70009ed70a7f28c2914888a7e27332)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
TODO: this commit to be put before
26d84bd065b16 ("vtty: fix slave peer lockdep annotation")
---
drivers/tty/tty_mutex.c | 12 +-----------
include/linux/tty.h | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c
index 6db7b33cfae04..cff304abb619a 100644
--- a/drivers/tty/tty_mutex.c
+++ b/drivers/tty/tty_mutex.c
@@ -4,18 +4,8 @@
#include <linux/semaphore.h>
#include <linux/sched.h>
-/*
- * Nested tty locks are necessary for releasing pty pairs.
- * The stable lock order is master pty first, then slave pty.
- */
-
/* Legacy tty mutex glue */
-enum {
- TTY_MUTEX_NORMAL,
- TTY_MUTEX_SLAVE,
-};
-
/*
* Getting the big tty mutex.
*/
@@ -71,5 +61,5 @@ void __lockfunc tty_unlock_slave(struct tty_struct *tty)
void tty_set_lock_subclass(struct tty_struct *tty)
{
- lockdep_set_subclass(&tty->legacy_mutex, TTY_MUTEX_SLAVE);
+ lockdep_set_subclass(&tty->legacy_mutex, TTY_LOCK_SLAVE);
}
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 888750809c1f7..50ca243894177 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -13,6 +13,23 @@
#include <linux/rwsem.h>
+/*
+ * Lock subclasses for tty locks
+ *
+ * TTY_LOCK_NORMAL is for normal ttys and master ptys.
+ * TTY_LOCK_SLAVE is for slave ptys only.
+ *
+ * Lock subclasses are necessary for handling nested locking with pty pairs.
+ * tty locks which use nested locking:
+ *
+ * legacy_mutex - Nested tty locks are necessary for releasing pty pairs.
+ * The stable lock order is master pty first, then slave pty.
+ */
+
+enum {
+ TTY_LOCK_NORMAL = 0,
+ TTY_LOCK_SLAVE,
+};
/*
* (Note: the *_driver.minor_start values 1, 64, 128, 192 are
More information about the Devel
mailing list