From owner-svn-src-head@FreeBSD.ORG Thu Oct 23 20:44:03 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6981999E; Thu, 23 Oct 2014 20:44:03 +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 3E2A7E18; Thu, 23 Oct 2014 20:44:03 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 7D0AFB98D; Thu, 23 Oct 2014 16:44:01 -0400 (EDT) From: John Baldwin To: Adrian Chadd Subject: Re: svn commit: r273549 - head/sys/kern Date: Thu, 23 Oct 2014 16:32:52 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <201410231535.s9NFZlbn002656@svn.freebsd.org> <20E7F407-9DC5-4A59-BC1C-7B868C31EF52@FreeBSD.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201410231632.53172.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 23 Oct 2014 16:44:01 -0400 (EDT) Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Edward Tomasz =?utf-8?q?Napiera=C5=82a?= , Mateusz Guzik X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Oct 2014 20:44:03 -0000 On Thursday, October 23, 2014 3:39:39 pm Adrian Chadd wrote: > Please back this out; it looks like the lock is protecting sf_si. The followup fix should be fine. The lock does indeed protect sf_si, but t= he value can only transition from non-NULL to NULL at this point, so if it is =3D=3D= NULL without the lock, it is safe to assume it has already been cleared. > -adrian >=20 > On 23 October 2014 11:45, Edward Tomasz Napiera=C5=82a wrote: > > Dnia 23 pa=C5=BA 2014 o godz. 20:38 John Baldwin napi= sa=C5=82(a): > > > >>> On Thursday, October 23, 2014 11:35:47 am Mateusz Guzik wrote: > >>> Author: mjg > >>> Date: Thu Oct 23 15:35:47 2014 > >>> New Revision: 273549 > >>> URL: https://svnweb.freebsd.org/changeset/base/273549 > >>> > >>> Log: > >>> Avoid taking the lock in selfdfree when not needed. > >>> > >>> Modified: > >>> head/sys/kern/sys_generic.c > >>> > >>> Modified: head/sys/kern/sys_generic.c > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > >>> --- head/sys/kern/sys_generic.c Thu Oct 23 15:16:40 2014 (r2735= 48) > >>> +++ head/sys/kern/sys_generic.c Thu Oct 23 15:35:47 2014 (r2735= 49) > >>> @@ -1600,10 +1600,11 @@ static void > >>> selfdfree(struct seltd *stp, struct selfd *sfp) > >>> { > >>> STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); > >>> - mtx_lock(sfp->sf_mtx); > >>> - if (sfp->sf_si) > >>> + if (sfp->sf_si !=3D NULL) { > >>> + mtx_lock(sfp->sf_mtx); > >>> TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); > >>> - mtx_unlock(sfp->sf_mtx); > >>> + mtx_unlock(sfp->sf_mtx); > >>> + } > >>> uma_zfree(selfd_zone, sfp); > >> > >> How do you ensure that the value you read for sf_si here is up to date= ? In > >> particular, if a thread is selecting on multiple fds and one awakens i= t, > >> another fd can invoke selwakeup() while the thread is in seltdclear(). > >> In that case, you might see a stale value of sf_si and not realize it = is > >> cleared by the selwakeup() after you get the lock and you will invoke > >> TAILQ_REMOVE an extra time. > > > > FWIW, I've just hit a panic in selfdfree(). > > > > >=20 >=20 =2D-=20 John Baldwin