From: Stefan Hajnoczi <stefanha@gmail.com>
To: Fam Zheng <famz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/3] blockjob: Introduce block_job_relax_cpu
Date: Thu, 9 Jul 2015 13:54:55 +0100 [thread overview]
Message-ID: <20150709125455.GA11166@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1436413678-7114-2-git-send-email-famz@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]
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.
>
> 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.
>
> Reported-by: Alexandre DERUMIER <aderumier@odiso.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> include/block/blockjob.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> 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);
>
> +#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 should
> + * 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 starve
s/enought/enough/
> + * on CPU and/or BQL.
> + */
> +static inline void block_job_relax_cpu(BlockJob *job)
coroutine_fn is missing.
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2015-07-09 12:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-09 3:47 [Qemu-devel] [PATCH 0/3] mirror: Fix guest responsiveness during bitmap scan Fam Zheng
2015-07-09 3:47 ` [Qemu-devel] [PATCH 1/3] blockjob: Introduce block_job_relax_cpu Fam Zheng
2015-07-09 12:54 ` Stefan Hajnoczi [this message]
2015-07-10 3:42 ` [Qemu-devel] [Qemu-block] " Alexandre DERUMIER
2015-07-14 12:31 ` Stefan Hajnoczi
2015-07-15 10:32 ` Fam Zheng
2015-07-16 13:21 ` Stefan Hajnoczi
2015-07-09 3:47 ` [Qemu-devel] [PATCH 2/3] mirror: Use block_job_relax_cpu during bitmap scanning Fam Zheng
2015-07-09 13:00 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-07-09 3:47 ` [Qemu-devel] [PATCH 3/3] mirror: Speed up bitmap initial scanning Fam Zheng
2015-07-09 13:00 ` Stefan Hajnoczi
2015-07-14 13:21 ` Stefan Hajnoczi
2015-07-09 11:51 ` [Qemu-devel] [PATCH 0/3] mirror: Fix guest responsiveness during bitmap scan Alexandre DERUMIER
2015-07-09 13:02 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-07-09 13:18 ` Alexandre DERUMIER
2015-07-10 6:43 ` Fam Zheng
2015-07-10 6:54 ` Alexandre DERUMIER
2015-07-10 7:13 ` Fam Zheng
2015-07-10 10:36 ` Alexandre DERUMIER
2015-07-10 12:16 ` Alexandre DERUMIER
2015-07-13 5:08 ` Fam Zheng
2015-07-14 12:40 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150709125455.GA11166@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).