From owner-cvs-src@FreeBSD.ORG Wed Sep 21 20:12:59 2005 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7850216A41F; Wed, 21 Sep 2005 20:12:59 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4E9B743D46; Wed, 21 Sep 2005 20:12:58 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from [10.50.41.233] (Not Verified[10.50.41.233]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Wed, 21 Sep 2005 16:28:46 -0400 From: John Baldwin To: Gleb Smirnoff Date: Wed, 21 Sep 2005 15:45:37 -0400 User-Agent: KMail/1.8 References: <200509190310.j8J3ALgt095979@repoman.freebsd.org> <200509211455.59154.jhb@FreeBSD.org> <20050921190250.GX36166@cell.sick.ru> In-Reply-To: <20050921190250.GX36166@cell.sick.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200509211545.39246.jhb@FreeBSD.org> Cc: Robert Watson , Ruslan Ermilov , "M. Warner Losh" , cvs-src@FreeBSD.org Subject: Re: cleanup of interface shutdown/detach Was: cvs commit: src/sys/dev/an X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2005 20:12:59 -0000 On Wednesday 21 September 2005 03:02 pm, Gleb Smirnoff wrote: > On Wed, Sep 21, 2005 at 02:55:57PM -0400, John Baldwin wrote: > J> > 4. Remove IFF_DRV_RUNNING check from ether_output(). > > > > J> I think you can leave #4 in if the race doesn't hurt anything. > > This check confuses people, is incorrect and useless. It confuses > people, because they think that the !IFF_DRV_RUNNING condition is > checked. It is incorrect because upper layer must not touch/look > at if_drv_flags. It is useless because the flag is checked without > driver mutex being acquired, and thus does not protect from anything. > > Yesterday I have fixed panic in em(4) that was "protected" by this > check. The correct way is to check the flag in interface start > method, with driver mutex held. It can sometimes be ok to check a flag twice to optimize the common case: if (!(foo & IF_FOO)) return; FOO_LOCK(foo); if (!(foo & IF_FOO)) { FOO_UNLOCK(foo); return; } ... FOO_UNLOCK(foo); This can be useful if IF_FOO is often false and if you don't lose anything by reading a stale value for the check (for example, if you poll it every so often then if you lose the race you just lose it until the next poll). -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org