public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ryan Arnold <rsa@us.ibm.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>, "Theodore Ts'o" <tytso@mit.edu>
Subject: Re: [PATCH] hvc_console fix to protect hvc_write against ldisc write after hvc_close
Date: Wed, 15 Sep 2004 16:23:02 -0500	[thread overview]
Message-ID: <1095283382.3294.349.camel@localhost> (raw)
In-Reply-To: <1095276020.20569.2.camel@localhost.localdomain>

On Wed, 2004-09-15 at 14:20, Alan Cox wrote:
> Actually for the short term I may have made the ldisc calling tty race
> worse. I'm still looking into some of that. I've fixed the one the other
> way but for now driver defensively 8)

Alan, thanks for the heads up, and thanks for the work on the ldisc code
it is MUCH appreciated.

While we're looking at the ldisc code; I am a bit disturbed by how easy
it is to tty_flip_buffer_push() and silently lose data.  The ldisc
function n_tty_receive_buf() which is normally scheduled as delayed work
via the tty_flip_buffer_push() operation simply overwrites the contents
of the circular tty->read_buf leading to dataloss and out of order
output if too much data is pushed too quickly.

The manual accounting of pushed data is very tricky to do when the
pushing thread isn't sure of when the line discipline will actually
schedule the n_tty_receive_buf() operation.  I think that the tty
throttle() & unthrottle api is supposed to help with this but it is
possible (and in my experience was common) that the throttle callback
would happen AFTER data has already been lost.

Many of us tty driver writers resort to setting tty->low_latency = 1
which synchronizes the n_tty_receive_buf() call to be executed in the
same thread as that which invoked tty_flip_buffer_push() such that we
know when a throttle happens we haven't yet lost data.

I don't know when tty->low_latency is really appropriate to use but it
solves my problems.  I've heard people say that tty data delivery is
inherently unreliable.  This doesn't make sense to me because imho tty
data is very important.  I hope I'm not approaching this topic of
flip_buffer_pushing and throttling from a mistaken assumption.

Thanks,

Ryan S. Arnold
Linux Technology Center


  reply	other threads:[~2004-09-15 21:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-15 18:43 [PATCH] hvc_console fix to protect hvc_write against ldisc write after hvc_close Ryan Arnold
2004-09-15 19:20 ` Alan Cox
2004-09-15 21:23   ` Ryan Arnold [this message]
2004-09-15 20:41 ` Theodore Ts'o
2004-09-15 21:36   ` Alan Cox
2004-09-15 22:35   ` Ryan Arnold
2004-09-24  1:15   ` ldisc writes during tty release_dev() causing problems Ryan Arnold
2004-09-24 12:40     ` Alan Cox
2004-09-24 16:18       ` Ryan Arnold
2004-09-24 15:30         ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1095283382.3294.349.camel@localhost \
    --to=rsa@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox