Skip to contentSkip to conversation

termios.3: Document line length in canonical mode

PATCH In review Dr. Tobias Quathamer 3 participants 8 messages Feb 15, 2016 – Feb 18, 2016 7 messages not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 termios.3: Document line length in canonical mode

See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/n_tty.c#n1673
See https://bugs.debian.org/797479

---
 man3/termios.3 | 9 +++++++++
 1 file changed, 9 insertions(+)
man3/termios.3 +9 -0
index 7d738d4..3f57607 100644
@@ -728,11 +728,20 @@ requested fewer bytes than are available in the current line of input,
 then only as many bytes as requested are read,
 and the remaining characters will be available for a future
 .BR read (2).
+.IP * 2
+The maximum line length is 4096 chars (including the line termination
+char); lines longer than 4096 chars are truncated. After 4095 chars,
+input data is still processed but not stored. Overflow processing
+ensures the tty can always receive more input until at least one
+line can be read.
 .PP
 In noncanonical mode input is available immediately (without
 the user having to type a line-delimiter character),
 no input processing is performed,
 and line editing is disabled.
+The read buffer will only accept 4095 chars; this provides the
+necessary space for a newline char if the input mode is switched
+to canonical.
 The settings of MIN
 .RI ( c_cc[VMIN] )
 and TIME
Signature · 6 lines
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1455542819-29184-1-git-send-email-toddy-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org

#2 lore raw

Hello Tobias,

Quoted 21 lines · Dr. Tobias Quathamer

See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/n_tty.c#n1673
See https://bugs.debian.org/797479

---
 man3/termios.3 | 9 +++++++++
 1 file changed, 9 insertions(+)
man3/termios.3 +6 -0
index 7d738d4..3f57607 100644
@@ -728,11 +728,20 @@ requested fewer bytes than are available in the current line of input,
 then only as many bytes as requested are read,
 and the remaining characters will be available for a future
 .BR read (2).
+.IP * 2
+The maximum line length is 4096 chars (including the line termination
+char); lines longer than 4096 chars are truncated. After 4095 chars,
+input data is still processed but not stored. Overflow processing
+ensures the tty can always receive more input until at least one
+line can be read.
 .PP

man3/termios.3 requested fewer bytes than are available in the current line of input, · line 747

Quoted 10 lines
man3/termios.3 +3 -0
 In noncanonical mode input is available immediately (without
 the user having to type a line-delimiter character),
 no input processing is performed,
 and line editing is disabled.
+The read buffer will only accept 4095 chars; this provides the
+necessary space for a newline char if the input mode is switched
+to canonical.
 The settings of MIN
 .RI ( c_cc[VMIN] )
 and TIME

Thanks for crafting this. I've applied, and tweaked a little to clarify some details:

* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input data up (but not including) any ter‐ minating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 38 lines · Michael Kerrisk (man-pages)

Hello Tobias,

Quoted 21 lines · Dr. Tobias Quathamer

See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/n_tty.c#n1673
See https://bugs.debian.org/797479

---
 man3/termios.3 | 9 +++++++++
 1 file changed, 9 insertions(+)
man3/termios.3 +6 -0
index 7d738d4..3f57607 100644
@@ -728,11 +728,20 @@ requested fewer bytes than are available in the current line of input,
 then only as many bytes as requested are read,
 and the remaining characters will be available for a future
 .BR read (2).
+.IP * 2
+The maximum line length is 4096 chars (including the line termination
+char); lines longer than 4096 chars are truncated. After 4095 chars,
+input data is still processed but not stored. Overflow processing
+ensures the tty can always receive more input until at least one
+line can be read.
 .PP

man3/termios.3 requested fewer bytes than are available in the current line of input, · line 747

Quoted 10 lines
man3/termios.3 +3 -0
 In noncanonical mode input is available immediately (without
 the user having to type a line-delimiter character),
 no input processing is performed,
 and line editing is disabled.
+The read buffer will only accept 4095 chars; this provides the
+necessary space for a newline char if the input mode is switched
+to canonical.
 The settings of MIN
 .RI ( c_cc[VMIN] )
 and TIME

