Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 05 Jan 2015 18:48:26 +0100
From:      Hans Petter Selasky <hps@selasky.org>
To:        John Baldwin <jhb@FreeBSD.org>, src-committers@freebsd.org,  svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r276534 - head/sys/dev/vt
Message-ID:  <54AACE6A.7020702@selasky.org>
In-Reply-To: <54AACBC4.5040802@FreeBSD.org>
References:  <201501021335.t02DZBRm015072@svn.freebsd.org> <54AACBC4.5040802@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 01/05/15 18:37, John Baldwin wrote:
> 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().
>

Right, but there is an "if" there which not always makes the assert 
visible execept for static code analysis.

--HPS




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?54AACE6A.7020702>