From owner-freebsd-current@FreeBSD.ORG Fri Jan 27 17:54:52 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9931C106566B; Fri, 27 Jan 2012 17:54:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 0B7778FC18; Fri, 27 Jan 2012 17:54:51 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q0RHqIhM019739 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 27 Jan 2012 19:52:18 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q0RHqIrE054373; Fri, 27 Jan 2012 19:52:18 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q0RHqIRZ054372; Fri, 27 Jan 2012 19:52:18 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 27 Jan 2012 19:52:18 +0200 From: Kostik Belousov To: Doug Ambrisko Message-ID: <20120127175218.GC2726@deviant.kiev.zoral.com.ua> References: <5EDB646F-513F-411A-ABBC-6DA555D2EAC6@averesystems.com> <201201271742.q0RHgwGS091009@ambrisko.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VcZjVMblxkg0/8Ur" Content-Disposition: inline In-Reply-To: <201201271742.q0RHgwGS091009@ambrisko.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-current@freebsd.org, Andrew Boyer Subject: Re: knlist_empty locking fix X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2012 17:54:52 -0000 --VcZjVMblxkg0/8Ur Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 27, 2012 at 09:42:58AM -0800, Doug Ambrisko wrote: > Andrew Boyer writes: > | On Jan 27, 2012, at 12:15 PM, Doug Ambrisko wrote: > |=20 > | > John Baldwin writes: > | > | Agreed, I think the missing locking should just be added to the aio= code. > | >=20 > | > Okay so then just: > | >=20 > | > Index: vfs_aio.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 > | > RCS file: /usr/local/cvsroot/freebsd/src/sys/kern/vfs_aio.c,v > | > retrieving revision 1.243.2.3.4.1 > | > diff -u -p -r1.243.2.3.4.1 vfs_aio.c > | > --- vfs_aio.c 21 Dec 2010 17:09:25 -0000 1.243.2.3.4.1 > | > +++ vfs_aio.c 27 Jan 2012 17:07:11 -0000 > | > @@ -2509,9 +2509,12 @@ static void > | > filt_aiodetach(struct knote *kn) > | > { > | > struct aiocblist *aiocbe =3D kn->kn_ptr.p_aio; > | > + struct knlist *knl =3D &aiocbe->klist; > | >=20 > | > - if (!knlist_empty(&aiocbe->klist)) > | > - knlist_remove(&aiocbe->klist, kn, 0); > | > + knl->kl_lock(knl->kl_lockarg); > | > + if (!knlist_empty(knl)) > | > + knlist_remove(knl, kn, 1); > | > + knl->kl_unlock(knl->kl_lockarg); > | > } > | >=20 > | > /* kqueue filter function */ > | >=20 > | > I was trying to be consistant with knlist_remove but this is a much > | > smaller change that can be merge to older branches. > | =20 > | Does filt_liodetach() need the same treatment? >=20 > Yes, I had that in the original. I updated that and optimized > the knl to just get the structure needed. >=20 > Index: vfs_aio.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 > RCS file: /usr/local/cvsroot/freebsd/src/sys/kern/vfs_aio.c,v > retrieving revision 1.243.2.3.4.1 > diff -u -p -r1.243.2.3.4.1 vfs_aio.c > --- vfs_aio.c 21 Dec 2010 17:09:25 -0000 1.243.2.3.4.1 > +++ vfs_aio.c 27 Jan 2012 17:35:47 -0000 > @@ -2508,10 +2508,12 @@ filt_aioattach(struct knote *kn) > static void > filt_aiodetach(struct knote *kn) > { > - struct aiocblist *aiocbe =3D kn->kn_ptr.p_aio; > + struct knlist *knl =3D &kn->kn_ptr.p_aio->klist; > =20 > - if (!knlist_empty(&aiocbe->klist)) > - knlist_remove(&aiocbe->klist, kn, 0); > + knl->kl_lock(knl->kl_lockarg); > + if (!knlist_empty(knl)) > + knlist_remove(knl, kn, 1); > + knl->kl_unlock(knl->kl_lockarg); > } > =20 > /* kqueue filter function */ > @@ -2553,10 +2555,12 @@ filt_lioattach(struct knote *kn) > static void > filt_liodetach(struct knote *kn) > { > - struct aioliojob * lj =3D kn->kn_ptr.p_lio; > + struct knlist *knl =3D &kn->kn_ptr.p_lio->klist; It is easy to be style-compiant there and move initialization of knl after the blank line. Do you need two different functions now ? I think you can leave just one. Otherwise looks fine. > =20 > - if (!knlist_empty(&lj->klist)) > - knlist_remove(&lj->klist, kn, 0); > + knl->kl_lock(knl->kl_lockarg); > + if (!knlist_empty(knl)) > + knlist_remove(knl, kn, 1); > + knl->kl_unlock(knl->kl_lockarg); > } > =20 > /* kqueue filter function */ >=20 > Thanks, >=20 > Doug A. --VcZjVMblxkg0/8Ur Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk8i5FEACgkQC3+MBN1Mb4hdCgCgo+14TtYF4K7VCahvfsZhavRQ 040AoNU2pTmCGC5g69EtH1IdoS4fwDv1 =yD6O -----END PGP SIGNATURE----- --VcZjVMblxkg0/8Ur--