From owner-freebsd-arch@FreeBSD.ORG Wed Mar 12 15:28:06 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 863D4106566B for ; Wed, 12 Mar 2008 15:28:06 +0000 (UTC) (envelope-from cokane@cokane.org) Received: from QMTA09.emeryville.ca.mail.comcast.net (qmta09.emeryville.ca.mail.comcast.net [76.96.30.96]) by mx1.freebsd.org (Postfix) with ESMTP id 65DA88FC20 for ; Wed, 12 Mar 2008 15:28:05 +0000 (UTC) (envelope-from cokane@cokane.org) Received: from OMTA12.emeryville.ca.mail.comcast.net ([76.96.30.44]) by QMTA09.emeryville.ca.mail.comcast.net with comcast id 0EVA1Z0010x6nqcA902u00; Wed, 12 Mar 2008 15:11:13 +0000 Received: from discordia ([24.61.189.203]) by OMTA12.emeryville.ca.mail.comcast.net with comcast id 0FC21Z00H4PktZC8Y00000; Wed, 12 Mar 2008 15:12:03 +0000 X-Authority-Analysis: v=1.0 c=1 a=yWIViUiLWPYA:10 a=i5KzmmKIZ9Ex48Ii2mMA:9 a=QSIy1mGstWZsU_lFX9-BSgP05_sA:4 a=oltf0pfCdT4A:10 a=-rtcXVvtY7498SX-e9UA:9 a=lEhTTu5oXNJMJ4XxhzkA:7 a=n-E81eKMzrkRIg9F2d6QuEMDThgA:4 a=NfA2RSpTaHsA:10 Received: by discordia (Postfix, from userid 103) id 429AC1636FA; Wed, 12 Mar 2008 11:12:02 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.1.8-gr1 (2007-02-13) on discordia X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.8-gr1 Received: from [172.20.1.3] (erwin.int.cokane.org [172.20.1.3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by discordia (Postfix) with ESMTP id D1E001636F8; Wed, 12 Mar 2008 11:11:50 -0400 (EDT) Message-ID: <47D7F1EC.6040802@cokane.org> Date: Wed, 12 Mar 2008 11:08:28 -0400 From: Coleman Kane User-Agent: Thunderbird 2.0.0.12 (X11/20080304) MIME-Version: 1.0 To: obrien@FreeBSD.org References: <47D7C25D.5070908@cokane.org> <200803120945.29018.jhb@freebsd.org> <47D7E5BF.2060102@cokane.org> <20080312145734.GB26812@dragon.NUXI.org> In-Reply-To: <20080312145734.GB26812@dragon.NUXI.org> Content-Type: multipart/mixed; boundary="------------020807070709030700060709" Cc: arch@FreeBSD.org, "jh >> John Baldwin" Subject: Re: SMPTODO: remove timeout(9) from ffs_softdep.c X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Mar 2008 15:28:06 -0000 This is a multi-part message in MIME format. --------------020807070709030700060709 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit David O'Brien wrote: > On Wed, Mar 12, 2008 at 10:16:31AM -0400, Coleman Kane wrote: > >> I am attaching the revised patch. >> > .. > >> + callout_reset(&softdep_callout, tickdelay > 2 ? tickdelay : 2, pause_timer, 0); >> > > Wrap long line. > > >> + /* The callout_ API has acquired mtx and will hold it around this function call. */ >> > > Ditto. > > >> + callout_reset(&softdep_callout, tickdelay > 2 ? tickdelay : 2, pause_timer, 0); >> > > Ditto. > Third try at the patch, properly adjusting my vim tabs to 8 spaces as they should be so that I can follow style(9). -- Coleman Kane --------------020807070709030700060709 Content-Type: text/x-patch; name="ffs_softdep.c-newcallout3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ffs_softdep.c-newcallout3.diff" diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 3e8ba26..457ed49 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -664,7 +664,7 @@ static int maxindirdeps = 50; /* max number of indirdeps before slowdown */ static int tickdelay = 2; /* number of ticks to pause during slowdown */ static int proc_waiting; /* tracks whether we have a timeout posted */ static int *stat_countp; /* statistic to count in proc_waiting timeout */ -static struct callout_handle handle; /* handle on posted proc_waiting timeout */ +static struct callout softdep_callout; static int req_pending; static int req_clear_inodedeps; /* syncer process flush some inodedeps */ #define FLUSH_INODES 1 @@ -1394,6 +1394,9 @@ softdep_initialize() bioops.io_complete = softdep_disk_write_complete; bioops.io_deallocate = softdep_deallocate_dependencies; bioops.io_countdeps = softdep_count_dependencies; + + /* Initialize the callout with an mtx. */ + callout_init_mtx(&softdep_callout, &lk, 0); } /* @@ -1404,6 +1407,7 @@ void softdep_uninitialize() { + callout_drain(&softdep_callout); hashdestroy(pagedep_hashtbl, M_PAGEDEP, pagedep_hash); hashdestroy(inodedep_hashtbl, M_INODEDEP, inodedep_hash); hashdestroy(newblk_hashtbl, M_NEWBLK, newblk_hash); @@ -5858,8 +5862,10 @@ request_cleanup(mp, resource) * We wait at most tickdelay before proceeding in any case. */ proc_waiting += 1; - if (handle.callout == NULL) - handle = timeout(pause_timer, 0, tickdelay > 2 ? tickdelay : 2); + if (callout_pending(&softdep_callout) == FALSE) { + callout_reset(&softdep_callout, tickdelay > 2 ? tickdelay : 2, + pause_timer, 0); + } msleep((caddr_t)&proc_waiting, &lk, PPAUSE, "softupdate", 0); proc_waiting -= 1; return (1); @@ -5874,14 +5880,16 @@ pause_timer(arg) void *arg; { - ACQUIRE_LOCK(&lk); + /* + * The callout_ API has acquired mtx and will hold it around this + * function call. + */ *stat_countp += 1; wakeup_one(&proc_waiting); - if (proc_waiting > 0) - handle = timeout(pause_timer, 0, tickdelay > 2 ? tickdelay : 2); - else - handle.callout = NULL; - FREE_LOCK(&lk); + if (proc_waiting > 0) { + callout_reset(&softdep_callout, tickdelay > 2 ? tickdelay : 2, + pause_timer, 0); + } } /* --------------020807070709030700060709--