From nobody Mon Feb 9 16:34:43 2026 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=virtuozzo.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549897076723871.4936222908965; Mon, 11 Feb 2019 06:57:56 -0800 (PST) Received: from localhost ([127.0.0.1]:51313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtD1q-00024X-Mm for importer@patchew.org; Mon, 11 Feb 2019 09:57:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtCpL-0001Fi-06 for qemu-devel@nongnu.org; Mon, 11 Feb 2019 09:44:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtCpK-0000s5-19 for qemu-devel@nongnu.org; Mon, 11 Feb 2019 09:44:54 -0500 Received: from relay.sw.ru ([185.231.240.75]:59796) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtCpE-0008Pp-CV; Mon, 11 Feb 2019 09:44:50 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gtCoo-0000WR-As; Mon, 11 Feb 2019 17:44:22 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 11 Feb 2019 17:44:16 +0300 Message-Id: <20190211144421.106232-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190211144421.106232-1-vsementsov@virtuozzo.com> References: <20190211144421.106232-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v4 4/9] qcow2-threads: qcow2_co_do_compress: protect queuing by mutex X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, mreitz@redhat.com, den@openvz.org, pbonzini@redhat.com 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" Drop dependence on AioContext lock. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Reviewed-by: Paolo Bonzini --- Notes: v4: add r-b by Alberto and Paolo. =20 Paolo asked to add some information to the commit message. I don't have good understanding of moving from "AioContext lock usage" to other locks, so I just added "Drop dependence on AioContext lock.", not being sure that it is correct or make sense. And, in the same time take both r-b's. So, hope maintainers will adjust commit message if needed. block/qcow2-threads.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/qcow2-threads.c b/block/qcow2-threads.c index 20b2616529..156e0667be 100644 --- a/block/qcow2-threads.c +++ b/block/qcow2-threads.c @@ -158,15 +158,19 @@ qcow2_co_do_compress(BlockDriverState *bs, void *dest= , size_t dest_size, .func =3D func, }; =20 + qemu_co_mutex_lock(&s->lock); while (s->nb_compress_threads >=3D MAX_COMPRESS_THREADS) { - qemu_co_queue_wait(&s->compress_wait_queue, NULL); + qemu_co_queue_wait(&s->compress_wait_queue, &s->lock); } - s->nb_compress_threads++; + qemu_co_mutex_unlock(&s->lock); + thread_pool_submit_co(pool, qcow2_compress_pool_func, &arg); - s->nb_compress_threads--; =20 + qemu_co_mutex_lock(&s->lock); + s->nb_compress_threads--; qemu_co_queue_next(&s->compress_wait_queue); + qemu_co_mutex_unlock(&s->lock); =20 return arg.ret; } --=20 2.18.0