From 5b7d9ae2fd435be7eb653ac3eb5d66e9f3d55a52 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Tue, 6 Sep 2016 17:16:59 +0000 Subject: [PATCH] cv: do a lockless check for no waiters in cv_signal and cv_broadcastpri In case of some consumers like zfs there are no waiters vast majority of the time Reviewed by: jhb MFC after: 1 week --- sys/kern/kern_condvar.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c index d4b477f3d59d..5b10914fe036 100644 --- a/sys/kern/kern_condvar.c +++ b/sys/kern/kern_condvar.c @@ -397,6 +397,8 @@ cv_signal(struct cv *cvp) { int wakeup_swapper; + if (cvp->cv_waiters == 0) + return; wakeup_swapper = 0; sleepq_lock(cvp); if (cvp->cv_waiters > 0) { @@ -424,6 +426,8 @@ cv_broadcastpri(struct cv *cvp, int pri) { int wakeup_swapper; + if (cvp->cv_waiters == 0) + return; /* * XXX sleepq_broadcast pri argument changed from -1 meaning * no pri to 0 meaning no pri.