freebsd-dev/sys/dev/vt
Jean-Sébastien Pédron 547e74a8be teken, vt(4): New callbacks to lock the terminal once
... to process input, instead of inside each smaller operations such as
appending a character or moving the cursor forward.

In other words, before we were doing (oversimplified):

  teken_input()
    <for each input character>
      vtterm_putchar()
        VTBUF_LOCK()
        VTBUF_UNLOCK()
      vtterm_cursor_position()
        VTBUF_LOCK()
        VTBUF_UNLOCK()

Now, we are doing:

  vtterm_pre_input()
    VTBUF_LOCK()
  teken_input()
    <for each input character>
      vtterm_putchar()
      vtterm_cursor_position()
  vtterm_post_input()
    VTBUF_UNLOCK()

The situation was even worse when the vtterm_copy() and vtterm_fill()
callbacks were involved.

The new callbacks are:
  * struct terminal_class->tc_pre_input()
  * struct terminal_class->tc_post_input()

They are called in teken_input(), surrounding the while() loop.

The goal is to improve input processing speed of vt(4). As a benchmark,
here is the time taken to write a text file of 360 000 lines (26 MiB) on
`ttyv0`:

  * vt(4), unmodified:      1500 ms
  * vt(4), with this patch: 1200 ms
  * syscons(4):              700 ms

This is on a Haswell laptop with a GENERIC-NODEBUG kernel.

At the same time, the locking is changed in the vt_flush() function
which is responsible to draw the text on screen. So instead of
(indirectly) using VTBUF_LOCK() just to read and reset the dirty area
of the internal buffer, the lock is held for about the entire function,
including the drawing part.

The change is mostly visible while content is scrolling fast: before,
lines could appear garbled while scrolling because the internal buffer
was accessed without locks (once the scrolling was finished, the output
was correct). Now, the scrolling appears correct.

In the end, the locking model is closer to what syscons(4) does.

Differential Revision:	https://reviews.freebsd.org/D15302
2018-05-16 09:01:02 +00:00
..
colors vt(4): Use default VGA palette 2018-05-10 17:00:33 +00:00
font Update vt(4) "Terminus BSD Console" font to v4.46 2018-04-12 20:21:04 +00:00
hw vt(4): Use default VGA palette 2018-05-10 17:00:33 +00:00
logo sys/dev: further adoption of SPDX licensing ID tags. 2017-11-27 14:52:40 +00:00
vt_buf.c teken, vt(4): New callbacks to lock the terminal once 2018-05-16 09:01:02 +00:00
vt_consolectl.c sys/dev: further adoption of SPDX licensing ID tags. 2017-11-27 14:52:40 +00:00
vt_core.c teken, vt(4): New callbacks to lock the terminal once 2018-05-16 09:01:02 +00:00
vt_cpulogos.c Revert r316796. It is not necessary since r317173. 2017-04-19 22:43:11 +00:00
vt_font.c Limit glyph count in vtfont_load to avoid integer overflow. 2018-04-04 05:21:46 +00:00
vt_sysmouse.c sys/dev: further adoption of SPDX licensing ID tags. 2017-11-27 14:52:40 +00:00
vt.h teken, vt(4): New callbacks to lock the terminal once 2018-05-16 09:01:02 +00:00