From nobody Sat May 18 21:26:36 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=1586337203; cv=none; d=zohomail.com; s=zohoarc; b=c80oybA/KBfm/OnEdkG1JwNMfLruqzG1O6hsOpdli9D1totUUqUprRJbhgvMpyq2IIP45zD8iNf2gv49jdJI/9KX0EDAsv8Cg3RSj1473E79Ch+FAjHvUwcsCqKQfiwMUe4MqfIEwMxxhtG1GY+tMUISfa3QnqvxuH3IkRTNpGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586337203; 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=+OnMlkR57OpXijgZ9SMDHND6/b9Z/s6xw8PDZc3TL68=; b=SfbuEAdHMtbZHy2bB+4wAEEMT/8xENZEMmV6eSwPVN2lWRAG4qEgaFWlnC46rWbPMakhcxxA8OQ1iqVkQWbMDSu6Qf9BAnJ4UQCIqQRcw4XEfSPwzts9w1LG6Iud1jzzF40DXCaR38F1zwj7lERAZZpjIL0ygz7Fv0jTVKNNke4= 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 1586337203027530.5054938790498; Wed, 8 Apr 2020 02:13:23 -0700 (PDT) Received: from localhost ([::1]:60890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jM6lt-0008Bv-Pt for importer@patchew.org; Wed, 08 Apr 2020 05:13:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36008) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jM6kT-0006Rh-Kg for qemu-devel@nongnu.org; Wed, 08 Apr 2020 05:11:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jM6kR-0002TJ-DZ for qemu-devel@nongnu.org; Wed, 08 Apr 2020 05:11:53 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36438 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jM6kR-0002Sp-A6 for qemu-devel@nongnu.org; Wed, 08 Apr 2020 05:11:51 -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-302-FHyhIlw8MGa3cs-6_gpo9g-1; Wed, 08 Apr 2020 05:11:49 -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 2A9ED18B9FC8; Wed, 8 Apr 2020 09:11:46 +0000 (UTC) Received: from localhost (ovpn-114-249.ams2.redhat.com [10.36.114.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E4B68C08D; Wed, 8 Apr 2020 09:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586337110; 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=+OnMlkR57OpXijgZ9SMDHND6/b9Z/s6xw8PDZc3TL68=; b=hzilrd6lg4KUZLkpUNqGuEEcjok0QZI9rdhi7LmT7kSPL0jEehMVkEBzpUTbyDwttJgH89 zryT3+KWSxq2kriN3lHLQvnqIV/SHek5ziZp7WQvaEEAnq2bXaXMFDN0ttsYFpGDOXcbYy BtzgA1OBeQFC3FSZSGvnAxzSmjC0iRU= X-MC-Unique: FHyhIlw8MGa3cs-6_gpo9g-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH for-5.0] aio-posix: signal-proof fdmon-io_uring Date: Wed, 8 Apr 2020 10:11:39 +0100 Message-Id: <20200408091139.273851-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] X-Received-From: 205.139.110.120 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 , qemu-block@nongnu.org, Julia Suvorova , Stefan Hajnoczi , Paolo Bonzini , sgarzare@redhat.com 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" The io_uring_enter(2) syscall returns with errno=3DEINTR when interrupted by a signal. Retry the syscall in this case. It's essential to do this in the io_uring_submit_and_wait() case. My interpretation of the Linux v5.5 io_uring_enter(2) code is that it shouldn't affect the io_uring_submit() case, but there is no guarantee this will always be the case. Let's check for -EINTR around both APIs. Note that the liburing APIs have -errno return values. Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella --- util/fdmon-io_uring.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c index b4d6109f20..d5a80ed6fb 100644 --- a/util/fdmon-io_uring.c +++ b/util/fdmon-io_uring.c @@ -88,7 +88,10 @@ static struct io_uring_sqe *get_sqe(AioContext *ctx) } =20 /* No free sqes left, submit pending sqes first */ - ret =3D io_uring_submit(ring); + do { + ret =3D io_uring_submit(ring); + } while (ret =3D=3D -EINTR); + assert(ret > 1); sqe =3D io_uring_get_sqe(ring); assert(sqe); @@ -282,7 +285,10 @@ static int fdmon_io_uring_wait(AioContext *ctx, AioHan= dlerList *ready_list, =20 fill_sq_ring(ctx); =20 - ret =3D io_uring_submit_and_wait(&ctx->fdmon_io_uring, wait_nr); + do { + ret =3D io_uring_submit_and_wait(&ctx->fdmon_io_uring, wait_nr); + } while (ret =3D=3D -EINTR); + assert(ret >=3D 0); =20 return process_cq_ring(ctx, ready_list); --=20 2.25.1