From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 9 13:28:53 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 23C5116A403 for ; Fri, 9 Mar 2007 13:28:53 +0000 (UTC) (envelope-from xdivac02@stud.fit.vutbr.cz) Received: from eva.fit.vutbr.cz (eva.fit.vutbr.cz [147.229.176.14]) by mx1.freebsd.org (Postfix) with ESMTP id A60E213C49D for ; Fri, 9 Mar 2007 13:28:52 +0000 (UTC) (envelope-from xdivac02@stud.fit.vutbr.cz) Received: from eva.fit.vutbr.cz (localhost [127.0.0.1]) by eva.fit.vutbr.cz (envelope-from xdivac02@eva.fit.vutbr.cz) (8.13.8/8.13.7) with ESMTP id l29DSpkW053331 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 9 Mar 2007 14:28:51 +0100 (CET) Received: (from xdivac02@localhost) by eva.fit.vutbr.cz (8.13.8/8.13.3/Submit) id l29DSp5B053330; Fri, 9 Mar 2007 14:28:51 +0100 (CET) Date: Fri, 9 Mar 2007 14:28:51 +0100 From: Divacky Roman To: hackers@freebsd.org Message-ID: <20070309132851.GA52655@stud.fit.vutbr.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i X-Scanned-By: MIMEDefang 2.57 on 147.229.176.14 Cc: alc@freebsd.org Subject: possibly missed wakeup in swap_pager_getpages() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2007 13:28:53 -0000 hi when looking at PR103455 I found this and I have a question.. code: swp_pager_strategy(bp); /* * wait for the page we want to complete. VPO_SWAPINPROG is always * cleared on completion. If an I/O error occurs, SWAPBLK_NONE * is set in the meta-data. */ VM_OBJECT_LOCK(object); while ((mreq->oflags & VPO_SWAPINPROG) != 0) { mreq->oflags |= VPO_WANTED; vm_page_lock_queues(); vm_page_flag_set(mreq, PG_REFERENCED); vm_page_unlock_queues(); cnt.v_intrans++; if (msleep(mreq, VM_OBJECT_MTX(object), PSWP, "swread", hz*20)) { the swp_pager_strategy() initiates IO (which should issue the wakeup() necessary for the msleep()). the problem in the PR is that the msleep() is never (within the specified 20 seconds) woken up. I wonder if this is because the wakeup arrives BEFORE the actual msleep() is issued. the page queue locking can take some time so there is a space for a missed wakeup. is my analysis correct? if so, can the race be mitigated by moving the flag setting (hence also the locking) after the msleep()? thnx roman