git: 88c5709e91ad - main - pass(4): Don't drop the periph lock before selrecord() in passpoll()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 11 Nov 2026 14:26:23 UTC
The branch main has been updated by ken:
URL: https://cgit.FreeBSD.org/src/commit/?id=88c5709e91ad2cc6df51380673837f0ebd8a2d50
commit 88c5709e91ad2cc6df51380673837f0ebd8a2d50
Author: Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2026-11-11 14:26:19 +0000
Commit: Kenneth D. Merry <ken@FreeBSD.org>
CommitDate: 2026-11-11 14:26:19 +0000
pass(4): Don't drop the periph lock before selrecord() in passpoll()
passpoll() checked the done queue while holding the peripheral lock,
dropped the lock, and only then called selrecord(). A CCB completing
in the window between the unlock and the selrecord() call sent its
selwakeuppri() before the polling thread was on the selinfo list, so
the wakeup was lost and select(2) or poll(2) slept until another
completion arrived or the timeout expired.
Call selrecord() before dropping the lock. This lock order is
already established: passdone() calls selwakeuppri(), which takes
the selinfo lock, while holding the peripheral lock.
kqueue is not affected, since the knlist is backed by the peripheral
mutex.
Reported by: llm-postcr
Fixes: a9934668aa13
MFC after: 1 week
Sponsored by: Spectra Logic
Assisted-by: Claude Fable 5 <noreply@anthropic.com>
---
sys/cam/scsi/scsi_pass.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c
index 6bb91e453e2b..50b2c53beca6 100644
--- a/sys/cam/scsi/scsi_pass.c
+++ b/sys/cam/scsi/scsi_pass.c
@@ -2191,9 +2191,9 @@ passpoll(struct cdev *dev, int poll_events, struct thread *td)
if (!TAILQ_EMPTY(&softc->done_queue)) {
revents |= poll_events & (POLLIN | POLLRDNORM);
}
- cam_periph_unlock(periph);
if (revents == 0)
selrecord(td, &softc->read_select);
+ cam_periph_unlock(periph);
}
return (revents);