Thanks for crafting this. I've applied, and tweaked a little to clarify some details:

Quoted 6 lines

* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input data up (but not including) any ter‐ minating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Hmm. Neither description is accurate of the observable behavior from userspace. For example, it's entirely possible to retrieve > 4096 bytes in non-canonical mode, at least since 3.12

And input processing continues on the input, even past 4096 bytes. Line editing, ISIG, ECHOxx processing still occurs.

It is true that it is not possible to retrieve > 4096 char line in canonical mode, and I don't see that ever changing via read() because userspace may assume it has received a terminated line in 4096-byte read buffer.

However, the noncanonical mode input buffer size may change in the near future.

Regards,
Peter Hurley
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 56C3A30D.5010101-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org

#6 lore raw

Hello Peter

Quoted 46 lines · Peter Hurley
Quoted 38 lines · Michael Kerrisk (man-pages)

Hello Tobias,

Quoted 21 lines · Dr. Tobias Quathamer

See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/n_tty.c#n1673
See https://bugs.debian.org/797479

---
 man3/termios.3 | 9 +++++++++
 1 file changed, 9 insertions(+)
man3/termios.3 +6 -0
index 7d738d4..3f57607 100644
@@ -728,11 +728,20 @@ requested fewer bytes than are available in the current line of input,
 then only as many bytes as requested are read,
 and the remaining characters will be available for a future
 .BR read (2).
+.IP * 2
+The maximum line length is 4096 chars (including the line termination
+char); lines longer than 4096 chars are truncated. After 4095 chars,
+input data is still processed but not stored. Overflow processing
+ensures the tty can always receive more input until at least one
+line can be read.
 .PP

man3/termios.3 requested fewer bytes than are available in the current line of input, · line 747

Quoted 10 lines
man3/termios.3 +3 -0
 In noncanonical mode input is available immediately (without
 the user having to type a line-delimiter character),
 no input processing is performed,
 and line editing is disabled.
+The read buffer will only accept 4095 chars; this provides the
+necessary space for a newline char if the input mode is switched
+to canonical.
 The settings of MIN
 .RI ( c_cc[VMIN] )
 and TIME

Thanks for crafting this. I've applied, and tweaked a little to clarify some details:

Quoted 6 lines

* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input data up (but not including) any ter‐ minating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Quoted 3 lines

Hmm. Neither description is accurate of the observable behavior from userspace. For example, it's entirely possible to retrieve > 4096 bytes in non-canonical mode, at least since 3.12

Note that the text I quoted applies just to canonical mode:

In canonical mode:

[...]

* The maximum line length is 4096 chars (including the terminat‐ ing newline character); lines longer than 4096 chars are trun‐ cated. After 4095 characters, input data up (but not includ‐ ing) any terminating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

So, does that seem okay?

Quoted 2 lines

And input processing continues on the input, even past 4096 bytes. Line editing, ISIG, ECHOxx processing still occurs.

Yes, but only in noncanonical mode, right?

Quoted 4 lines

It is true that it is not possible to retrieve > 4096 char line in canonical mode, and I don't see that ever changing via read() because userspace may assume it has received a terminated line in 4096-byte read buffer.

Yep. So we all seem to agree.

Quoted 2 lines

However, the noncanonical mode input buffer size may change in the near future.

Can you say some more about that? And what changed in 3.13 with respect to noncanonical mode, by the way?

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Hi Michael,

Quoted 55 lines · Michael Kerrisk (man-pages)
Quoted 44 lines · Peter Hurley
Quoted 36 lines · Michael Kerrisk (man-pages)
Quoted 21 lines · Dr. Tobias Quathamer

See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/n_tty.c#n1673
See https://bugs.debian.org/797479

---
 man3/termios.3 | 9 +++++++++
 1 file changed, 9 insertions(+)
man3/termios.3 +6 -0
index 7d738d4..3f57607 100644
@@ -728,11 +728,20 @@ requested fewer bytes than are available in the current line of input,
 then only as many bytes as requested are read,
 and the remaining characters will be available for a future
 .BR read (2).
