From owner-freebsd-current@FreeBSD.ORG Thu Apr 3 13:48:23 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 84A2CC98 for ; Thu, 3 Apr 2014 13:48:23 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0C019E5A for ; Thu, 3 Apr 2014 13:48:22 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.8/8.14.8) with ESMTP id s33DmGm6099557; Thu, 3 Apr 2014 16:48:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua s33DmGm6099557 Received: (from kostik@localhost) by tom.home (8.14.8/8.14.8/Submit) id s33DmEU7099556; Thu, 3 Apr 2014 16:48:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 3 Apr 2014 16:48:14 +0300 From: Konstantin Belousov To: Kohji Okuno Subject: Re: kevent has bug? Message-ID: <20140403134814.GT21331@kib.kiev.ua> References: <20140402120745.GN21331@kib.kiev.ua> <20140402164542.GC3270@funkthat.com> <20140402174400.GR21331@kib.kiev.ua> <20140403.182656.1696050559410663288.okuno.kohji@jp.panasonic.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="u+HAydxlPP+oPOdi" Content-Disposition: inline In-Reply-To: <20140403.182656.1696050559410663288.okuno.kohji@jp.panasonic.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 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: Thu, 03 Apr 2014 13:48:23 -0000 --u+HAydxlPP+oPOdi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Apr 03, 2014 at 06:26:56PM +0900, Kohji Okuno wrote: > > The done_ev_add case is indeed missed in my patch, thank you for noting. > > The case of EV_ADD does not need the KN_SCAN workaround, IMO, since the > > race is possible just by the nature of adding the knote. > I think, we should add KN_SCAN after knote_attach() in > kqueue_register(), too. What do you think about this? See above, I noted this case in the previous mail. This may be elaborated. First, I think it is technically incorrect to allow the event notification before the f_attach() method is finished. So the KN_SCAN flag could be set only after f_attach() call, but due to both kq and knlist not locked there, we still have the same race. And this race is in fact acceptable, since it is the race between application calling EV_ADD, and external event occuring, which cannot be avoided. Until the kevent(EV_ADD) syscall returned, we do not have an obligation to report the event from the kqfd. Having the race somewhat bigger by not setting KN_SCAN is fine in my opinion. --u+HAydxlPP+oPOdi Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTPWaeAAoJEJDCuSvBvK1BDRwP/2L0d3i4RjQSopdNcrnoo+tl W+ITV0PYmSLDQ9T98Mq9uSsLhB/e2HQgnwg9dY7oJ0GNvOaNOSVxn3ntutsd2jeT JvIy/8fEGsKpFbhLxjbU7aTlBHsAPadFVBCuwpQQs20nCUcK7kuEbYjvMfIu3/kO ycGjM25YMgeFlmSkmngcehWziHhRe0oJ195ftl1ThL3KwX5rKHTDfZ9SSny8PdqN c7DHP+aBL/r3jxgbNMrrZ3NIPnQsXGXo4UYymgsAedKeNr3K0pgUzyhdQnL775Y8 sHtgPk4oq76Bt4F28LVSm7AzPlyMALRnvfe7j/fz3jmSEVCMOxqFXtHhITQS52Ze H1K55fy8HvzrxqnzEBWLFN6sN8YVZPzDD6n3+5C69RdOPWORxIp8Adx/tePClTme F9wx99dGd8caFUvoKBDC9uaX06fltvTZ3ovB8es0HE8kQS2pI29+egC9d8UgFLIc lHPmwyds7RxITUjS1PudE5K4jqwi0ujWxQeHNrgdxm5hgDtuP0d+Gvi3bgPLQXoz ImhkShtkG2StOS18GIoneWFfQHP7TZab5ayQBDn546LfJDAiAy0UJCZYWJ/I1XKW shHBXNy+2OdUErAPekLSbu0BimsBRn3kp3vnGchW5SOj/xHEt9FofO7P9JoYRrlO xoEI0KYN4tb44Nst6cy4 =g7Ji -----END PGP SIGNATURE----- --u+HAydxlPP+oPOdi--