[patch] sched, tty: fix scheduling latencies in tty_io.c

From: Ingo Molnar
Date: Tue Sep 14 2004 - 06:32:49 EST



the attached patch fixes long scheduling latencies in tty_read() and
tty_write() caused by the BKL.

has been tested as part of the -VP patchset and the tty_read() side
has also been tested in earlier -mm trees.

Ingo

the attached patch fixes long scheduling latencies in tty_read() and
tty_write() caused by the BKL.

has been tested as part of the -VP patchset and the tty_read() side
has also been tested in earlier -mm trees.

Signed-off-by: Ingo Molnar <mingo@xxxxxxx>

--- linux/drivers/char/tty_io.c.orig
+++ linux/drivers/char/tty_io.c
@@ -660,12 +660,10 @@ static ssize_t tty_read(struct file * fi
if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags)))
return -EIO;

- lock_kernel();
if (tty->ldisc.read)
i = (tty->ldisc.read)(tty,file,buf,count);
else
i = -EIO;
- unlock_kernel();
if (i > 0)
inode->i_atime = CURRENT_TIME;
return i;
@@ -688,17 +686,13 @@ static inline ssize_t do_tty_write(
return -ERESTARTSYS;
}
if ( test_bit(TTY_NO_WRITE_SPLIT, &tty->flags) ) {
- lock_kernel();
written = write(tty, file, buf, count);
- unlock_kernel();
} else {
for (;;) {
unsigned long size = max((unsigned long)PAGE_SIZE*2, 16384UL);
if (size > count)
size = count;
- lock_kernel();
ret = write(tty, file, buf, size);
- unlock_kernel();
if (ret <= 0)
break;
written += ret;