[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC V2 14/16] qcow2: Add qcow2_dedup_update_metrics to
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [RFC V2 14/16] qcow2: Add qcow2_dedup_update_metrics to compute dedup RAM usage. |
Date: |
Thu, 07 Feb 2013 11:06:47 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
On 02/06/2013 05:32 AM, Benoît Canet wrote:
> ---
> block/qcow2-dedup.c | 11 +++++++++++
> block/qcow2.h | 18 ++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/block/qcow2-dedup.c b/block/qcow2-dedup.c
> index 308b4f6..72ce1d7 100644
> --- a/block/qcow2-dedup.c
> +++ b/block/qcow2-dedup.c
> @@ -1311,3 +1311,14 @@ void qcow2_dedup_close(BlockDriverState *bs)
> {
> qcow2_dedup_free(bs);
> }
> +
> +void qcow2_dedup_update_metrics(BlockDriverState *bs)
> +{
> + BDRVQcowState *s = bs->opaque;
> +
> + uint64_t nb_hashs = s->dedup_metrics.ram_hash_creations -
> + s->dedup_metrics.ram_hash_deletions;
> +
> + s->dedup_metrics.ram_usage = nb_hashs * sizeof(GTreeNode_Copy) * 2;
> + s->dedup_metrics.ram_usage += nb_hashs * sizeof(QCowHashNode);
> +}
> diff --git a/block/qcow2.h b/block/qcow2.h
> index fc393d5..191b272 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -76,6 +76,23 @@
> #define QCOW_STRATEGY_DISK (1 << 1)
> #define QCOW_STRATEGY_RUNNING (1 << 2)
>
> +/* This is an internal structure of glib gtree.c
> + * copy it here so we can compute it's size
> + * from glib/gtree.c in glib sources
> + */
> +typedef struct _GTreeNode_Copy GTreeNode_Copy;
> +
> +struct _GTreeNode_Copy
> +{
> + gpointer key; /* key for this node */
> + gpointer value; /* value stored at this node */
> + GTreeNode_Copy *left; /* left subtree */
> + GTreeNode_Copy *right; /* right subtree */
> + gint8 balance; /* height (right) - height (left) */
> + guint8 left_child;
> + guint8 right_child;
> +};
This doesn't belong in the .h file; stick it in the .c since that is the
only place where you use it. It still feels kind of risky to be copying
this opaque struct - what if a newer version of glib changes the struct
size? Do you have any way to ensure that your copy will remain in sync
with the actual struct used by the version of glib that you are linked with?
Would it be better to propose that upstream glib add a new function for
getting memory usage of an opaque hash object, and that qemu merely omit
the memory usage statistic when linked with an older version of glib
that does not provide the new accessor?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [RFC V2 00/16] QCOW2 deduplication metrics, Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 01/16] qcow2: Add qcow2_co_dedup_resume to restart deduplication., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 03/16] qcow2: Add deduplication metrics structures., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 05/16] qcow2: Collect unaligned writes missing data reads metric., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 06/16] qcow2: Collect deduplicated cluster metric., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 14/16] qcow2: Add qcow2_dedup_update_metrics to compute dedup RAM usage., Benoît Canet, 2013/02/06
- Re: [Qemu-devel] [RFC V2 14/16] qcow2: Add qcow2_dedup_update_metrics to compute dedup RAM usage.,
Eric Blake <=
- [Qemu-devel] [RFC V2 15/16] qcow2: returns deduplication metrics and status via bdrv_get_info(), Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 10/16] qcow2: Count cluster deleted metric, Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 11/16] qcow2: Count deduplication refcount overflow metric., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 07/16] qcow2: Collect undeduplicated cluster metric., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 02/16] qcow2: Enable the deduplication feature., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 04/16] qcow2: Initialize deduplication metrics., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 08/16] qcow2: Count QCowHashNode creation metrics., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 09/16] qcow2: Count QCowHashNode removal from tree for metrics., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 16/16] qapi: Return virtual block device deduplication metrics in QMP, Benoît Canet, 2013/02/06