All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/6] qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty()
Date: Tue, 05 May 2015 09:21:58 -0600	[thread overview]
Message-ID: <5548E016.4020208@redhat.com> (raw)
In-Reply-To: <65c04848cf88f3342e229464e72d1124ce3d8de9.1430388393.git.berto@igalia.com>

[-- Attachment #1: Type: text/plain, Size: 1380 bytes --]

On 04/30/2015 04:11 AM, Alberto Garcia wrote:
> Since all tables are now stored together, it is possible to obtain
> the position of a particular table directly from its address, so the
> operation becomes O(1).
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
>  block/qcow2-cache.c | 22 +++++-----------------
>  1 file changed, 5 insertions(+), 17 deletions(-)
> 
> diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
> index 586880b..d3274f4 100644
> --- a/block/qcow2-cache.c
> +++ b/block/qcow2-cache.c
> @@ -335,16 +335,12 @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
>  
>  int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table)
>  {
> -    int i;
> +    int i = (*table - c->table_array) / c->table_size;

Arithmetic on void* is not portable.

>  void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table)
>  {
> -    int i;
> -
> -    for (i = 0; i < c->size; i++) {
> -        if (table_addr(c, i) == table) {
> -            goto found;
> -        }
> -    }
> -    abort();
> -
> -found:
> +    int i = (table - c->table_array) / c->table_size;

and again.

> +    assert(c->entries[i].offset != 0);
>      c->entries[i].dirty = true;
>  }
> 

-- 
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 --]

  parent reply	other threads:[~2015-05-05 15:22 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 10:11 [Qemu-devel] [PATCH 0/6] qcow2 L2/refcount cache improvements Alberto Garcia
2015-04-30 10:11 ` [Qemu-devel] [PATCH 1/6] qcow2: use one single memory block for the L2/refcount cache tables Alberto Garcia
2015-04-30 15:08   ` Eric Blake
2015-05-05 13:00     ` Alberto Garcia
2015-05-01 14:23   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-05-04 10:58     ` Kevin Wolf
2015-05-05 10:28       ` Stefan Hajnoczi
2015-05-05 11:20         ` Kevin Wolf
2015-05-05 15:09           ` Alberto Garcia
2015-05-06 14:57           ` Stefan Hajnoczi
2015-04-30 10:11 ` [Qemu-devel] [PATCH 2/6] qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty() Alberto Garcia
2015-05-01 14:31   ` Stefan Hajnoczi
2015-05-05 13:06     ` Alberto Garcia
2015-05-06 15:00       ` Stefan Hajnoczi
2015-05-06 15:32         ` Alberto Garcia
2015-05-05 15:21   ` Eric Blake [this message]
2015-04-30 10:11 ` [Qemu-devel] [PATCH 3/6] qcow2: use an LRU algorithm to replace entries from the L2 cache Alberto Garcia
2015-04-30 10:11 ` [Qemu-devel] [PATCH 4/6] qcow2: remove qcow2_cache_find_entry_to_replace() Alberto Garcia
2015-04-30 10:11 ` [Qemu-devel] [PATCH 5/6] qcow2: use a hash to look for entries in the L2 cache Alberto Garcia
2015-05-06 16:42   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-05-07  8:23     ` Alberto Garcia
2015-04-30 10:11 ` [Qemu-devel] [PATCH 6/6] qcow2: style fixes in qcow2-cache.c Alberto Garcia
2015-05-06 16:42   ` Stefan Hajnoczi
2015-05-06 16:43 ` [Qemu-devel] [Qemu-block] [PATCH 0/6] qcow2 L2/refcount cache improvements 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=5548E016.4020208@redhat.com \
    --to=eblake@redhat.com \
    --cc=berto@igalia.com \
    --cc=kwolf@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.