From owner-svn-src-head@FreeBSD.ORG Thu Oct 23 18:45:19 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 C915A2D7; Thu, 23 Oct 2014 18:45:19 +0000 (UTC) Received: from mail-lb0-x22a.google.com (mail-lb0-x22a.google.com [IPv6:2a00:1450:4010:c04::22a]) (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 8CD1EE19; Thu, 23 Oct 2014 18:45:18 +0000 (UTC) Received: by mail-lb0-f170.google.com with SMTP id u10so1367774lbd.15 for ; Thu, 23 Oct 2014 11:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=mK9rRkxKSYXy5OMwSTUojabY/90Ayj2J4+LPMWXZ4iQ=; b=Lqxw0PkxqwXdzSkFGGoMUB09yGsvnzsYXSieULDR7O1eXrffhVOEeeQaRKT4MqbOQz Etd2OINiDXtKPGd4fco03IVAOJMrLLQI1xEhXuUtLoMSh6wsYVe7O14N3KBB7fYmf8Bm HltHkojEvSGouYUhzjaA072nctiK9T9tRh1snzxSURUxK8P6En5ApsixCpGCGV1mBo2W Xy2sWmiO2NfOjujQa2MP0mgX6nKY0Y65bpJB2NqxF8mI99BrgOGoU/NYEK2YYg9RfBXv gRnsUdww0hHGSo5r5kY4M/VhY8amcMpgB9J31oiEFKw3mCUOYlJWbSF6c8Lwimw6PznI dStA== X-Received: by 10.112.26.71 with SMTP id j7mr5248609lbg.96.1414089916366; Thu, 23 Oct 2014 11:45:16 -0700 (PDT) Received: from [192.168.1.14] (aefx165.neoplus.adsl.tpnet.pl. [79.186.153.165]) by mx.google.com with ESMTPSA id i6sm1046976laf.47.2014.10.23.11.45.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 11:45:15 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: svn commit: r273549 - head/sys/kern From: =?utf-8?Q?Edward_Tomasz_Napiera=C5=82a?= X-Mailer: iPhone Mail (12A405) In-Reply-To: <201410231438.09220.jhb@freebsd.org> Date: Thu, 23 Oct 2014 20:45:13 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <20E7F407-9DC5-4A59-BC1C-7B868C31EF52@FreeBSD.org> References: <201410231535.s9NFZlbn002656@svn.freebsd.org> <201410231438.09220.jhb@freebsd.org> To: John Baldwin Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , 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 18:45:20 -0000 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 >>=20 >> Log: >> Avoid taking the lock in selfdfree when not needed. >>=20 >> Modified: >> head/sys/kern/sys_generic.c >>=20 >> 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); >=20 > How do you ensure that the value you read for sf_si here is up to date? I= n=20 > 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=20= > 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().