From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZH3ip-0005EX-CG for qemu-devel@nongnu.org; Mon, 20 Jul 2015 01:34:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZH3il-0006aJ-6v for qemu-devel@nongnu.org; Mon, 20 Jul 2015 01:34:39 -0400 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]:33596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZH3il-0006Zu-04 for qemu-devel@nongnu.org; Mon, 20 Jul 2015 01:34:35 -0400 Received: by wgmn9 with SMTP id n9so121799147wgm.0 for ; Sun, 19 Jul 2015 22:34:34 -0700 (PDT) Sender: Paolo Bonzini References: <1437250916-18905-1-git-send-email-pbonzini@redhat.com> <1437250916-18905-3-git-send-email-pbonzini@redhat.com> <20150720022708.GA17582@ad.nay.redhat.com> <55AC8663.7020405@redhat.com> From: Paolo Bonzini Message-ID: <55AC8867.1000400@redhat.com> Date: Mon, 20 Jul 2015 07:34:31 +0200 MIME-Version: 1.0 In-Reply-To: <55AC8663.7020405@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] AioContext: optimize clearing the EventNotifier List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, lersek@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, rjones@redhat.com On 20/07/2015 07:25, Paolo Bonzini wrote: > > /* fill pollfds */ > > + i = 0; > > QLIST_FOREACH(node, &ctx->aio_handlers, node) { > > if (!node->deleted && node->pfd.events) { > > add_pollfd(node); > > + if (node->pfd.fd == event_notifier_get_fd(&ctx->notifier)) { > > + assert(aio_notifier_idx == -1); > > + aio_notifier_idx = i; > > + } > > + i++; > > } > > } > > That's a good idea. Since aio_set_fd_handler uses QLIST_INSERT_HEAD, > perhaps we can be sure that aio_notifier_idx is always the last one > (i.e. i-1)? And the same can be done on Windows, I think. BTW, if this is not true I think I prefer the optimization with atomics. But if it's true that we can just use i-1, this one is better. Paolo