From owner-freebsd-bugs@FreeBSD.ORG Fri Apr 22 10:20:02 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1ABEE106566B for ; Fri, 22 Apr 2011 10:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CCBC08FC16 for ; Fri, 22 Apr 2011 10:20:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p3MAK12U012811 for ; Fri, 22 Apr 2011 10:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p3MAK1XO012810; Fri, 22 Apr 2011 10:20:01 GMT (envelope-from gnats) Resent-Date: Fri, 22 Apr 2011 10:20:01 GMT Resent-Message-Id: <201104221020.p3MAK1XO012810@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Igor Soumenkov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1FA641065676 for ; Fri, 22 Apr 2011 10:14:08 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 0F6368FC08 for ; Fri, 22 Apr 2011 10:14:08 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p3MAE7s3017273 for ; Fri, 22 Apr 2011 10:14:07 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p3MAE7RA017272; Fri, 22 Apr 2011 10:14:07 GMT (envelope-from nobody) Message-Id: <201104221014.p3MAE7RA017272@red.freebsd.org> Date: Fri, 22 Apr 2011 10:14:07 GMT From: Igor Soumenkov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/156567: Add EV_CLEAR to AIO events in kqueue X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2011 10:20:02 -0000 >Number: 156567 >Category: kern >Synopsis: Add EV_CLEAR to AIO events in kqueue >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Apr 22 10:20:01 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Igor Soumenkov >Release: 8.2-STABLE >Organization: >Environment: FreeBSD igosha2 8.2-STABLE FreeBSD 8.2-STABLE #6: Fri Apr 22 13:53:04 MSD 2011 root@igosha2:/usr/obj/usr/src/sys/IGOSHA-WORK-8 amd64 >Description: Current implementation of AIO does not set the EV_CLEAR flag when adding new AIO events in the kqueue. This causes problems while fetching kevents from several threads. I can't imagine the situation when the AIO event should be read many times, so I suggest adding EV_CLEAR to all AIO events. >How-To-Repeat: Schedule aio operation, i.e. aio_read or aio_write with kqueue notification. If you use kevent in several threads, several copies of the EVFILT_AIO events will be fetched. >Fix: I suggest adding EV_CLEAR to the flags of the AIO event, since there is no way to control it with aio_ operations directly. If it is not acceptable maybe there should be a sysctl or other tunable option. Patch attached with submission follows: --- sys/kern/vfs_aio.c.old 2011-04-22 13:49:37.000000000 +0400 +++ sys/kern/vfs_aio.c 2011-04-22 13:49:45.000000000 +0400 @@ -1622,7 +1622,7 @@ kqfd = aiocbe->uaiocb.aio_sigevent.sigev_notify_kqueue; kev.ident = (uintptr_t)aiocbe->uuaiocb; kev.filter = EVFILT_AIO; - kev.flags = EV_ADD | EV_ENABLE | EV_FLAG1; + kev.flags = EV_ADD | EV_ENABLE | EV_CLEAR | EV_FLAG1; kev.data = (intptr_t)aiocbe; kev.udata = aiocbe->uaiocb.aio_sigevent.sigev_value.sival_ptr; error = kqfd_register(kqfd, &kev, td, 1); >Release-Note: >Audit-Trail: >Unformatted: