Received: from eggs.gnu.org ([2001:4830:134:3::10]:34395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC3NU-0002QM-NL for qemu-devel@nongnu.org; Mon, 06 Jul 2015 06:11:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC3NT-0007bx-S0 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 06:11:56 -0400 Date: Mon, 6 Jul 2015 12:11:47 +0200 (CEST) From: Alexandre DERUMIER Message-ID: <947457006.7135924.1436177507489.JavaMail.zimbra@oxygem.tv> In-Reply-To: <1436153291-13908-1-git-send-email-famz@redhat.com> References: <1436153291-13908-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] blockjob: Don't sleep too short List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , qemu-devel , mreitz@redhat.com, stefanha , pbonzini , jsnow@redhat.com Works fine here, Thanks ! ----- Mail original ----- De: "Fam Zheng" =C3=80: "qemu-devel" Cc: "Kevin Wolf" , "Jeff Cody" , qemu-b= lock@nongnu.org, mreitz@redhat.com, jsnow@redhat.com, "aderumier" , "stefanha" , "pbonzini" Envoy=C3=A9: Lundi 6 Juillet 2015 05:28:11 Objet: [PATCH] blockjob: Don't sleep too short block_job_sleep_ns is called by block job coroutines to yield the=20 execution to VCPU threads and monitor etc. It is pointless to sleep for=20 0 or a few nanoseconds, because that equals to a "yield + enter" with no=20 intermission in between (the timer fires immediately in the same=20 iteration of event loop), which means other code still doesn't get a=20 fair share of main loop / BQL.=20 Trim the sleep duration with a minimum value.=20 Reported-by: Alexandre DERUMIER =20 Signed-off-by: Fam Zheng =20 ---=20 blockjob.c | 2 ++=20 include/block/blockjob.h | 4 +++-=20 2 files changed, 5 insertions(+), 1 deletion(-)=20 diff --git a/blockjob.c b/blockjob.c=20 index ec46fad..b17ed1f 100644=20 --- a/blockjob.c=20 +++ b/blockjob.c=20 @@ -238,6 +238,8 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType ty= pe, int64_t ns)=20 return;=20 }=20 + ns =3D MAX(ns, BLOCK_JOB_SLEEP_NS_MIN);=20 +=20 job->busy =3D false;=20 if (block_job_is_paused(job)) {=20 qemu_coroutine_yield();=20 diff --git a/include/block/blockjob.h b/include/block/blockjob.h=20 index 57d8ef1..3deb731 100644=20 --- a/include/block/blockjob.h=20 +++ b/include/block/blockjob.h=20 @@ -146,11 +146,13 @@ void *block_job_create(const BlockJobDriver *driver, = BlockDriverState *bs,=20 int64_t speed, BlockCompletionFunc *cb,=20 void *opaque, Error **errp);=20 +#define BLOCK_JOB_SLEEP_NS_MIN 10000000L=20 /**=20 * block_job_sleep_ns:=20 * @job: The job that calls the function.=20 * @clock: The clock to sleep on.=20 - * @ns: How many nanoseconds to stop for.=20 + * @ns: How many nanoseconds to stop for. It sleeps at least=20 + * for BLOCK_JOB_SLEEP_NS_MIN ns, even if a smaller value is specified.=20 *=20 * Put the job to sleep (assuming that it wasn't canceled) for @ns=20 * nanoseconds. Canceling the job will interrupt the wait immediately.=20 --=20 2.4.3=20