From owner-freebsd-current@FreeBSD.ORG  Thu Apr  3 22:55:08 2014
Return-Path: <owner-freebsd-current@FreeBSD.ORG>
Delivered-To: freebsd-current@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id 2713EAF1
 for <freebsd-current@freebsd.org>; Thu,  3 Apr 2014 22:55:08 +0000 (UTC)
Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20])
 by mx1.freebsd.org (Postfix) with ESMTP id C02D99BA
 for <freebsd-current@freebsd.org>; Thu,  3 Apr 2014 22:55:07 +0000 (UTC)
Received: from mail-gw.jp.panasonic.com ([157.8.1.157])
 by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile13) with ESMTP id
 s33Mt6De024572; Fri, 4 Apr 2014 07:55:06 +0900 (JST)
Received: from epochmail.jp.panasonic.com ([157.8.1.130])
 by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili15) with ESMTP id s33Mt6B05801;
 Fri, 4 Apr 2014 07:55:06 +0900
Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi16) id
 s33Mt6AE011015; Fri, 4 Apr 2014 07:55:06 +0900
Received: from localhost
 by lomi16.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id
 s33Mt5kV010981; Fri, 4 Apr 2014 07:55:05 +0900
Date: Fri, 04 Apr 2014 07:55:05 +0900 (JST)
Message-Id: <20140404.075505.349505214846463043.okuno.kohji@jp.panasonic.com>
To: kostikbel@gmail.com
Subject: Re: kevent has bug?
From: Kohji Okuno <okuno.kohji@jp.panasonic.com>
In-Reply-To: <20140403134814.GT21331@kib.kiev.ua>
References: <20140402174400.GR21331@kib.kiev.ua>
 <20140403.182656.1696050559410663288.okuno.kohji@jp.panasonic.com>
 <20140403134814.GT21331@kib.kiev.ua>
Organization: Panasonic Corporation
X-Mailer: Mew version 6.5 on Emacs 24.3 / Mule 6.0 (HANACHIRUSATO)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Cc: freebsd-current@freebsd.org, okuno.kohji@jp.panasonic.com
X-BeenThere: freebsd-current@freebsd.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: Discussions about the use of FreeBSD-current
 <freebsd-current.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-current>, 
 <mailto:freebsd-current-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current/>
List-Post: <mailto:freebsd-current@freebsd.org>
List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>,
 <mailto:freebsd-current-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 03 Apr 2014 22:55:08 -0000

From: Konstantin Belousov <kostikbel@gmail.com>
Date: Thu, 3 Apr 2014 16:48:14 +0300
> 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.

Hi,

Thank you for your detailed commnet. And I uderstood about your opinion.
By the way, do you commit your change to HEAD?

Regards,
 Kohji Okuno