All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: n_tty.c driver patch (semantic and performance correction) (a ll recent versions)
@ 2002-06-26 17:48 Ed Vance
  2002-06-26 20:42 ` Russell King
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Ed Vance @ 2002-06-26 17:48 UTC (permalink / raw)
  To: 'rwhite@pobox.com', 'Theodore Tso',
	'Russell King'
  Cc: linux-kernel, linux-serial

Hi Robert,

On Sat, June 15, 2002, Robert White wrote:
> 
> The n_tty line discipline module contains a "semantic error" 
> that limits its speed and usefullness in many uses.  The 
> attached patch directly addresses serial performance in a 
> completely backwards-compatable way.
> 
> In particular, the current handling of VMIN hugely limits, 
> complicates, and/or slows down optimal serial use.  The most 
> obvius example is that if you call read(2) with a buffer size 
> less than the current value of VMIN, the line discipline will 
> insist that the read call wait for characters that can not be 
> returned to that call.  The POSIX standard is silent on the 
> subject of whether this is right or wrong.  Common sense says 
> it is wrong.
> 

Ten years ago, I would have agreed with you. I suggested a very 
similar change for VTIME=0;VMIN>0 behavior back then, while we 
were porting SVR4 to proprietary hardware. This was for 
compatibility with the way reads were handled on a previous 
non-un*x product. It was deemed a spec violation, so we added an 
ioctl to implement the compatible behavior. 

Does the spec say that VMIN behavior depends on the size of a 
blocking read? No, it says that the read completes when VMIN or 
more characters have been received. If VMIN is three and two 
characters have been received, completing a blocking read of any 
size is a violation. Should we also add a "read buffer size" 
parameter to select and poll, etc. so they can report that read 
data is available before satisfying VMIN, too? 

Ted, Russell, please weigh in on this. 

Best regards,
Ed

---------------------------------------------------------------- 
Ed Vance              edv@macrolink.com
Macrolink, Inc.       1500 N. Kellogg Dr  Anaheim, CA  92807
----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: n_tty.c driver patch (semantic and performance correction) (a ll recent versions)
@ 2002-07-31 16:58 Ed Vance
  0 siblings, 0 replies; 28+ messages in thread
From: Ed Vance @ 2002-07-31 16:58 UTC (permalink / raw)
  To: 'David Lawyer'
  Cc: linux-serial, 'linux-kernel@vger.kernel.org'

Hi David,

On Tue, July 30, 2002 at 10:32 PM, David Lawyer wrote:
> On Tue, Jul 30, 2002 at 10:07:51AM -0700, Ed Vance wrote:
> > On Sat, July 27, 2002 at 8:02 PM, stevie@qrpff.net wrote:
> > > 
> > > But... but... the standard says...
> > > 
> > >    A pending read shall not be satisfied until MIN bytes are 
> > >    received (that is, the pending read shall block until MIN 
> > >    bytes are received), or a signal is received.
> > > 
> > > And because I'm too dead-set on doing it that way solely because 
> > > that's how it's always been done, I won't ever consider changing it. 

 [ snip ] 

> > Stevie O gets to the central issue here. Why _not_ change long-existing,
> > widely used interfaces in subtle ways because the old way makes no 
> > sense to us and the new way does? Is standards-based programming a 
> > lemming behavior? 

 [ snip ]

> > As I said before, innovation is fine. Just don't pollute the existing
> > interfaces. If even one real customer running real work has bad day 
> > because of exposure of an old app bug or an unanticipated consequence 
> > of the change, then it wasn't worth ignoring safer implementation 
> > practices. One can't attain 100% safety, but one _can_ minimize the 
> > risk. 
> 
> I think it's very important for Linux to be efficient so that it will
> work well on old hardware, etc.  

I agree 100% so far.

>                                 What's being proposed seems to help.
> So I think that if there is a low probability that it will break any
> existing application where non-trivial harm will be caused, then I would
> favor innovation (actually common sense in this case).  

I don't agree that we have a trade off, here. (big surprise? :) We are
simply asking the wrong question in the quest to achieve the desired
benefit. We are asking how to deviate from the standard to get better
performance. We should be asking how to change the kernel to get better
performance without changing the standard app interface. Of course, making
the standard (but rather uninspired) app interface work efficiently is a
_lot_ more technically challenging. 

>                                                        Also someone
> should try to get the standards modified to clearly allow what's
> proposed.

Good luck with that. ;)

BTW, I am hypersensitive to this issue because I got bit by Mot V/88 that
had a buggy MIN and TIME implementation. My phone ran flames for about a
month because of my initial decision to match their quirky interface
behavior in my serial card's driver. 

Best regards,
Ed

---------------------------------------------------------------- 
Ed Vance              edv@macrolink.com
Macrolink, Inc.       1500 N. Kellogg Dr  Anaheim, CA  92807
----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: n_tty.c driver patch (semantic and performance correction) (a ll recent versions)
@ 2002-07-31 16:58 Ed Vance
  0 siblings, 0 replies; 28+ messages in thread
From: Ed Vance @ 2002-07-31 16:58 UTC (permalink / raw)
  To: 'David Lawyer'
  Cc: linux-serial, 'linux-kernel@vger.kernel.org'

Hi David,

On Tue, July 30, 2002 at 10:32 PM, David Lawyer wrote:
> On Tue, Jul 30, 2002 at 10:07:51AM -0700, Ed Vance wrote:
> > On Sat, July 27, 2002 at 8:02 PM, stevie@qrpff.net wrote:
> > > 
> > > But... but... the standard says...
> > > 
> > >    A pending read shall not be satisfied until MIN bytes are 
> > >    received (that is, the pending read shall block until MIN 
> > >    bytes are received), or a signal is received.
> > > 
> > > And because I'm too dead-set on doing it that way solely because 
> > > that's how it's always been done, I won't ever consider changing it. 

 [ snip ] 

> > Stevie O gets to the central issue here. Why _not_ change long-existing,
> > widely used interfaces in subtle ways because the old way makes no 
> > sense to us and the new way does? Is standards-based programming a 
> > lemming behavior? 

 [ snip ]

> > As I said before, innovation is fine. Just don't pollute the existing
> > interfaces. If even one real customer running real work has bad day 
> > because of exposure of an old app bug or an unanticipated consequence 
> > of the change, then it wasn't worth ignoring safer implementation 
> > practices. One can't attain 100% safety, but one _can_ minimize the 
> > risk. 
> 
> I think it's very important for Linux to be efficient so that it will
> work well on old hardware, etc.  

I agree 100% so far.

>                                 What's being proposed seems to help.
> So I think that if there is a low probability that it will break any
> existing application where non-trivial harm will be caused, then I would
> favor innovation (actually common sense in this case).  

I don't agree that we have a trade off, here. (big surprise? :) We are
simply asking the wrong question in the quest to achieve the desired
benefit. We are asking how to deviate from the standard to get better
performance. We should be asking how to change the kernel to get better
performance without changing the standard app interface. Of course, making
the standard (but rather uninspired) app interface work efficiently is a
_lot_ more technically challenging. 

>                                                        Also someone
> should try to get the standards modified to clearly allow what's
> proposed.

Good luck with that. ;)

BTW, I am hypersensitive to this issue because I got bit by Mot V/88 that
had a buggy MIN and TIME implementation. My phone ran flames for about a
month because of my initial decision to match their quirky interface
behavior in my serial card's driver. 

Best regards,
Ed

---------------------------------------------------------------- 
Ed Vance              edv@macrolink.com
Macrolink, Inc.       1500 N. Kellogg Dr  Anaheim, CA  92807
----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: n_tty.c driver patch (semantic and performance correction) (a ll recent versions)
@ 2002-07-30 17:07 Ed Vance
  0 siblings, 0 replies; 28+ messages in thread
From: Ed Vance @ 2002-07-30 17:07 UTC (permalink / raw)
  To: rwhite, 'Stevie O'
  Cc: Russell King, Ed Vance, 'Theodore Tso',
	linux-kernel, linux-serial

On Sat, July 27, 2002 at 8:02 PM, stevie@qrpff.net wrote:
> 
> But... but... the standard says...
> 
>    A pending read shall not be satisfied until MIN bytes are 
>    received (that is, the pending read shall block until MIN 
>    bytes are received), or a signal is received.
> 
> And because I'm too dead-set on doing it that way solely because 
> that's how it's always been done, I won't ever consider changing it.  
> I'll blindly ignore how much xmodem transfers suck, and the fact 
> that I can come up with no practical purpose at all for this feature, 
> and just repeat what the standard says.  Why should we obey what 
> Linux man pages say? What do the Linux man pages have to do with 
> Linux?
> 
> Remember: Computers and their programs aren't here to make our lives 
> easier, or to make tasks simpler. They are here to follow standards.

Hi Rob, 

Stevie O gets to the central issue here. Why _not_ change long-existing,
widely used interfaces in subtle ways because the old way makes no sense to
us and the new way does? Is standards-based programming a lemming behavior? 

My answer is that but-I-think-it-would-be-better, alone, is not a sufficient
reason to risk exposure of old application bugs (if you don't actually have
to) and to bring down apps that ran just fine with the bugs for years. In
this case, the proposed new functionality is triggered by use of interface
space that already had a specified behavior. 

When new functionality is added, at a minimum, its interface should be
outside of the previous valid use set. If one simply must attach the
tendrils of cleverness to the vines of an existing interface, the new
functionality should only appear upon app behaviors that would previously
have been invalid enough to reject the request and burp up an error code. 

As I said before, innovation is fine. Just don't pollute the existing
interfaces. If even one real customer running real work has bad day because
of exposure of an old app bug or an unanticipated consequence of the change,
then it wasn't worth ignoring safer implementation practices. One can't
attain 100% safety, but one _can_ minimize the risk. 

Best regards,
Ed 

---------------------------------------------------------------- 
Ed Vance              edv@macrolink.com
Macrolink, Inc.       1500 N. Kellogg Dr  Anaheim, CA  92807
----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: n_tty.c driver patch (semantic and performance correction) (a ll recent versions)
@ 2002-07-30 17:07 Ed Vance
  2002-07-31  5:31 ` David Lawyer
  0 siblings, 1 reply; 28+ messages in thread
