From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDBM4-0004Yb-KJ for qemu-devel@nongnu.org; Thu, 09 Jul 2015 08:55:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDBM0-0003UC-7o for qemu-devel@nongnu.org; Thu, 09 Jul 2015 08:55:08 -0400 Date: Thu, 9 Jul 2015 13:54:55 +0100 From: Stefan Hajnoczi Message-ID: <20150709125455.GA11166@stefanha-thinkpad.redhat.com> References: <1436413678-7114-1-git-send-email-famz@redhat.com> <1436413678-7114-2-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UlVJffcvxoiEqYs2" Content-Disposition: inline In-Reply-To: <1436413678-7114-2-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/3] blockjob: Introduce block_job_relax_cpu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org, qemu-block@nongnu.org --UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 09, 2015 at 11:47:56AM +0800, Fam Zheng wrote: > block_job_sleep_ns is called by block job coroutines to yield the > execution to VCPU threads and monitor etc. It is pointless to sleep for > 0 or a few nanoseconds, because that equals to a "yield + enter" with no > intermission in between (the timer fires immediately in the same > iteration of event loop), which means other code still doesn't get a > fair share of main loop / BQL. >=20 > Introduce block_job_relax_cpu which will at least for > BLOCK_JOB_RELAX_CPU_NS. Existing block_job_sleep_ns(job, 0) callers can > be replaced by this later. >=20 > Reported-by: Alexandre DERUMIER > Signed-off-by: Fam Zheng > --- > include/block/blockjob.h | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) >=20 > diff --git a/include/block/blockjob.h b/include/block/blockjob.h > index 57d8ef1..53ac4f4 100644 > --- a/include/block/blockjob.h > +++ b/include/block/blockjob.h > @@ -157,6 +157,22 @@ void *block_job_create(const BlockJobDriver *driver,= BlockDriverState *bs, > */ > void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns); > =20 > +#define BLOCK_JOB_RELAX_CPU_NS 10000000L By the way, why did you choose 10 milliseconds? That is quite long. If this function is called once per 10 ms disk I/O operations then we lose 50% utilization. 1 ms or less would be reasonable. > + > +/** > + * block_job_relax_cpu: > + * @job: The job that calls the function. > + * > + * Sleep a little to avoid intensive cpu time occupation. Block jobs sho= uld > + * call this or block_job_sleep_ns (for more precision, but note that 0 = ns is > + * usually not enought) periodically, otherwise the QMP and VCPU could s= tarve s/enought/enough/ > + * on CPU and/or BQL. > + */ > +static inline void block_job_relax_cpu(BlockJob *job) coroutine_fn is missing. --UlVJffcvxoiEqYs2 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVnm8fAAoJEJykq7OBq3PIC74IAI885+Aaus2MRuXfLbm100Zh hKwRz+dJY91KEg4xRYRZMCmgNsdHkZcu+fMaDuo965MDD9tyB9+XmK4gVrSChwFa QHDc43GByWVqoQ6UNrZamsiXPcaat7nUK/3NWCV1MSrwa7leaSsUdicP7EgI6bBv RUOfybMfNgvTyMe7RH4NFXmcJ2bNF84A+cGyDrZ4BjlKss7DMYRRCp1C162pP2+k jhLKCDO21SwBY0HqGAZJwO2dWDuEu3bDAVBBLWiyKDhxg7gSh9GbMDdvPLC/C3sr 0jdnzxs4MmneLyz0ACC+OagxuibEnGpfOA/56gXIys6Z1RdaXJfWxsjXo2YO24w= =spKS -----END PGP SIGNATURE----- --UlVJffcvxoiEqYs2--