+.IP * 2
+The maximum line length is 4096 chars (including the line termination
+char); lines longer than 4096 chars are truncated. After 4095 chars,
+input data is still processed but not stored. Overflow processing
+ensures the tty can always receive more input until at least one
+line can be read.
 .PP

man3/termios.3 requested fewer bytes than are available in the current line of input, · line 747

Quoted 10 lines
man3/termios.3 +3 -0
 In noncanonical mode input is available immediately (without
 the user having to type a line-delimiter character),
 no input processing is performed,
 and line editing is disabled.
+The read buffer will only accept 4095 chars; this provides the
+necessary space for a newline char if the input mode is switched
+to canonical.
 The settings of MIN
 .RI ( c_cc[VMIN] )
 and TIME

Thanks for crafting this. I've applied, and tweaked a little to clarify some details:

Quoted 6 lines

* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input data up (but not including) any ter‐ minating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Quoted 3 lines

Hmm. Neither description is accurate of the observable behavior from userspace. For example, it's entirely possible to retrieve > 4096 bytes in non-canonical mode, at least since 3.12

Note that the text I quoted applies just to canonical mode:

In canonical mode:

[...]

Quoted 8 lines

* The maximum line length is 4096 chars (including the terminat‐ ing newline character); lines longer than 4096 chars are trun‐ cated. After 4095 characters, input data up (but not includ‐ ing) any terminating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

So, does that seem okay?

See below.

Quoted 4 lines
Quoted 2 lines

And input processing continues on the input, even past 4096 bytes. Line editing, ISIG, ECHOxx processing still occurs.

Yes, but only in noncanonical mode, right?

No. Input processing continues in canonical mode, including echoing. Only when bytes are to actually be stored for userspace to later read is the input data discarded if the buffer is full (less the 1 byte required to store the line termination).

Every input byte received in canonical mode is always processed normally and only discarded if the buffer is full. IOW, a Ctrl+u (line kill) received as the 6000th byte received w/o line termination will still cause all previous data to be flushed and the line restarted when new input arrives.

Similarly, all data is still echoed regardless of how long the line is.

Quoted 5 lines
Quoted 3 lines

It is true that it is not possible to retrieve > 4096 char line in canonical mode, and I don't see that ever changing via read() because userspace may assume it has received a terminated line in 4096-byte read buffer.

Yep. So we all seem to agree.

The way I read your edits above is that all new input data is simply discarded until line termination, which is not the case.

Dr. Quathamer's first diff hunk is accurate wrt canonical mode. However, I think the 'Overflow processing ...' is overly specific; the tty core contains many elements which prevent terminal lockup.

Quoted 4 lines
Quoted 2 lines

However, the noncanonical mode input buffer size may change in the near future.

Can you say some more about that?

At very high line rates and with ptys, the size of the read buffer becomes a bottleneck, while at the same time, an already-committed page of memory is going unused because of the page order allocation used by vm area allocator (where N_TTY data is stored).

The change is non-trivial however, since the maximum read size returned by canonical mode cannot > 4096 bytes (because of the userspace assumptions I referred to earlier).

Quoted 1 line

And what changed in 3.13 with respect to noncanonical mode, by the way?

In 3.12, the entire tty input path was parallelized.

So while data is being read by userspace, input processing continues concurrently, adding new data for userspace to read (the actual construct used is a lockless circular buffer). In non-canonical modes, the userspace copy is always performed twice -- first, from beginning of unread data (head) to the end of buffer and then, from the beginning of buffer to last unread data (tail).

Since new data may be added to the circular buffer in parallel after the first user copy has been performed, it's possible to retrieve up to 8192 bytes (assuming the user copy buffer is that large).

Regards,
Peter Hurley
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 56C4A1E4.3090201-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org

#10 lore raw

Hello Peter,

Quoted 79 lines · Peter Hurley

Hi Michael,

