From nobody Sun Feb 8 14:52:16 2026 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; 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 1516396239879144.0311741600126; Fri, 19 Jan 2018 13:10:39 -0800 (PST) Received: from localhost ([::1]:45078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecdvr-0002jE-6i for importer@patchew.org; Fri, 19 Jan 2018 16:10:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecdl3-0001z7-GF for qemu-devel@nongnu.org; Fri, 19 Jan 2018 15:59:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecdl2-00066g-G5 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 15:59:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecdkw-00064G-S6; Fri, 19 Jan 2018 15:59:23 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E329FA96F9; Fri, 19 Jan 2018 20:59:21 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-231.bos.redhat.com [10.18.17.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94D945C1B7; Fri, 19 Jan 2018 20:59:20 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org Date: Fri, 19 Jan 2018 15:58:45 -0500 Message-Id: <20180119205847.7141-12-jsnow@redhat.com> In-Reply-To: <20180119205847.7141-1-jsnow@redhat.com> References: <20180119205847.7141-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 19 Jan 2018 20:59:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 11/13] block/mirror: remove block_job_sleep_ns calls 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, jcody@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We're attempting to slacken the mirror loop in three different places, but we can combine these three attempts. Combine the early loop call to block_job_pause_point with the two late-loop calls to block_job_sleep_ns. When delay_ns is 0 and it has not been SLICE_TIME since the last yield, block_job_relax is merely a call to block_job_pause_point, so this should be equivalent with the exception that if we have managed to not yield at all in the last SLICE_TIME ns, we will now do so. I am not sure that condition was possible, so this loop should be equivalent. Signed-off-by: John Snow --- block/mirror.c | 22 +++++++++++----------- block/trace-events | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index a0e0044de2..192e03694f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -761,7 +761,7 @@ static void coroutine_fn mirror_run(void *opaque) assert(!s->dbi); s->dbi =3D bdrv_dirty_iter_new(s->dirty_bitmap); for (;;) { - uint64_t delay_ns =3D 0; + static uint64_t delay_ns =3D 0; int64_t cnt, delta; bool should_complete; =20 @@ -770,9 +770,16 @@ static void coroutine_fn mirror_run(void *opaque) goto immediate_exit; } =20 - block_job_pause_point(&s->common); - cnt =3D bdrv_get_dirty_count(s->dirty_bitmap); + + trace_mirror_before_relax(s, cnt, s->synced, delay_ns); + if (block_job_relax(&s->common, delay_ns)) { + if (!s->synced) { + goto immediate_exit; + } + } + delay_ns =3D 0; + /* s->common.offset contains the number of bytes already processed= so * far, cnt is the number of dirty bytes remaining and * s->bytes_in_flight is the number of bytes currently being @@ -849,15 +856,8 @@ static void coroutine_fn mirror_run(void *opaque) } =20 ret =3D 0; - trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); - if (!s->synced) { - block_job_sleep_ns(&s->common, delay_ns); - if (block_job_is_cancelled(&s->common)) { - break; - } - } else if (!should_complete) { + if (s->synced && !should_complete) { delay_ns =3D (s->in_flight =3D=3D 0 && cnt =3D=3D 0 ? SLICE_TI= ME : 0); - block_job_sleep_ns(&s->common, delay_ns); } } =20 diff --git a/block/trace-events b/block/trace-events index 11c8d5f590..60f36f929a 100644 --- a/block/trace-events +++ b/block/trace-events @@ -27,7 +27,7 @@ mirror_start(void *bs, void *s, void *opaque) "bs %p s %p= opaque %p" mirror_restart_iter(void *s, int64_t cnt) "s %p dirty count %"PRId64 mirror_before_flush(void *s) "s %p" mirror_before_drain(void *s, int64_t cnt) "s %p dirty count %"PRId64 -mirror_before_sleep(void *s, int64_t cnt, int synced, uint64_t delay_ns) "= s %p dirty count %"PRId64" synced %d delay %"PRIu64"ns" +mirror_before_relax(void *s, int64_t cnt, int synced, uint64_t delay_ns) "= s %p dirty count %"PRId64" synced %d delay %"PRIu64"ns" mirror_one_iteration(void *s, int64_t offset, uint64_t bytes) "s %p offset= %" PRId64 " bytes %" PRIu64 mirror_iteration_done(void *s, int64_t offset, uint64_t bytes, int ret) "s= %p offset %" PRId64 " bytes %" PRIu64 " ret %d" mirror_yield(void *s, int64_t cnt, int buf_free_count, int in_flight) "s %= p dirty count %"PRId64" free buffers %d in_flight %d" --=20 2.14.3