[Devel] [PATCH RHEL COMMIT] vtty: update termios settings and fix hung

Konstantin Khorenko khorenko at virtuozzo.com
Tue Oct 12 14:01:22 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 1f8fc1147bf50c9264e75bec27086fa755a5f81c
Author: Cyrill Gorunov <gorcunov at virtuozzo.com>
Date:   Tue Oct 12 14:01:11 2021 +0300

    vtty: update termios settings and fix hung
    
    Here are some things left to be updated while moving to a new kernel:
    
     - setup default limit for ports up to 8192 bytes just like it done
       for regular unix PTY driver
     - report exactly how many bytes left available in the peer buffer
       (actually I don't remember where this 2K constant came from, maybe
        from early console or systemd specific in some old version we will
        figure out drawbacks once deep testing get started)
     - update termios settings to match unix PTY
     - drop chars_in_buffer operation since it is just makes a loop eating
       100% cpu upon start, seems like been occasionally sneaked in from
       previous kernels
    
    https://jira.sw.ru/browse/PSBM-134658
    
    Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 drivers/tty/pty.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 44089615f946..7d33bce95a36 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -765,6 +765,7 @@ static void vtty_standard_install(struct tty_driver *driver,
 
 	tty_driver_kref_get(driver);
 	tty_port_init(tty->port);
+	tty_buffer_set_limit(tty->port, 8192);
 	tty->port->itty = tty;
 }
 
@@ -880,14 +881,10 @@ static int vtty_write(struct tty_struct *tty,
 static unsigned int vtty_write_room(struct tty_struct *tty)
 {
 	struct tty_struct *peer = tty->link;
-	int count = (tty->driver == vttym_driver) ? 2 : 1;
 
 	if (tty->flow.stopped)
 		return 0;
 
-	if (peer->count < count)
-		return 2048;
-
 	return tty_buffer_space_avail(peer->port);
 }
 
@@ -911,7 +908,6 @@ static const struct tty_operations vtty_ops = {
 	.cleanup	= pty_cleanup,
 	.write		= vtty_write,
 	.write_room	= vtty_write_room,
-	.chars_in_buffer= tty_chars_in_buffer,
 	.set_termios	= pty_set_termios,
 	.unthrottle	= pty_unthrottle,
 	.flush_buffer	= pty_flush_buffer,
@@ -998,6 +994,8 @@ static int __init vtty_init(void)
 	/* 38400 boud rate, 8 bit char size, enable receiver */
 	vttym_driver->init_termios.c_cflag	= B38400 | CS8 | CREAD;
 	vttym_driver->init_termios.c_lflag	= 0;
+	vttym_driver->init_termios.c_ispeed	= 38400;
+	vttym_driver->init_termios.c_ospeed	= 38400;
 	tty_set_operations(vttym_driver, &vtty_ops);
 
 	vttys_driver->driver_name		= "vtty_slave";
@@ -1009,6 +1007,8 @@ static int __init vtty_init(void)
 	vttys_driver->subtype			= PTY_TYPE_SLAVE;
 	vttys_driver->init_termios		= tty_std_termios;
 	vttys_driver->init_termios.c_cflag	= B38400 | CS8 | CREAD;
+	vttys_driver->init_termios.c_ispeed	= 38400;
+	vttys_driver->init_termios.c_ospeed	= 38400;
 	tty_set_operations(vttys_driver, &vtty_ops);
 
 	if (tty_register_driver(vttym_driver))


More information about the Devel mailing list