From: Ed Vance @ 2002-07-30 17:07 UTC (permalink / raw)
  To: rwhite, 'Stevie O'
  Cc: Russell King, Ed Vance, 'Theodore Tso',
	linux-kernel, linux-serial

On Sat, July 27, 2002 at 8:02 PM, stevie@qrpff.net wrote:
> 
> But... but... the standard says...
> 
>    A pending read shall not be satisfied until MIN bytes are 
>    received (that is, the pending read shall block until MIN 
>    bytes are received), or a signal is received.
> 
> And because I'm too dead-set on doing it that way solely because 
> that's how it's always been done, I won't ever consider changing it.  
> I'll blindly ignore how much xmodem transfers suck, and the fact 
> that I can come up with no practical purpose at all for this feature, 
> and just repeat what the standard says.  Why should we obey what 
> Linux man pages say? What do the Linux man pages have to do with 
> Linux?
> 
> Remember: Computers and their programs aren't here to make our lives 
> easier, or to make tasks simpler. They are here to follow standards.

Hi Rob, 

Stevie O gets to the central issue here. Why _not_ change long-existing,
widely used interfaces in subtle ways because the old way makes no sense to
us and the new way does? Is standards-based programming a lemming behavior? 

My answer is that but-I-think-it-would-be-better, alone, is not a sufficient
reason to risk exposure of old application bugs (if you don't actually have
to) and to bring down apps that ran just fine with the bugs for years. In
this case, the proposed new functionality is triggered by use of interface
space that already had a specified behavior. 

