From nobody Tue Oct 28 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516054410901148.9003062350813; Mon, 15 Jan 2018 14:13:30 -0800 (PST) Received: from localhost ([::1]:38800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebD0R-0002T5-5F for importer@patchew.org; Mon, 15 Jan 2018 17:13:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebCvh-0007PN-2c for qemu-devel@nongnu.org; Mon, 15 Jan 2018 17:08:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebCvg-0006DX-34 for qemu-devel@nongnu.org; Mon, 15 Jan 2018 17:08:32 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:46475) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebCvf-0006CW-U2; Mon, 15 Jan 2018 17:08:32 -0500 Received: by mail-wr0-x243.google.com with SMTP id g21so13212118wrb.13; Mon, 15 Jan 2018 14:08:31 -0800 (PST) Received: from donizetti.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id n74sm17351039wmi.1.2018.01.15.14.08.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Jan 2018 14:08:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y+NRW7Dr5Wv1ew5YBu802on1cGYnQSU4p/voC5el7yM=; b=HOU6fQXdQwRX4TPKsY/KW7iT7PTRvCUFq8QQVMtQcOYpZnQ1fpXwJX8qRGiUuf+kTX 8hjApg5dQvfZ29W/8RpuDtU9pKm3W94kgTLQxO/Cxeer19bGsieW1bzewUC/ZNO+xycX Sj8xyAvXHI0bGPHV+sSVca8TJEx7P9gEeIn4yO+HRtY86g/jUPamkjGpfBKOK4gXSBhO R9W5N2S1oN/Oy4dg/+lCjimkOITGAfjg1YrABSx13xEBwgLQyMvFvob+Q93UnFlUBVf2 K1Kw1Au+4R4Rq83bs8EHb7rN7qYWDJepMLJOo58kX755dJYD+YoikWok2rQTMbEN5PT/ jhtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Y+NRW7Dr5Wv1ew5YBu802on1cGYnQSU4p/voC5el7yM=; b=bE0QVsvVXZAcZVNr3dLbDBIlqAHk3R8zv27FQO1s25RkpKmYroJfuXADUFkUifID0P 4V36kMh1zdTVYjR8oJIHwFoVgUlnD8nJUdktB+bQ4dNiHRTvcDMaG3UBsaTrnQ4SNvsm hJ3MT83VZJS4xqUkqrNhMigEiDdipT43Bw5E8uEJtN8zapBeEtSQO4owH9+z2ySxzk12 cVJiwlnsuBApm1+l6lpDlIJNw1LYXyLVKkSoeoQ2V0Z3owC0cZspNjwe4CAITGnekNYk JyyMXPG+DGgQaJRec6ROa0v6ztdj4ZBOTscmHKTUU1TgXscNkXDeVDLCZmp474psgnnm AvFg== X-Gm-Message-State: AKwxytdyWEV5YS9RqDy0OJOrcyQ4kVM7yZmZm4NRRaHalFiJg77BVUC1 rKFFQsvp8sN7aIGdZ5moUf8Wunmt X-Google-Smtp-Source: ACJfBou25KnLMNK4z2s2nbJ3wOSAN0sWWYZTpgb/HkJ9vX+oWl6GZVBzcCSWPCMYhQPhtwUL4z+qCw== X-Received: by 10.223.196.147 with SMTP id m19mr22317825wrf.56.1516054110667; Mon, 15 Jan 2018 14:08:30 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 23:08:22 +0100 Message-Id: <20180115220822.10156-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180115220822.10156-1-pbonzini@redhat.com> References: <20180115220822.10156-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PATCH 4/4] curl: convert to CoQueue 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: famz@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that CoQueues can use a QemuMutex for thread-safety, there is no need for curl to roll its own coroutine queue. Coroutines can be placed directly on the queue instead of using a list of CURLAIOCBs. Signed-off-by: Paolo Bonzini --- block/curl.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/block/curl.c b/block/curl.c index 35cf417f59..cd578d3d14 100644 --- a/block/curl.c +++ b/block/curl.c @@ -101,8 +101,6 @@ typedef struct CURLAIOCB { =20 size_t start; size_t end; - - QSIMPLEQ_ENTRY(CURLAIOCB) next; } CURLAIOCB; =20 typedef struct CURLSocket { @@ -138,7 +136,7 @@ typedef struct BDRVCURLState { bool accept_range; AioContext *aio_context; QemuMutex mutex; - QSIMPLEQ_HEAD(, CURLAIOCB) free_state_waitq; + CoQueue free_state_waitq; char *username; char *password; char *proxyusername; @@ -538,7 +536,6 @@ static int curl_init_state(BDRVCURLState *s, CURLState = *state) /* Called with s->mutex held. */ static void curl_clean_state(CURLState *s) { - CURLAIOCB *next; int j; for (j =3D 0; j < CURL_NUM_ACB; j++) { assert(!s->acb[j]); @@ -556,13 +553,7 @@ static void curl_clean_state(CURLState *s) =20 s->in_use =3D 0; =20 - next =3D QSIMPLEQ_FIRST(&s->s->free_state_waitq); - if (next) { - QSIMPLEQ_REMOVE_HEAD(&s->s->free_state_waitq, next); - qemu_mutex_unlock(&s->s->mutex); - aio_co_wake(next->co); - qemu_mutex_lock(&s->s->mutex); - } + qemu_co_enter_next(&s->s->free_state_waitq, &s->s->mutex); } =20 static void curl_parse_filename(const char *filename, QDict *options, @@ -784,7 +775,7 @@ static int curl_open(BlockDriverState *bs, QDict *optio= ns, int flags, } =20 DPRINTF("CURL: Opening %s\n", file); - QSIMPLEQ_INIT(&s->free_state_waitq); + qemu_co_queue_init(&s->free_state_waitq); s->aio_context =3D bdrv_get_aio_context(bs); s->url =3D g_strdup(file); qemu_mutex_lock(&s->mutex); @@ -888,10 +879,7 @@ static void curl_setup_preadv(BlockDriverState *bs, CU= RLAIOCB *acb) if (state) { break; } - QSIMPLEQ_INSERT_TAIL(&s->free_state_waitq, acb, next); - qemu_mutex_unlock(&s->mutex); - qemu_coroutine_yield(); - qemu_mutex_lock(&s->mutex); + qemu_co_queue_wait(&s->free_state_waitq, &s->mutex); } =20 if (curl_init_state(s, state) < 0) { --=20 2.14.3