Quoted 55 lines · Michael Kerrisk (man-pages)
Quoted 44 lines · Peter Hurley
Quoted 36 lines · Michael Kerrisk (man-pages)
Quoted 21 lines · Dr. Tobias Quathamer

See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/n_tty.c#n1673
See https://bugs.debian.org/797479

---
 man3/termios.3 | 9 +++++++++
 1 file changed, 9 insertions(+)
man3/termios.3 +6 -0
index 7d738d4..3f57607 100644
@@ -728,11 +728,20 @@ requested fewer bytes than are available in the current line of input,
 then only as many bytes as requested are read,
 and the remaining characters will be available for a future
 .BR read (2).
+.IP * 2
+The maximum line length is 4096 chars (including the line termination
+char); lines longer than 4096 chars are truncated. After 4095 chars,
+input data is still processed but not stored. Overflow processing
+ensures the tty can always receive more input until at least one
+line can be read.
 .PP

man3/termios.3 requested fewer bytes than are available in the current line of input, · line 747

Quoted 10 lines
man3/termios.3 +3 -0
 In noncanonical mode input is available immediately (without
 the user having to type a line-delimiter character),
 no input processing is performed,
 and line editing is disabled.
+The read buffer will only accept 4095 chars; this provides the
+necessary space for a newline char if the input mode is switched
+to canonical.
 The settings of MIN
 .RI ( c_cc[VMIN] )
 and TIME

Thanks for crafting this. I've applied, and tweaked a little to clarify some details:

Quoted 6 lines

* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input data up (but not including) any ter‐ minating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Quoted 3 lines

Hmm. Neither description is accurate of the observable behavior from userspace. For example, it's entirely possible to retrieve > 4096 bytes in non-canonical mode, at least since 3.12

Note that the text I quoted applies just to canonical mode:

In canonical mode:

[...]

Quoted 8 lines

* The maximum line length is 4096 chars (including the terminat‐ ing newline character); lines longer than 4096 chars are trun‐ cated. After 4095 characters, input data up (but not includ‐ ing) any terminating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

So, does that seem okay?

See below.

Quoted 4 lines
Quoted 2 lines

And input processing continues on the input, even past 4096 bytes. Line editing, ISIG, ECHOxx processing still occurs.

Yes, but only in noncanonical mode, right?

No. Input processing continues in canonical mode, including echoing. Only when bytes are to actually be stored for userspace to later read is the input data discarded if the buffer is full (less the 1 byte required to store the line termination).

Quoted 4 lines

Every input byte received in canonical mode is always processed normally and only discarded if the buffer is full. IOW, a Ctrl+u (line kill) received as the 6000th byte received w/o line termination will still cause all previous data to be flushed and the line restarted when new input arrives.

Ahh -- got it. I wasn't thinking about that stuff at all!

Quoted 10 lines

Similarly, all data is still echoed regardless of how long the line is.

Quoted 5 lines
Quoted 3 lines

It is true that it is not possible to retrieve > 4096 char line in canonical mode, and I don't see that ever changing via read() because userspace may assume it has received a terminated line in 4096-byte read buffer.

Yep. So we all seem to agree.

The way I read your edits above is that all new input data is simply discarded until line termination, which is not the case.

Yes, because I wasn't even considering your point :-). Thanks for the clarifications.

Quoted 3 lines

Dr. Quathamer's first diff hunk is accurate wrt canonical mode. However, I think the 'Overflow processing ...' is overly specific; the tty core contains many elements which prevent terminal lockup.

Okay -- so how's this text?

In canonical mode:
[...]
* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input processing (e.g., ISIG and ECHO* processing) continues, but any input data after 4095 characters up to (but not including) any terminating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Quoted 25 lines
Quoted 4 lines
Quoted 2 lines

However, the noncanonical mode input buffer size may change in the near future.

Can you say some more about that?

At very high line rates and with ptys, the size of the read buffer becomes a bottleneck, while at the same time, an already-committed page of memory is going unused because of the page order allocation used by vm area allocator (where N_TTY data is stored).