When new functionality is added, at a minimum, its interface should be
outside of the previous valid use set. If one simply must attach the
tendrils of cleverness to the vines of an existing interface, the new
functionality should only appear upon app behaviors that would previously
have been invalid enough to reject the request and burp up an error code. 

As I said before, innovation is fine. Just don't pollute the existing
interfaces. If even one real customer running real work has bad day because
of exposure of an old app bug or an unanticipated consequence of the change,
then it wasn't worth ignoring safer implementation practices. One can't
attain 100% safety, but one _can_ minimize the risk. 

Best regards,
Ed 

---------------------------------------------------------------- 
Ed Vance              edv@macrolink.com
Macrolink, Inc.       1500 N. Kellogg Dr  Anaheim, CA  92807
----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: n_tty.c driver patch (semantic and performance correction) (a ll recent versions)
@ 2002-07-29 21:46 Ed Vance
  2002-07-30  7:50 ` Robert White
  0 siblings, 1 reply; 28+ messages in thread
From: Ed Vance @ 2002-07-29 21:46 UTC (permalink / raw)
  To: 'rwhite@pobox.com'
  Cc: Russell King, 'Theodore Tso',
	linux-kernel, linux-serial, Andries Brouwer

On Sat, July 27, 2002 at 7:36 PM, Robert White wrote:
> 
> And if you could show me ONE example of wild code that would be 
> harmed by the mod I would shut up and go away.
> 
> (I say wild code, but even contrived code would be interesting.)

>From the archive ...
http://marc.theaimsgroup.com/?l=linux-kernel&m=102440556723250&w=2


^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: n_tty.c driver patch (semantic and performance correction) (a ll recent versions)
@ 2002-06-28 18:12 Ed Vance
  0 siblings, 0 replies; 28+ messages in thread
From: Ed Vance @ 2002-06-28 18:12 UTC (permalink / raw)
  To: 'rwhite@pobox.com'
  Cc: linux-kernel, linux-serial, 'Russell King',
	'Theodore Tso'

Hi Rob,

On Thu, June 27, 2002 at 9:37 AM, Robert White wrote:
> 
> Actually you are wrong about the "Standard".  The Linux manual 
> pages only say the read will return when so many characters 
> have been received.  Alternately, the System V Interface 
> Definition (in every version I have been able to find on the 
> net) speaks in terms of "satisfying the read" .  Both are 
> silent on the issue of what to do if the read is asking for 
> less than VMIN characters.

The Linux termios man page says rather clearly that "If only MIN 
is set, the read will not return before MIN characters have been 
received". Your change would create cases where the read _will_ 
return before MIN characters have been received. That is a conflict. 

> That is, since the VMIN/VTIME mechanism exists only with respect 
> to each individual read request and not with respect to any 
> kind of driver state, there is no inference or onus that says 
> the state applies to anything other than the receipt of 
> characters from the driver to the read itself.
> 
> That is, the context for the word "received" MUST BE "received 
> into the read buffer."  [or perhaps "received into the user 
> context"].  How so, you may ask?
> 
> If "received" is in respect to the UART (e.g. the machine/
> hardware boundary) then it would be true that if there were 100 
> characters in the driver's internal buffer, VMIN were 1, VTIME 
> were 1, and a read were issued but no more characters were 
> "received" by the UART then the read would never return.  
> That is, by the standard, "one character must be received to 
> start the timer, and one character must perceived minimum" so 
> if "received" means "into the driver" instead of "into the user 
> context" the 100 characters in the buffer, having been received 
> in the past would not relate the read (and so on ad nauseum 8-)   
> That would be ridiculous.

Termio, etc. specify the API, not the kernel's implementation of the 
API. All such driver software implements at least two levels of 
buffering to deal with the raw vs. canonical mode. The received data 
does not go directly to the user buffer. The data moves into the user 
buffer only when the read completes. Usually, the data received by 
the UART is handed up to a "line discipline" layer. In Streams 
implementations, there are (at least) three levels of buffering below 
the user's buffer: driver raw queue, line discipline private line 
assembly queue, and the stream head's queue. 

> Since in every stated and useful sense the VMIN and VTIME 
> mechanisms exist specifically and expressly for the purpose of 
> satisfying individual read requests, that is in terms of the 
> user-context/program "receiving" data from the abstract "device" 
> at the file interface, data that can not possibly relate to a 
> read because it is "out of bounds"  is immaterial to the act by 
> definition.  So waiting for the user context to receive 
> characters it has not asked for and cannot possibly receive is 
> a "bad thing".

It operates as specified and does what you tell it to through the API. 
That is neither good nor bad, per se. That's just compliance. If you 
tell it to do something that you don't want, that's not a driver bug. 

> The "waiting for data that can't be returned" and/or the 
> inconsistent application of the concept of "received" serves 
> nobody's interests.

Please make your good changes in a way that does not conflict with the 
existing API. Ioctl is your friend. 

> 
> I was going to simply dismiss that bit of hyperbole about 
> poll as a cheap bit of bad "debate technique" but I've decided 
> to respond.

Surprise. 

> Poll already and explicitly addresses the size of the read and/
> or write as one character, so tossing it in as if it were an 
> example was logically junct.  Additionally, to make the example 
> work you "threw in" with a comment about "adding an argument to 
> poll."  The reason that this was fatuous is that the parameter 
> you would "add"  to poll would be disruptive (which is why you 
> put it in 8-) but the information is already provided in the 
> read, the buffer length IS ALREADY being passed.  The analogy 
> and the allegation of difficulty or disruption is inapplicable.

That's not how poll and select are used. For the read case, Poll and 
Select are active when waiting for the availability of data. When data 
becomes available, they return and you post a read to scoop up the new 
data. There is no pending read during poll and select to supply a read 
buffer length to the driver.

I have no problem with innovation. Just don't pollute the existing API. 

Regards,
Ed

----------------------------------------------------------------
Ed Vance              edv@macrolink.com
Macrolink, Inc.       1500 N. Kellogg Dr  Anaheim, CA  92807
----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: n_tty.c driver patch (semantic and performance correction) (a ll recent versions)
@ 2002-06-17 17:27 Ed Vance
  2002-06-18  2:00 ` Robert White
  2002-06-18  2:00 ` Robert White
  0 siblings, 2 replies; 28+ messages in thread
From: Ed Vance @ 2002-06-17 17:27 UTC (permalink / raw)
  To: 'rwhite@pobox.com'
  Cc: linux-kernel, linux-serial, 'Russell King',
	'Theodore Tso'

On Sat, June 15, 2002 at 9:01 PM, Robert White wrote:
> Kernel Versions: 2.2, 2.4, 2.5 (all of them since 1996 really 8-)
> 
> The n_tty line discipline module contains a "semantic error" that 
> limits its speed and usefulness in many uses.  The attached patch 
> directly addresses serial performance in a completely backwards-
> compatible way.
> 
> In particular, the current handling of VMIN hugely limits, 
> complicates, and/or slows down optimal serial use.  The most 
> obvious example is that if you call read(2) with a buffer size less 
> than the current value of VMIN, the line discipline will insist 
> that the read call wait for characters that can not be returned to 
> that call.  The POSIX standard is silent on the subject of whether 
> this is right or wrong.  Common sense says it is wrong.

Hi,

IIRC, the way VMIN>0,VTIME=0 is supposed to work is to make characters 
available to the top level queue to be read when the low level input 
queue contains VMIN or more characters. Until that moment, there are 
no characters available to a read of any buffer size regardless of how 
many characters have been received at the low level. This is why a 
single character read blocks when at least one character has been 
received but not yet VMIN characters. Only data in the top level queue 
can be read. If the line discipline has not yet released data to the 
top level queue because of VMIN, then no data can be read, but this is 
not an error. 

Many have been tempted to change the behavior of this part of the 
system. IMHO, it is not worth tossing away application portability. 

Standards compliance can feel a bit like vertigo while instrument 
flying. Sometimes one has to just stare at the artificial horizon and 
say "I believe it" to one's self until the gut is convinced. 

Best regards,
Ed

---------------------------------------------------------------- 
Ed Vance              edv@macrolink.com
Macrolink, Inc.       1500 N. Kellogg Dr  Anaheim, CA  92807
----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2002-07-31 16:58 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-26 17:48 n_tty.c driver patch (semantic and performance correction) (a ll recent versions) Ed Vance
2002-06-26 20:42 ` Russell King
2002-06-27 16:37 ` Robert White
2002-06-27 16:37 ` Robert White
2002-07-26 14:17 ` Russell King
2002-07-27 22:07   ` Robert White
2002-07-27 23:11     ` Russell King
2002-07-27 23:21     ` Andries Brouwer
2002-07-28  2:34       ` Robert White
2002-07-28  3:01         ` Stevie O
2002-07-28 13:34         ` Andries Brouwer
2002-07-28 20:04         ` Alan Cox
2002-07-30  7:41           ` Robert White
2002-07-28 20:04         ` Alan Cox
2002-07-28  2:36       ` Robert White
  -- strict thread matches above, loose matches on Subject: below --
2002-07-31 16:58 Ed Vance
2002-07-31 16:58 Ed Vance
2002-07-30 17:07 Ed Vance
2002-07-30 17:07 Ed Vance
2002-07-31  5:31 ` David Lawyer
2002-07-29 21:46 Ed Vance
2002-07-30  7:50 ` Robert White
2002-06-28 18:12 Ed Vance
2002-06-17 17:27 Ed Vance
2002-06-18  2:00 ` Robert White
2002-06-18 13:05   ` Stuart MacDonald
2002-06-18 13:05     ` Stuart MacDonald
2002-06-18  2:00 ` Robert White

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.