From: Eric Blake <eblake@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] qcow2: add option to clean unused cache entries after some time
Date: Wed, 27 May 2015 06:27:35 -0600 [thread overview]
Message-ID: <5565B837.3090300@redhat.com> (raw)
In-Reply-To: <8007efe81120cd72f7c4145b8bbc3f4bc558e62d.1432719752.git.berto@igalia.com>
[-- Attachment #1: Type: text/plain, Size: 2971 bytes --]
On 05/27/2015 03:46 AM, Alberto Garcia wrote:
> This adds a new 'cache-clean-interval' option that cleans all qcow2
> cache entries that haven't been used in a certain interval, given in
> seconds.
>
> This allows setting a large L2 cache size so it can handle scenarios
> with lots of I/O and at the same time use little memory during periods
> of inactivity.
>
> This feature currently relies on MADV_DONTNEED to free that memory, so
> it is not useful in systems that don't follow that behavior.
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> Cc: Max Reitz <mreitz@redhat.com>
> ---
> block/qcow2-cache.c | 35 ++++++++++++++++++++++++++++
> block/qcow2.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> block/qcow2.h | 4 ++++
> qapi/block-core.json | 13 +++++++++--
> 4 files changed, 116 insertions(+), 2 deletions(-)
>
> +static void cache_clean_timer_init(BlockDriverState *bs, AioContext *context)
> +{
> + BDRVQcowState *s = bs->opaque;
> + if (s->cache_clean_interval > 0) {
> + s->cache_clean_timer = aio_timer_new(context, QEMU_CLOCK_VIRTUAL,
> + SCALE_MS, cache_clean_timer_cb,
> + bs);
> + timer_mod(s->cache_clean_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
> + (int64_t) s->cache_clean_interval * 1000);
> + }
> +}
> +
This function sets up a timer for non-zero interval, but does nothing if
interval is zero. [1]
> @@ -839,6 +888,16 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
> goto fail;
> }
>
> + cache_clean_interval =
> + qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0);
> + if (cache_clean_interval > UINT_MAX) {
> + error_setg(errp, "Cache clean interval too big");
> + ret = -EINVAL;
> + goto fail;
> + }
If you type the qapi code as 'uint32' rather than 'int', you could skip
the error checking here because the parser would have already clamped
things. But I can live with this as-is.
> + s->cache_clean_interval = cache_clean_interval;
> + cache_clean_timer_init(bs, bdrv_get_aio_context(bs));
[1] But here, you are unconditionally calling init, whether the new
value is 0 or nonzero. Can a block reopen ever cause an existing BDS to
change its interval, in which case I could create a BDS originally with
a timer, then reopen it without a timer, and init() would have to remove
the existing timer? If I'm reading this patch correctly, right now the
interval is a write-once deal (no way to change it after the fact), so
your code is okay; but should a separate patch be added to allow
adjusting the interval, via a reopen operation?
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-05-27 12:28 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-27 9:46 [Qemu-devel] [PATCH v3 0/3] Clean unused entries in the qcow2 L2/refcount cache Alberto Garcia
2015-05-27 9:46 ` [Qemu-devel] [PATCH 1/3] qcow2: mark the memory as no longer needed after qcow2_cache_empty() Alberto Garcia
2015-05-27 9:46 ` [Qemu-devel] [PATCH 2/3] qcow2: add option to clean unused cache entries after some time Alberto Garcia
2015-05-27 12:27 ` Eric Blake [this message]
2015-05-27 14:34 ` Alberto Garcia
2015-05-28 14:47 ` Max Reitz
2015-05-28 14:56 ` Max Reitz
2015-05-28 15:02 ` Alberto Garcia
2015-05-28 15:04 ` Max Reitz
2015-05-28 15:06 ` Max Reitz
2015-05-28 15:13 ` Eric Blake
2015-05-28 15:14 ` Max Reitz
2015-05-28 15:19 ` Alberto Garcia
2015-05-28 15:23 ` Max Reitz
2015-05-28 15:30 ` Alberto Garcia
2015-05-28 19:41 ` Eric Blake
2015-05-29 8:32 ` Kevin Wolf
2015-05-28 16:44 ` Kevin Wolf
2015-05-28 17:03 ` Alberto Garcia
2015-05-27 9:46 ` [Qemu-devel] [PATCH 3/3] qcow2: reorder fields in Qcow2CachedTable to reduce padding Alberto Garcia
-- strict thread matches above, loose matches on Subject: below --
2015-05-29 9:24 [Qemu-devel] [PATCH v4 0/3] Clean unused entries in the qcow2 L2/refcount cache Alberto Garcia
2015-05-29 9:24 ` [Qemu-devel] [PATCH 2/3] qcow2: add option to clean unused cache entries after some time Alberto Garcia
2015-06-02 11:04 ` Kevin Wolf
2015-05-26 17:14 [Qemu-devel] [PATCH v2 0/3] Clean unused entries in the qcow2 L2/refcount cache Alberto Garcia
2015-05-26 17:14 ` [Qemu-devel] [PATCH 2/3] qcow2: add option to clean unused cache entries after some time Alberto Garcia
2015-05-26 17:26 ` Max Reitz
2015-05-26 18:52 ` Eric Blake
2015-05-26 19:10 ` Alberto Garcia
2015-05-26 19:15 ` Eric Blake
2015-05-18 16:48 [Qemu-devel] [PATCH 0/3] Clean unused entries in the qcow2 L2/refcount cache Alberto Garcia
2015-05-18 16:48 ` [Qemu-devel] [PATCH 2/3] qcow2: add option to clean unused cache entries after some time Alberto Garcia
2015-05-26 16:07 ` Max Reitz
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=5565B837.3090300@redhat.com \
--to=eblake@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.