Reported by: bz, adrian
MFC after: 2 weeks
Details
Details
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
Updating D57442: vt: Do not lock request comming from terminal, only those originated by
mouse. Because the terminal surrounds requests to vt(4) with locking.
Comment Actions
ok, i see what's going on here. im' ok with this to unbrick -head, but personally:
- have xxx_locked() versions of functions which mtx_assert(mtx, MA_OWNED)
- have unlocked versions of functions that mtx_assert(mtx, MA_UNOWNED); grab lock; call _locked version; mtx_unlock();
- callers would then either call the xxx() version if they don't own the lock, or xxx_locked() if they already hold the lock.
If this fixes the crash then I'm going to approve it to unbrick head, but it does tell me we should do a pass or two around locking in vt.
| sys/dev/vt/vt.h | ||
|---|---|---|
| 248–251 ↗ | (On Diff #179215) | I'd suggest to just use bool locked. This is a very common style throughout the kernel in the last years. Or use Adrian's suggestion. |
| sys/dev/vt/vt_buf.c | ||
| 743–757 | Alternatively to this whole patch you can just use mtx_owned(9) and don't need to modify the function argument list: #define VTBUF_LOCK_OWNED(vb) mtx_owned(&(vb)->vb_lock)
...
static void
vtbuf_flush_mark(...
bool dounlock;
...
if (!VTBUF_LOCK_OWNED(vb)) {
dounlock = true;
VTBUF_LOCK(vb);
} else
dounlock = false;
vtbuf_dirty(vb, &area);
if (dounlock)
VTBUF_UNLOCK(vb); | |
Comment Actions
Check if lock owned.
Updating D57442: vt: Do not lock request comming from terminal, only those originated by
mouse. Because the terminal surrounds requests to vt(4) with locking.