Skip to content

mostly lockless tty echo

Peter Hurley linux-serial lkml 2 versions – Applied

Status from this message: Applied, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 3 repliesApplied
  2. v19 patches 0 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/9n_tty: Remove unused echo_overrun fielddrivers/tty/n_tty.c+1 -70 replies
2/9n_tty: Use separate head and tail indices for echo_bufdrivers/tty/n_tty.c+35 -530 replies
3/9n_tty: Replace echo_cnt with computed valuedrivers/tty/n_tty.c+7 -130 replies
4/9n_tty: Remove echo_lockdrivers/tty/n_tty.c+28 -470 replies
5/9n_tty: Eliminate echo_commit memory barrierdrivers/tty/n_tty.c+20 -110 replies
6/9n_tty: Process echoes in blocksdrivers/tty/n_tty.c+47 -232 replies
7/9n_tty: Only flush echo output if actually outputdrivers/tty/n_tty.c+10 -80 replies
8/9n_tty: Eliminate counter in __process_echoesdrivers/tty/n_tty.c+1 -80 replies
9/9n_tty: Avoid false-sharing echo buffer indicesdrivers/tty/n_tty.c+4 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/9] mostly lockless tty echo

** v2 changes **
- Rebased on v2 of 'lockless tty flip buffers'

This 3rd of 4 patchsets implements a mostly-lockless tty echo output.

Because echoing is performed solely by the single-threaded ldisc receive_buf() method, most of the lockless requirements are already in-place. The main existing complications were;
1) Echoing could overrun itself. A fixed-size buffer is used to record the operations necessary when outputting the echoes; the most recent echo data is preserved.
2) An attempt to push unprocessed echoes is made by the n_tty_write method (on a different thread) before attempting write output.

The overrun condition is solved by outputting the echoes in blocks and ensuring that at least that much space is available each time an echo operation is committed. At the conclusion of each flip buffer received, any remaining unprocessed echoes are output.

This block output method is particularly effective when there is no reader (the tty is output-only) and termios is misconfigured with echo enabled.

The concurrent access by the n_tty_write() method is already excluded by the existing output_lock mutex.

Peter Hurley (9):
n_tty: Remove unused echo_overrun field
n_tty: Use separate head and tail indices for echo_buf
n_tty: Replace echo_cnt with computed value
n_tty: Remove echo_lock
n_tty: Eliminate echo_commit memory barrier
n_tty: Process echoes in blocks
n_tty: Only flush echo output if actually output
n_tty: Eliminate counter in __process_echoes
n_tty: Avoid false-sharing echo buffer indices

 drivers/tty/n_tty.c | 248 ++++++++++++++++++++++++----------------------------
 1 file changed, 113 insertions(+), 135 deletions(-)
Signature · 1 line
1.8.1.2