summaryrefslogtreecommitdiffstats
path: root/sys/dev/vt
diff options
context:
space:
mode:
authordumbbell <dumbbell@FreeBSD.org>2014-08-19 20:53:28 +0000
committerdumbbell <dumbbell@FreeBSD.org>2014-08-19 20:53:28 +0000
commit7daa04d3523ba48ea4928880d129119e21b0cd50 (patch)
treea612d657bfcda13d22e9f13439dc97df8b8992b8 /sys/dev/vt
parent93714464a815b9cf961a1d024a0166fca79dde2d (diff)
downloadFreeBSD-src-7daa04d3523ba48ea4928880d129119e21b0cd50.zip
FreeBSD-src-7daa04d3523ba48ea4928880d129119e21b0cd50.tar.gz
vt(4): Add vtbuf_dirty*_locked() to lock vtbuf once, not twice
In several functions, vtbuf_putchar() in particular, the lock on vtbuf is acquired twice: 1. once by the said functions; 2. once in vtbuf_dirty(). Now, vtbuf_dirty_locked() and vtbuf_dirty_cell_locked() allow to acquire that lock only once. This improves the input speed of vt(4). To measure the gain, a 50,000-lines file was displayed on the console using cat(1). The time taken by cat(1) is reported below: o On amd64, with vt_vga: - before: 1.0" - after: 0.5" o On sparc64, with creator_vt: - before: 13.6" - after: 10.5" This is an MFC of r269780.
Diffstat (limited to 'sys/dev/vt')
-rw-r--r--sys/dev/vt/vt_buf.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c
index 14e02f1..4003ce8 100644
--- a/sys/dev/vt/vt_buf.c
+++ b/sys/dev/vt/vt_buf.c
@@ -229,10 +229,9 @@ vtbuf_dirty_axis(unsigned int begin, unsigned int end)
}
static inline void
-vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area)
+vtbuf_dirty_locked(struct vt_buf *vb, const term_rect_t *area)
{
- VTBUF_LOCK(vb);
if (vb->vb_dirtyrect.tr_begin.tp_row > area->tr_begin.tp_row)
vb->vb_dirtyrect.tr_begin.tp_row = area->tr_begin.tp_row;
if (vb->vb_dirtyrect.tr_begin.tp_col > area->tr_begin.tp_col)
@@ -245,18 +244,26 @@ vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area)
vtbuf_dirty_axis(area->tr_begin.tp_row, area->tr_end.tp_row);
vb->vb_dirtymask.vbm_col |=
vtbuf_dirty_axis(area->tr_begin.tp_col, area->tr_end.tp_col);
+}
+
+static inline void
+vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area)
+{
+
+ VTBUF_LOCK(vb);
+ vtbuf_dirty_locked(vb, area);
VTBUF_UNLOCK(vb);
}
static inline void
-vtbuf_dirty_cell(struct vt_buf *vb, const term_pos_t *p)
+vtbuf_dirty_cell_locked(struct vt_buf *vb, const term_pos_t *p)
{
term_rect_t area;
area.tr_begin = *p;
area.tr_end.tp_row = p->tp_row + 1;
area.tr_end.tp_col = p->tp_col + 1;
- vtbuf_dirty(vb, &area);
+ vtbuf_dirty_locked(vb, &area);
}
static void
@@ -373,9 +380,8 @@ vtbuf_fill_locked(struct vt_buf *vb, const term_rect_t *r, term_char_t c)
VTBUF_LOCK(vb);
vtbuf_fill(vb, r, c);
+ vtbuf_dirty_locked(vb, r);
VTBUF_UNLOCK(vb);
-
- vtbuf_dirty(vb, r);
}
static void
@@ -531,8 +537,8 @@ vtbuf_putchar(struct vt_buf *vb, const term_pos_t *p, term_char_t c)
if (row[p->tp_col] != c) {
VTBUF_LOCK(vb);
row[p->tp_col] = c;
+ vtbuf_dirty_cell_locked(vb, p);
VTBUF_UNLOCK(vb);
- vtbuf_dirty_cell(vb, p);
}
}
@@ -541,9 +547,11 @@ vtbuf_cursor_position(struct vt_buf *vb, const term_pos_t *p)
{
if (vb->vb_flags & VBF_CURSOR) {
- vtbuf_dirty_cell(vb, &vb->vb_cursor);
+ VTBUF_LOCK(vb);
+ vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
vb->vb_cursor = *p;
- vtbuf_dirty_cell(vb, &vb->vb_cursor);
+ vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
+ VTBUF_UNLOCK(vb);
} else {
vb->vb_cursor = *p;
}
@@ -724,10 +732,10 @@ vtbuf_cursor_visibility(struct vt_buf *vb, int yes)
else
vb->vb_flags &= ~VBF_CURSOR;
nflags = vb->vb_flags;
- VTBUF_UNLOCK(vb);
if (oflags != nflags)
- vtbuf_dirty_cell(vb, &vb->vb_cursor);
+ vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
+ VTBUF_UNLOCK(vb);
}
void
@@ -742,9 +750,9 @@ vtbuf_scroll_mode(struct vt_buf *vb, int yes)
else
vb->vb_flags &= ~VBF_SCROLL;
nflags = vb->vb_flags;
- VTBUF_UNLOCK(vb);
if (oflags != nflags)
- vtbuf_dirty_cell(vb, &vb->vb_cursor);
+ vtbuf_dirty_cell_locked(vb, &vb->vb_cursor);
+ VTBUF_UNLOCK(vb);
}
OpenPOWER on IntegriCloud