From nobody Sun Feb 8 10:09:19 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 1516395877094769.5132063091395; Fri, 19 Jan 2018 13:04:37 -0800 (PST) Received: from localhost ([::1]:44761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecdpy-0005re-D6 for importer@patchew.org; Fri, 19 Jan 2018 16:04:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecdkd-0001X6-PA for qemu-devel@nongnu.org; Fri, 19 Jan 2018 15:59:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecdkc-0005vU-VI for qemu-devel@nongnu.org; Fri, 19 Jan 2018 15:59:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59686) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ecdkY-0005t4-0D; Fri, 19 Jan 2018 15:58:58 -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 1182D5F22; Fri, 19 Jan 2018 20:58:57 +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 C89575C1B7; Fri, 19 Jan 2018 20:58:54 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org Date: Fri, 19 Jan 2018 15:58:35 -0500 Message-Id: <20180119205847.7141-2-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:58:57 +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 01/13] blockjob: record time of last entrance 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" The mirror job makes a semi-inaccurate record of the last time we yielded by recording the last time we left a "pause", but this doesn't always correlate to the time we actually last successfully ceded control. Record the time we last *exited* a yield centrally. In other words, record the time we began execution of this job to know how long we have been selfish for. Signed-off-by: John Snow --- block/mirror.c | 8 ++------ blockjob.c | 2 ++ include/block/blockjob.h | 5 +++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index c9badc1203..88f4e8964d 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -63,7 +63,6 @@ typedef struct MirrorBlockJob { QSIMPLEQ_HEAD(, MirrorBuffer) buf_free; int buf_free_count; =20 - uint64_t last_pause_ns; unsigned long *in_flight_bitmap; int in_flight; int64_t bytes_in_flight; @@ -596,8 +595,7 @@ static void mirror_throttle(MirrorBlockJob *s) { int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); =20 - if (now - s->last_pause_ns > SLICE_TIME) { - s->last_pause_ns =3D now; + if (now - s->common.last_enter_ns > SLICE_TIME) { block_job_sleep_ns(&s->common, 0); } else { block_job_pause_point(&s->common); @@ -769,7 +767,6 @@ static void coroutine_fn mirror_run(void *opaque) =20 mirror_free_init(s); =20 - s->last_pause_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); if (!s->is_none_mode) { ret =3D mirror_dirty_init(s); if (ret < 0 || block_job_is_cancelled(&s->common)) { @@ -803,7 +800,7 @@ static void coroutine_fn mirror_run(void *opaque) * We do so every SLICE_TIME nanoseconds, or when there is an erro= r, * or when the source is clean, whichever comes first. */ - delta =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->last_pause_n= s; + delta =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->common.last_= enter_ns; if (delta < SLICE_TIME && s->common.iostatus =3D=3D BLOCK_DEVICE_IO_STATUS_OK) { if (s->in_flight >=3D MAX_IN_FLIGHT || s->buf_free_count =3D= =3D 0 || @@ -878,7 +875,6 @@ static void coroutine_fn mirror_run(void *opaque) 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); } - s->last_pause_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); } =20 immediate_exit: diff --git a/blockjob.c b/blockjob.c index f5cea84e73..2a9ff66b95 100644 --- a/blockjob.c +++ b/blockjob.c @@ -321,6 +321,7 @@ void block_job_start(BlockJob *job) job->pause_count--; job->busy =3D true; job->paused =3D false; + job->last_enter_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); bdrv_coroutine_enter(blk_bs(job->blk), job->co); } =20 @@ -786,6 +787,7 @@ static void block_job_do_yield(BlockJob *job, uint64_t = ns) job->busy =3D false; block_job_unlock(); qemu_coroutine_yield(); + job->last_enter_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); =20 /* Set by block_job_enter before re-entering the coroutine. */ assert(job->busy); diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 00403d9482..e965845c94 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -141,6 +141,11 @@ typedef struct BlockJob { */ QEMUTimer sleep_timer; =20 + /** + * Timestamp of the last yield + */ + uint64_t last_enter_ns; + /** Non-NULL if this job is part of a transaction */ BlockJobTxn *txn; QLIST_ENTRY(BlockJob) txn_list; --=20 2.14.3