path: root/sys/sys/terminal.h
diff options
authorJean-Sébastien Pédron <dumbbell@FreeBSD.org>2018-05-16 09:01:02 +0000
committerJean-Sébastien Pédron <dumbbell@FreeBSD.org>2018-05-16 09:01:02 +0000
commit547e74a8be76e2d9fcaa1c4c9b31225044f70963 (patch)
tree889e1c01e5b6d41052a7652c0c5ee93179236ac7 /sys/sys/terminal.h
parentc9c4d38aa84d87a4d24a7857e98bfa7b6dff1f68 (diff)
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
Notes: svn path=/head/; revision=333669
Diffstat (limited to 'sys/sys/terminal.h')
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/sys/terminal.h b/sys/sys/terminal.h
index c69f00b05af1..dc78cca5394e 100644
--- a/sys/sys/terminal.h
+++ b/sys/sys/terminal.h
@@ -151,6 +151,8 @@ typedef void tc_fill_t(struct terminal *tm, const term_rect_t *r,
term_char_t c);
typedef void tc_copy_t(struct terminal *tm, const term_rect_t *r,
const term_pos_t *p);
+typedef void tc_pre_input_t(struct terminal *tm);
+typedef void tc_post_input_t(struct terminal *tm);
typedef void tc_param_t(struct terminal *tm, int cmd, unsigned int arg);
typedef void tc_done_t(struct terminal *tm);
@@ -173,6 +175,8 @@ struct terminal_class {
tc_putchar_t *tc_putchar;
tc_fill_t *tc_fill;
tc_copy_t *tc_copy;
+ tc_pre_input_t *tc_pre_input;
+ tc_post_input_t *tc_post_input;
tc_param_t *tc_param;
tc_done_t *tc_done;