From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuf32-00086j-VH for qemu-devel@nongnu.org; Tue, 19 May 2015 06:46:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yuf2x-0005Vw-7v for qemu-devel@nongnu.org; Tue, 19 May 2015 06:46:56 -0400 Date: Tue, 19 May 2015 11:46:47 +0100 From: Stefan Hajnoczi Message-ID: <20150519104647.GB27737@stefanha-thinkpad.redhat.com> References: <1431486673-19280-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7ZAtKRhVyVSsbBD2" Content-Disposition: inline In-Reply-To: <1431486673-19280-1-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] block/mirror: Sleep periodically during bitmap scanning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: pbonzini@redhat.com, Jeff Cody , qemu-devel@nongnu.org, qemu-block@nongnu.org --7ZAtKRhVyVSsbBD2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 13, 2015 at 11:11:13AM +0800, Fam Zheng wrote: > Before, we only yield after initializing dirty bitmap, where the QMP > command would return. That may take very long, and guest IO will be > blocked. >=20 > Add sleep points like the later mirror iterations. >=20 > Signed-off-by: Fam Zheng > --- > block/mirror.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) CCing Jeff Cody for block jobs. >=20 > diff --git a/block/mirror.c b/block/mirror.c > index 1a1d997..baed225 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -467,11 +467,23 @@ static void coroutine_fn mirror_run(void *opaque) > sectors_per_chunk =3D s->granularity >> BDRV_SECTOR_BITS; > mirror_free_init(s); > =20 > + last_pause_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > if (!s->is_none_mode) { > /* First part, loop on the sectors and initialize the dirty bitm= ap. */ > BlockDriverState *base =3D s->base; > for (sector_num =3D 0; sector_num < end; ) { > int64_t next =3D (sector_num | (sectors_per_chunk - 1)) + 1; > + int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > + > + if (now - last_pause_ns > SLICE_TIME) { > + last_pause_ns =3D now; > + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, 0); > + } > + > + if (block_job_is_cancelled(&s->common)) { > + goto immediate_exit; > + } > + > ret =3D bdrv_is_allocated_above(bs, base, > sector_num, next - sector_num,= &n); > =20 > @@ -490,7 +502,6 @@ static void coroutine_fn mirror_run(void *opaque) > } > =20 > bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); > - last_pause_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > for (;;) { > uint64_t delay_ns =3D 0; > int64_t cnt; > --=20 > 2.4.0 >=20 >=20 --7ZAtKRhVyVSsbBD2 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVWxSXAAoJEJykq7OBq3PIxJoIAIBJvrlQDd/mtiXqQ1HF8mbs EzaazzKPc8rSBQYRJwfaO6lh8r3tT6gqD/LqJWhE6+n8xIYDKwXBmoqAOug2w2iO puI9N5dmC15Z0dMjqrB+azYIrJtjXIBo8uiPlUnqw+9wBijYlsLOYyNTdBRnos4u yqLg/TeeEFSGDb/W5kUW/veLC1Oft9OKFUdyGx7Kl5V2BLj+EJrcMUkixKogB07E mnGM3rvVGNScL0Vu+mHHgXP4vSB2xZ11V4uSJkmQJlTbKzXbQZ827gDTVbUYvgOm sduLNrlt3VW1SgLjEqLZavkHIRklpihWC6e0PkTifw1MkL/hWyd9jpL2+YldycU= =m46s -----END PGP SIGNATURE----- --7ZAtKRhVyVSsbBD2--