From nobody Thu May 2 21:03:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=fail; spf=pass (zohomail.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=1584635888; cv=none; d=zohomail.com; s=zohoarc; b=YL6UoxJdyDIZmRIzXxqd8m9tKErxccQdJMBtRzHWQQ68BWHvxtxNQw6YWnpBeIqQJxc0m8JvQyHviQCz32+/7rLbcwplkPUObXpdSvTd+nmJobAbjMXSPoyWykmk4VLunLajQuARlYFzkxH/jmlLRRpOa2p10X7qBKZu3r/dt9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584635888; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=pgrBJVqrDcRBvnrD83fggUJtxyGyTTnG81DGVacbk3A=; b=EWBUq15S+c0BuyLmg9ruTMsM45pxccAw7kLwKuYRbDg9GTCAkMS3LrOyfLtACRJym4wf8xaZygSmH5+8h6xBxP5Jyn7vXjWWbmocoMw2BAqt2auU1QDu/2DEq/VmYt+fhSiEF6HLfgYBx3ggMaIBhnphDw7HcQ68iz+yxJPs/ww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584635888737963.3772870205156; Thu, 19 Mar 2020 09:38:08 -0700 (PDT) Received: from localhost ([::1]:40486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEyBL-0001V8-An for importer@patchew.org; Thu, 19 Mar 2020 12:38:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51232) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEy9c-0008Rs-L9 for qemu-devel@nongnu.org; Thu, 19 Mar 2020 12:36:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEy9b-0004XA-Kc for qemu-devel@nongnu.org; Thu, 19 Mar 2020 12:36:20 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:38149) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEy9b-0004VY-GG for qemu-devel@nongnu.org; Thu, 19 Mar 2020 12:36:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-6Az1v6vcMI61YzZoSV8hHg-1; Thu, 19 Mar 2020 12:36:17 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A63961088381; Thu, 19 Mar 2020 16:36:16 +0000 (UTC) Received: from localhost (ovpn-113-148.ams2.redhat.com [10.36.113.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18EE89B919; Thu, 19 Mar 2020 16:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584635779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pgrBJVqrDcRBvnrD83fggUJtxyGyTTnG81DGVacbk3A=; b=Zw0WI8fEsDe85zCteB+ocaW4k++Wqdk8doHrBVPICcAtU9ukQ7jdHwnWLNfzy9ompjJYaI TdWTXE6aNEbF/fqWXuB/QlKZlZPg3p9MY8XHOmEXcURvPSquZ9WTQVM3agC14fjj+B+c91 +Ya6C0Ah8VqSi73zpS1rhBSHeZX2Ts8= X-MC-Unique: 6Az1v6vcMI61YzZoSV8hHg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH] aio-posix: fix io_uring with external events Date: Thu, 19 Mar 2020 16:35:59 +0000 Message-Id: <20200319163559.117903-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 216.205.24.74 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: Fam Zheng , Paolo Bonzini , Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" When external event sources are disabled fdmon-io_uring falls back to fdmon-poll. The ->need_wait() callback needs to watch for this so it can return true when external event sources are disabled. It is also necessary to call ->wait() when AioHandlers have changed because io_uring is asynchronous and we must submit new sqes. Both of these changes to ->need_wait() together fix tests/test-aio -p /aio/external-client, which failed with: test-aio: tests/test-aio.c:404: test_aio_external_client: Assertion `aio_= poll(ctx, false)' failed. Reported-by: Julia Suvorova Signed-off-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella --- util/fdmon-io_uring.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c index 893b79b622..7e143ef515 100644 --- a/util/fdmon-io_uring.c +++ b/util/fdmon-io_uring.c @@ -290,7 +290,18 @@ static int fdmon_io_uring_wait(AioContext *ctx, AioHan= dlerList *ready_list, =20 static bool fdmon_io_uring_need_wait(AioContext *ctx) { - return io_uring_cq_ready(&ctx->fdmon_io_uring); + /* Have io_uring events completed? */ + if (io_uring_cq_ready(&ctx->fdmon_io_uring)) { + return true; + } + + /* Do we need to submit new io_uring sqes? */ + if (!QSLIST_EMPTY_RCU(&ctx->submit_list)) { + return true; + } + + /* Are we falling back to fdmon-poll? */ + return atomic_read(&ctx->external_disable_cnt); } =20 static const FDMonOps fdmon_io_uring_ops =3D { --=20 2.24.1