con_open() is called on every open of the tty, even if the tty is already all set up. We only need to do that initialisation if the tty is being set up for the very first time (tty->count == 1). So do that: check for tty_count == 1 inside console_sem() and if so, bypass all the unnecessary initialisation. Note that this patch reintroduces the con_close()-vs-init_dev() race+oops. This is because that oops is accidentally prevented because when it happens, con_open() reinstalls tty->driver_data even when tty->count > 1. But that's bogus, and when the race happens we end up running vcs_make_devfs() and vcs_remove_devfs() against the same console at the same time, producing indeterminate results. So the race needs to be fixed again, for real. --- 25-akpm/drivers/char/vt.c | 40 +++++++++++++++++++--------------------- 1 files changed, 19 insertions(+), 21 deletions(-) diff -puN drivers/char/vt.c~con_open-speedup drivers/char/vt.c --- 25/drivers/char/vt.c~con_open-speedup 2004-04-03 02:59:46.074348576 -0800 +++ 25-akpm/drivers/char/vt.c 2004-04-03 02:59:46.079347816 -0800 @@ -2454,32 +2454,30 @@ static void con_flush_chars(struct tty_s /* * Allocate the console screen memory. */ -static int con_open(struct tty_struct *tty, struct file * filp) +static int con_open(struct tty_struct *tty, struct file *filp) { - unsigned int currcons; - int i; - - currcons = tty->index; + unsigned int currcons = tty->index; + int ret = 0; acquire_console_sem(); - i = vc_allocate(currcons); - if (i) { - release_console_sem(); - return i; + if (tty->count == 1) { + ret = vc_allocate(currcons); + if (ret == 0) { + vt_cons[currcons]->vc_num = currcons; + tty->driver_data = vt_cons[currcons]; + vc_cons[currcons].d->vc_tty = tty; + + if (!tty->winsize.ws_row && !tty->winsize.ws_col) { + tty->winsize.ws_row = video_num_lines; + tty->winsize.ws_col = video_num_columns; + } + release_console_sem(); + vcs_make_devfs(tty); + return ret; + } } - vt_cons[currcons]->vc_num = currcons; - tty->driver_data = vt_cons[currcons]; - vc_cons[currcons].d->vc_tty = tty; - release_console_sem(); - - if (!tty->winsize.ws_row && !tty->winsize.ws_col) { - tty->winsize.ws_row = video_num_lines; - tty->winsize.ws_col = video_num_columns; - } - if (tty->count == 1) - vcs_make_devfs(tty); - return 0; + return ret; } static void con_close(struct tty_struct *tty, struct file *filp) _