From nobody Mon Feb 9 20:11:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1591815920; cv=none; d=zohomail.com; s=zohoarc; b=PfaGyFaqp7HkGF5TguW+NhrX/1Y32Z71Qiq1F1O17w7uVnafm+OK3B/h7lRigeM9MMzh+OXTDF+CuxjuyR3jLU2wUW32q9vLB1606+PQvvBYQ6LPh/8WE7C1gn4gSE2JvKZNmBIDOQyPx2sQfV3s7AyRfZ+PeFfbUZa1Euh3R0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591815920; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=IkKHpC84JxttkslZjE0DAaXHAD5OY3iW2DGk/tbYTig=; b=GPhPb3hFOf4Ui74ySbsJ6p1/lhgOhqetW2wzMc4jcvo+kecnKJEf2WVXiyyD5fDUQWud9b0Q4IzlyLe8o16iy0uQuaLcY3q/3TAnwtZrUSFk9RIUAN/TOtrEB0nYthjd+/V8iut/tKQSdXZlqJjDSRT/Z3xG4GfJwl0HFTFvhqw= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1591815920613100.51527743880877; Wed, 10 Jun 2020 12:05:20 -0700 (PDT) Received: from localhost ([::1]:60272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jj62J-0001uJ-0X for importer@patchew.org; Wed, 10 Jun 2020 15:05:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jj5yD-0005v5-GP; Wed, 10 Jun 2020 15:01:06 -0400 Received: from relay.sw.ru ([185.231.240.75]:42684 helo=relay3.sw.ru) by eggs.gnu.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jj5yA-0005PX-9y; Wed, 10 Jun 2020 15:01:05 -0400 Received: from [192.168.15.9] (helo=iris.lishka.ru) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1jj5y6-0007vZ-CD; Wed, 10 Jun 2020 22:00:58 +0300 From: "Denis V. Lunev" To: qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Date: Wed, 10 Jun 2020 22:00:57 +0300 Message-Id: <20200610190058.10781-2-den@openvz.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200610190058.10781-1-den@openvz.org> References: <20200610190058.10781-1-den@openvz.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; Received-SPF: pass client-ip=185.231.240.75; envelope-from=den@openvz.org; helo=relay3.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/10 14:58:35 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Kevin Wolf , "Denis V. Lunev" , Vladimir Sementsov-Ogievskiy , Denis Plotnikov , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The patch preserves the constraint that the only waiter is allowed. The patch renames AioTaskPool->main_co to wake_co and removes AioTaskPool->waiting flag. wake_co keeps coroutine, which is waiting for wakeup on worker completion. Thus 'waiting' flag in this semantics is equivalent to 'wake_co !=3D NULL'. Signed-off-by: Denis V. Lunev CC: Kevin Wolf CC: Max Reitz CC: Vladimir Sementsov-Ogievskiy CC: Denis Plotnikov --- block/aio_task.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/block/aio_task.c b/block/aio_task.c index 88989fa248..5183b0729d 100644 --- a/block/aio_task.c +++ b/block/aio_task.c @@ -27,11 +27,10 @@ #include "block/aio_task.h" =20 struct AioTaskPool { - Coroutine *main_co; + Coroutine *wake_co; int status; int max_busy_tasks; int busy_tasks; - bool waiting; }; =20 static void coroutine_fn aio_task_co(void *opaque) @@ -52,21 +51,21 @@ static void coroutine_fn aio_task_co(void *opaque) =20 g_free(task); =20 - if (pool->waiting) { - pool->waiting =3D false; - aio_co_wake(pool->main_co); + if (pool->wake_co !=3D NULL) { + aio_co_wake(pool->wake_co); + pool->wake_co =3D NULL; } } =20 void coroutine_fn aio_task_pool_wait_one(AioTaskPool *pool) { assert(pool->busy_tasks > 0); - assert(qemu_coroutine_self() =3D=3D pool->main_co); + assert(pool->wake_co =3D=3D NULL); =20 - pool->waiting =3D true; + pool->wake_co =3D qemu_coroutine_self(); qemu_coroutine_yield(); =20 - assert(!pool->waiting); + assert(pool->wake_co =3D=3D NULL); assert(pool->busy_tasks < pool->max_busy_tasks); } =20 @@ -98,7 +97,7 @@ AioTaskPool *coroutine_fn aio_task_pool_new(int max_busy_= tasks) { AioTaskPool *pool =3D g_new0(AioTaskPool, 1); =20 - pool->main_co =3D qemu_coroutine_self(); + pool->wake_co =3D NULL; pool->max_busy_tasks =3D max_busy_tasks; =20 return pool; --=20 2.17.1