From owner-svn-src-all@FreeBSD.ORG Mon Jan 5 17:37:10 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 642FA900; Mon, 5 Jan 2015 17:37:10 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3CCE33652; Mon, 5 Jan 2015 17:37:10 +0000 (UTC) Received: from new-host-2.home (pool-173-70-85-31.nwrknj.fios.verizon.net [173.70.85.31]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AF1A3B91E; Mon, 5 Jan 2015 12:37:08 -0500 (EST) Message-ID: <54AACBC4.5040802@FreeBSD.org> Date: Mon, 05 Jan 2015 12:37:08 -0500 From: John Baldwin User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Hans Petter Selasky , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r276534 - head/sys/dev/vt References: <201501021335.t02DZBRm015072@svn.freebsd.org> In-Reply-To: <201501021335.t02DZBRm015072@svn.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 05 Jan 2015 12:37:08 -0500 (EST) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2015 17:37:10 -0000 On 1/2/15 8:35 AM, Hans Petter Selasky wrote: > Author: hselasky > Date: Fri Jan 2 13:35:10 2015 > New Revision: 276534 > URL: https://svnweb.freebsd.org/changeset/base/276534 > > Log: > The "vt_suspend_flush_timer()" function is sometimes called locked > which prevents us from doing a "callout_drain()" call. The callout in > question has a lock associated with it and we are not freeing the > callout. That means we can use the "callout_stop()" function to > atomically stop the callback iff the "callout_stop()" function is > called locked. This patch applies proper locking to "callout_stop()" > and replaces a "callout_drain()" with a "callout_stop()". > > Modified: head/sys/dev/vt/vt_core.c > ============================================================================== > --- head/sys/dev/vt/vt_core.c Fri Jan 2 13:15:36 2015 (r276533) > +++ head/sys/dev/vt/vt_core.c Fri Jan 2 13:35:10 2015 (r276534) > @@ -114,6 +114,7 @@ const struct terminal_class vt_termclass > > #define VT_LOCK(vd) mtx_lock(&(vd)->vd_lock) > #define VT_UNLOCK(vd) mtx_unlock(&(vd)->vd_lock) > +#define VT_LOCK_ASSERT(vd, what) mtx_assert(&(vd)->vd_lock, what) > > #define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS + \ > (vw)->vw_number) > @@ -283,12 +284,18 @@ vt_resume_flush_timer(struct vt_device * > static void > vt_suspend_flush_timer(struct vt_device *vd) > { > + /* > + * As long as this function is called locked, callout_stop() > + * has the same effect like callout_drain() with regard to > + * preventing the callback function from executing. > + */ > + VT_LOCK_ASSERT(vd, MA_OWNED); Note that this assert is redundant. callout_stop() already asserts this for a callout initialized via callout_init_mtx(). > > if (!(vd->vd_flags & VDF_ASYNC) || > !atomic_cmpset_int(&vd->vd_timer_armed, 1, 0)) > return; > > - callout_drain(&vd->vd_timer); > + callout_stop(&vd->vd_timer); > } > > static void -- John Baldwin