From owner-svn-src-head@FreeBSD.ORG Thu Oct 23 19:39:43 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 DE2919EC; Thu, 23 Oct 2014 19:39:42 +0000 (UTC) Received: from mail-wg0-x22d.google.com (mail-wg0-x22d.google.com [IPv6:2a00:1450:400c:c00::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B546F674; Thu, 23 Oct 2014 19:39:41 +0000 (UTC) Received: by mail-wg0-f45.google.com with SMTP id m15so1862546wgh.4 for ; Thu, 23 Oct 2014 12:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=Jt4GdNFdJE99PJ4v+Tr6XZLqOzIQ3jxebHMupbTIlmk=; b=swBU3LeRGG8UK/kLLdhwx2iiT0TdvtCxf3S2vFvu6Dw35kmTe0Ndl90tJzXlXPniGa VSEp+o77VjCsuAL1cV39HzM7wbiO8P7GCzrxPo321payZLo0Ta5DFSiTSPzGKcdAL+CG yDo2XrTZ+XNlRRsYeNWU/6mRwHWq6UALGTyMbNnU57WwpODgmJWwE+Cs6s5Ncs54a59A S1ROwRG5Co+IGCvrns8oq2qvFTwxef788Wov+JXEKMS4acBrFTPM6ev6KGFU4lNGTYqL l1VheNHD+yb3uz8xpt05uLAavwX7/SnA1wMVW8qjdUsApF8M6Sh17EXnnm+/LbwWHorO vy1Q== MIME-Version: 1.0 X-Received: by 10.194.216.162 with SMTP id or2mr7720803wjc.68.1414093180007; Thu, 23 Oct 2014 12:39:40 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.216.106.136 with HTTP; Thu, 23 Oct 2014 12:39:39 -0700 (PDT) In-Reply-To: <20E7F407-9DC5-4A59-BC1C-7B868C31EF52@FreeBSD.org> References: <201410231535.s9NFZlbn002656@svn.freebsd.org> <201410231438.09220.jhb@freebsd.org> <20E7F407-9DC5-4A59-BC1C-7B868C31EF52@FreeBSD.org> Date: Thu, 23 Oct 2014 12:39:39 -0700 X-Google-Sender-Auth: CGL1LT6XCY4oV3jnlEifwmswfDY Message-ID: Subject: Re: svn commit: r273549 - head/sys/kern From: Adrian Chadd To: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Mateusz Guzik , John Baldwin 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 19:39:43 -0000 Please back this out; it looks like the lock is protecting sf_si. -adrian On 23 October 2014 11:45, Edward Tomasz Napiera=C5=82a = wrote: > Dnia 23 pa=C5=BA 2014 o godz. 20:38 John Baldwin napisa= =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 (r273548= ) >>> +++ head/sys/kern/sys_generic.c Thu Oct 23 15:35:47 2014 (r273549= ) >>> @@ -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 it, >> 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(). > >