From nobody Wed Nov 12 10:10:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569936679; cv=none; d=zoho.com; s=zohoarc; b=mSyNE6LBNTGi8q3gS/UH/UiGs5f09aRZ1AXMI/YBKOw80yOTorWbzmktwU3y/mG+LmxULiE4+zDTOxJxIQu6DAmDp/6EB9DmiD0EGK3CL8saykxk16P3Y8UG8ONMMbZRvQjNs57eTplhQ261pYKKDfV/yREQKdEQ5sg5PPuRFLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569936679; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Di20N4WiiQuN41mTOrqPklFmpfUdXoQiZPcRPdzsRMg=; b=AOLr2ipwerydjh/Ry7H9ZZGzpq4BYeMKL1nIhwmE1pa9EWw6Ro4Upe1oiAo/f84B64ZTmZ5ZIpDo54565FGIRxhmiuQH+o6DpE0vehIOMAflCv/Xj5NFEFhJ7ftET5EP9c3wgsmXsX797wtm14uRppD8C2mXNR3H1L/017M9c4E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569936679135503.64378498830695; Tue, 1 Oct 2019 06:31:19 -0700 (PDT) Received: from localhost ([::1]:42176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFIFF-0003cY-3e for importer@patchew.org; Tue, 01 Oct 2019 09:31:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56456) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFIAy-0000Nd-J2 for qemu-devel@nongnu.org; Tue, 01 Oct 2019 09:26:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iFIAx-0000ZA-G7 for qemu-devel@nongnu.org; Tue, 01 Oct 2019 09:26:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iFIAx-0000YR-4L for qemu-devel@nongnu.org; Tue, 01 Oct 2019 09:26:47 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60CCE30715F9; Tue, 1 Oct 2019 13:26:46 +0000 (UTC) Received: from localhost (ovpn-112-22.ams2.redhat.com [10.36.112.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01FFE60BDF; Tue, 1 Oct 2019 13:26:38 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Subject: [PATCH 3/3] win32: fix main-loop busy loop on socket/fd event Date: Tue, 1 Oct 2019 17:26:09 +0400 Message-Id: <20191001132609.23184-4-marcandre.lureau@redhat.com> In-Reply-To: <20191001132609.23184-1-marcandre.lureau@redhat.com> References: <20191001132609.23184-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 01 Oct 2019 13:26:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, James Le Cuirot , berrange@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , sw@weilnetz.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Commit 05e514b1d4d5bd4209e2c8bbc76ff05c85a235f3 introduced an AIO context optimization to avoid calling event_notifier_test_and_clear() on ctx->notifier. On Windows, the same notifier is being used to wakeup the wait on socket events (see commit d3385eb448e38f828c78f8f68ec5d79c66a58b5d). The ctx->notifier event is added to the gpoll sources in aio_set_event_notifier(), aio_ctx_check() should clear the event regardless of ctx->notified, since Windows sets the event by itself, bypassing the aio->notified. This fixes qemu not clearing the event resulting in a busy loop. Paolo suggested to me on irc to call event_notifier_test_and_clear() after select() >0 from aio-win32.c's aio_prepare. Unfortunately, not all fds associated with ctx->notifiers are in AIO fd handlers set. (qemu_set_nonblock() in util/oslib-win32.c calls qemu_fd_register()). This is essentially a v2 of a patch that was sent earlier: https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg00420.html that resurfaced when James investigated Spice performance issues on Windows: https://gitlab.freedesktop.org/spice/spice/issues/36 In order to test that patch, I simply tried running test-char on win32, and it hangs. Applying that patch solves it. QIO idle sources are not dispatched. I haven't investigated much further, I suspect source priorities and busy looping still come into play. This version keeps the "notified" field, so event_notifier_poll() should still work as expected. Cc: James Le Cuirot Signed-off-by: Marc-Andr=C3=A9 Lureau --- util/async.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/async.c b/util/async.c index 4e4c7af51e..ca83e32c7f 100644 --- a/util/async.c +++ b/util/async.c @@ -354,7 +354,11 @@ void aio_notify(AioContext *ctx) =20 void aio_notify_accept(AioContext *ctx) { - if (atomic_xchg(&ctx->notified, false)) { + if (atomic_xchg(&ctx->notified, false) +#ifdef WIN32 + || true +#endif + ) { event_notifier_test_and_clear(&ctx->notifier); } } --=20 2.23.0