From owner-cvs-all@FreeBSD.ORG Sat Nov 6 06:29:50 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 450C616A4CE; Sat, 6 Nov 2004 06:29:50 +0000 (GMT) Received: from VARK.MIT.EDU (VARK.MIT.EDU [18.95.3.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id E9CBF43D39; Sat, 6 Nov 2004 06:29:49 +0000 (GMT) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (localhost [127.0.0.1]) by VARK.MIT.EDU (8.13.1/8.12.10) with ESMTP id iA66Tt0W002661; Sat, 6 Nov 2004 01:29:55 -0500 (EST) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.MIT.EDU (8.13.1/8.12.10/Submit) id iA66Ttc0002660; Sat, 6 Nov 2004 01:29:55 -0500 (EST) (envelope-from das@FreeBSD.ORG) Date: Sat, 6 Nov 2004 01:29:55 -0500 From: David Schultz To: John Baldwin Message-ID: <20041106062955.GA1986@VARK.MIT.EDU> Mail-Followup-To: John Baldwin , Alfred Perlstein , Alan Cox , src-committers@FreeBSD.ORG, cvs-src@FreeBSD.ORG, cvs-all@FreeBSD.ORG References: <200410311932.i9VJWvmo058193@repoman.freebsd.org> <20041101045331.GP16728@cs.rice.edu> <20041101105113.GS24892@elvis.mu.org> <200411011441.33067.jhb@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200411011441.33067.jhb@FreeBSD.org> cc: Alan Cox cc: cvs-src@FreeBSD.ORG cc: Alfred Perlstein cc: src-committers@FreeBSD.ORG cc: cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/sys/vm vm_zeroidle.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2004 06:29:50 -0000 On Mon, Nov 01, 2004, John Baldwin wrote: > On Monday 01 November 2004 05:51 am, Alfred Perlstein wrote: > > * Alan Cox [041031 20:53] wrote: > > > On Sun, Oct 31, 2004 at 07:13:17PM -0800, Alfred Perlstein wrote: > > > > * Alan Cox [041031 11:33] wrote: > > > > > alc 2004-10-31 19:32:57 UTC > > > > > > > > > > FreeBSD src repository > > > > > > > > > > Modified files: > > > > > sys/vm vm_zeroidle.c > > > > > Log: > > > > > Introduce a Boolean variable wakeup_needed to avoid repeated, > > > > > unnecessary calls to wakeup() by vm_page_zero_idle_wakeup(). > > > > > > > > > > Revision Changes Path > > > > > 1.31 +9 -2 src/sys/vm/vm_zeroidle.c > > > > > > > > Why not switch to a cv? > > > > > > Calling cv_signal repeatedly would be no better than calling wakeup() > > > repeatedly. Either way, a Boolean variable is desirable to prevent > > > unnecessary calls. > > > > Yah, I figured there would be something in the cv code to optimize > > the "no waiters" case. > > There is, though sometimes it might think there are waiters when there > actually aren't any. It doesn't look very optimized: void cv_signal(struct cv *cvp) { sleepq_lock(cvp); ^^^^^^^^^^^^^^^^^ if (cvp->cv_waiters > 0) { [...] } else sleepq_release(cvp); The mutex associated with the condition variable will be held on entry to both cv_wait() and cv_signal(), so why is the sleepqueue locked in the no waiters case?