The change is non-trivial however, since the maximum read size returned by canonical mode cannot > 4096 bytes (because of the userspace assumptions I referred to earlier).

Quoted 1 line

And what changed in 3.13 with respect to noncanonical mode, by the way?

In 3.12, the entire tty input path was parallelized.

So while data is being read by userspace, input processing continues concurrently, adding new data for userspace to read (the actual construct used is a lockless circular buffer). In non-canonical modes, the userspace copy is always performed twice -- first, from beginning of unread data (head) to the end of buffer and then, from the beginning of buffer to last unread data (tail).

Quoted 3 lines

Since new data may be added to the circular buffer in parallel after the first user copy has been performed, it's possible to retrieve up to 8192 bytes (assuming the user copy buffer is that large).

Thanks for the info. Do you think this warrants any changes in the man page?

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 109 lines · Michael Kerrisk (man-pages)

Hello Peter,

Quoted 79 lines · Peter Hurley

Hi Michael,

Quoted 55 lines · Michael Kerrisk (man-pages)
Quoted 44 lines · Peter Hurley
Quoted 36 lines · Michael Kerrisk (man-pages)
Quoted 21 lines · Dr. Tobias Quathamer

See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/n_tty.c#n1673
See https://bugs.debian.org/797479

---
 man3/termios.3 | 9 +++++++++
 1 file changed, 9 insertions(+)
man3/termios.3 +6 -0
index 7d738d4..3f57607 100644
@@ -728,11 +728,20 @@ requested fewer bytes than are available in the current line of input,
 then only as many bytes as requested are read,
 and the remaining characters will be available for a future
 .BR read (2).
+.IP * 2
+The maximum line length is 4096 chars (including the line termination
+char); lines longer than 4096 chars are truncated. After 4095 chars,
+input data is still processed but not stored. Overflow processing
+ensures the tty can always receive more input until at least one
+line can be read.
 .PP

man3/termios.3 requested fewer bytes than are available in the current line of input, · line 747

Quoted 10 lines
man3/termios.3 +3 -0
 In noncanonical mode input is available immediately (without
 the user having to type a line-delimiter character),
 no input processing is performed,
 and line editing is disabled.
+The read buffer will only accept 4095 chars; this provides the
+necessary space for a newline char if the input mode is switched
+to canonical.
 The settings of MIN
 .RI ( c_cc[VMIN] )
 and TIME

Thanks for crafting this. I've applied, and tweaked a little to clarify some details:

Quoted 6 lines

* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input data up (but not including) any ter‐ minating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Quoted 3 lines

Hmm. Neither description is accurate of the observable behavior from userspace. For example, it's entirely possible to retrieve > 4096 bytes in non-canonical mode, at least since 3.12

Note that the text I quoted applies just to canonical mode:

In canonical mode:

[...]

Quoted 8 lines

* The maximum line length is 4096 chars (including the terminat‐ ing newline character); lines longer than 4096 chars are trun‐ cated. After 4095 characters, input data up (but not includ‐ ing) any terminating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

So, does that seem okay?

See below.

Quoted 4 lines
Quoted 2 lines

And input processing continues on the input, even past 4096 bytes. Line editing, ISIG, ECHOxx processing still occurs.

Yes, but only in noncanonical mode, right?

No. Input processing continues in canonical mode, including echoing. Only when bytes are to actually be stored for userspace to later read is the input data discarded if the buffer is full (less the 1 byte required to store the line termination).

Quoted 4 lines

Every input byte received in canonical mode is always processed normally and only discarded if the buffer is full. IOW, a Ctrl+u (line kill) received as the 6000th byte received w/o line termination will still cause all previous data to be flushed and the line restarted when new input arrives.

Ahh -- got it. I wasn't thinking about that stuff at all!

Quoted 10 lines

Similarly, all data is still echoed regardless of how long the line is.

Quoted 5 lines
Quoted 3 lines

It is true that it is not possible to retrieve > 4096 char line in canonical mode, and I don't see that ever changing via read() because userspace may assume it has received a terminated line in 4096-byte read buffer.

