Linux-kernel mailing list archive 2000-29,: Re: Race in n_tty.c write_chan()

# Re: Race in n_tty.c write_chan()

Al Borchers (alborchers@steinerpoint.com)
Tue, 18 Jul 2000 11:59:45 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Aaron Macks: "image for sparc"
- Previous message: Manfred Spraul: "Re: [patch-2.4.0-test5-pre1] nullfs and forced umount"

Andrea --

This patch is now in 2.2.17--thanks--but it has not shown up in 2.4.0
yet. Can we get this patch 2.4.0, too? It would help out the USB
serial drivers where this race is a problem--we can work around it
mostly but the workaround is not ideal.

Thanks alot,
-- Al Borchers

Andrea Arcangeli wrote:
>
> On Wed, 28 Jun 2000, Al Borchers wrote:
>
> >Our fix corrects the problem on UP, but theoretically (I think) there
> >is still a race on SMP. We have not actually seen the problem in our
> >testing on SMP, however.
>
> Good spotting. This below is the right fix for 2.2.16pre6. Taking page
> faults with the task in interruptible state is safe. Linus only suggested
> to split schedule() in two parts so that in the low-latency patch (in
> things like the _necessary_ [but still actually missing!] low-latency
> checks in the copy-user stuff) instead of doing:
>
> if (current->need_resched) {
> current->state = TASK_RUNNING;
> schedule();
> }
>
> we could do something of faster like:
>
> if (current->need_resched)
> __schedule_core();
>
> --- 2.2.17pre6aa2/drivers/char/n_tty.c Tue Jun 13 03:48:13 2000
> +++ 2.2.14/drivers/char/n_tty.c Mon Jan 17 16:44:37 2000
> @@ -1142,9 +1094,7 @@
> nr -= num;
> if (nr == 0)
> break;
> - current->state = TASK_RUNNING;
> get_user(c, b);
> - current->state = TASK_INTERRUPTIBLE;
> if (opost(c, tty) < 0)
> break;
> b++; nr--;
> @@ -1152,9 +1102,7 @@
> if (tty->driver.flush_chars)
> tty->driver.flush_chars(tty);
> } else {
> - current->state = TASK_RUNNING;
> c = tty->driver.write(tty, 1, b, nr);
> - current->state = TASK_INTERRUPTIBLE;
> if (c < 0) {
> retval = c;
> goto break_out;
>
> Andrea

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

- Next message: Aaron Macks: "image for sparc"
- Previous message: Manfred Spraul: "Re: [patch-2.4.0-test5-pre1] nullfs and forced umount"