Date: Thu, 11 Jun 2026 23:56:35 +0000 From: Aleksandr Rybalko <ray@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 1f68ca5802db - main - vt: Do not lock request comming from terminal Message-ID: <6a2b4b33.3f198.77e2d1ed@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by ray: URL: https://cgit.FreeBSD.org/src/commit/?id=1f68ca5802db91bd9725bcdbf55932e104dbe95d commit 1f68ca5802db91bd9725bcdbf55932e104dbe95d Author: Aleksandr Rybalko <ray@FreeBSD.org> AuthorDate: 2026-06-11 13:33:49 +0000 Commit: Aleksandr Rybalko <ray@FreeBSD.org> CommitDate: 2026-06-11 23:56:03 +0000 vt: Do not lock request comming from terminal only those originated by mouse. Because the terminal surrounds requests to vt(4) with locking. Reported by: bz, adrian Reviewed by: adrian, glebius Approved by: glebius (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D57442 --- sys/dev/vt/vt_buf.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index 9b65a7cb889c..ec08967232f4 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -45,6 +45,7 @@ static MALLOC_DEFINE(M_VTBUF, "vtbuf", "vt buffer"); #define VTBUF_LOCK(vb) mtx_lock_spin(&(vb)->vb_lock) #define VTBUF_UNLOCK(vb) mtx_unlock_spin(&(vb)->vb_lock) +#define VTBUF_LOCK_OWNED(vb) mtx_owned(&(vb)->vb_lock) #define POS_INDEX(c, r) (((r) << 12) + (c)) #define POS_COPY(d, s) do { \ @@ -740,9 +741,19 @@ vtbuf_flush_mark(struct vt_buf *vb) area.tr_end.tp_col = vb->vb_scr_size.tp_col; area.tr_end.tp_row = MAX(s, e) + 1; - VTBUF_LOCK(vb); - vtbuf_dirty(vb, &area); - VTBUF_UNLOCK(vb); + /* + * If the request originates from a keyboard, the vtbuf is + * locked by teken for the entire duration of the request. + * For all other sources, we avoid holding the spinlock for + * extended periods. + */ + if (VTBUF_LOCK_OWNED(vb)) { + vtbuf_dirty(vb, &area); + } else { + VTBUF_LOCK(vb); + vtbuf_dirty(vb, &area); + VTBUF_UNLOCK(vb); + } } }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a2b4b33.3f198.77e2d1ed>