Yep. So we all seem to agree.

The way I read your edits above is that all new input data is simply discarded until line termination, which is not the case.

Yes, because I wasn't even considering your point :-). Thanks for the clarifications.

Quoted 3 lines

Dr. Quathamer's first diff hunk is accurate wrt canonical mode. However, I think the 'Overflow processing ...' is overly specific; the tty core contains many elements which prevent terminal lockup.

Okay -- so how's this text?

Quoted 9 lines

In canonical mode:
[...]
* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input processing (e.g., ISIG and ECHO* processing) continues, but any input data after 4095 characters up to (but not including) any terminating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Yeah, this seems fine.

Quoted 25 lines
Quoted 25 lines
Quoted 4 lines
Quoted 2 lines

However, the noncanonical mode input buffer size may change in the near future.

Can you say some more about that?

At very high line rates and with ptys, the size of the read buffer becomes a bottleneck, while at the same time, an already-committed page of memory is going unused because of the page order allocation used by vm area allocator (where N_TTY data is stored).

The change is non-trivial however, since the maximum read size returned by canonical mode cannot > 4096 bytes (because of the userspace assumptions I referred to earlier).

Quoted 1 line

And what changed in 3.13 with respect to noncanonical mode, by the way?

In 3.12, the entire tty input path was parallelized.

So while data is being read by userspace, input processing continues concurrently, adding new data for userspace to read (the actual construct used is a lockless circular buffer). In non-canonical modes, the userspace copy is always performed twice -- first, from beginning of unread data (head) to the end of buffer and then, from the beginning of buffer to last unread data (tail).

Quoted 5 lines
Quoted 3 lines

Since new data may be added to the circular buffer in parallel after the first user copy has been performed, it's possible to retrieve up to 8192 bytes (assuming the user copy buffer is that large).

Thanks for the info. Do you think this warrants any changes in the man page?

I don't think so. The goal of most changes in tty is to improve reliability or performance w/o affecting userspace-observable behavior.

Regards,
Peter Hurley
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 56C5E3DC.6040504-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org

#14 lore raw

Hello Peter

Quoted 4 lines · Peter Hurley
Quoted 3 lines · Michael Kerrisk (man-pages)

Hello Peter,

On 02/17/2016 05:37 PM, Peter Hurley wrote:

[...]

Quoted 12 lines
Quoted 11 lines

Okay -- so how's this text?

In canonical mode:
[...]
* The maximum line length is 4096 chars (including the terminating newline character); lines longer than 4096 chars are truncated. After 4095 characters, input processing (e.g., ISIG and ECHO* processing) continues, but any input data after 4095 characters up to (but not including) any terminating newline is discarded. This ensures that the terminal can always receive more input until at least one line can be read.

Quoted 1 line

Yeah, this seems fine.

Thanks for checking it.

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 4 lines
Quoted 2 lines

However, the noncanonical mode input buffer size may change in the near future.

Can you say some more about that?

At very high line rates and with ptys, the size of the read buffer becomes a bottleneck, while at the same time, an already-committed page of memory is going unused because of the page order allocation used by vm area allocator (where N_TTY data is stored).

The change is non-trivial however, since the maximum read size returned by canonical mode cannot > 4096 bytes (because of the userspace assumptions I referred to earlier).

Quoted 1 line

And what changed in 3.13 with respect to noncanonical mode, by the way?

In 3.12, the entire tty input path was parallelized.

So while data is being read by userspace, input processing continues concurrently, adding new data for userspace to read (the actual construct used is a lockless circular buffer). In non-canonical modes, the userspace copy is always performed twice -- first, from beginning of unread data (head) to the end of buffer and then, from the beginning of buffer to last unread data (tail).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Since new data may be added to the circular buffer in parallel after the first user copy has been performed, it's possible to retrieve up to 8192 bytes (assuming the user copy buffer is that large).

Thanks for the info. Do you think this warrants any changes in the man page?

I don't think so. The goal of most changes in tty is to improve reliability or performance w/o affecting userspace-observable behavior.

Okay.

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html