[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 06/10] XBZRLE: rebuild the cache_is_cached fu
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH v3 06/10] XBZRLE: rebuild the cache_is_cached function |
Date: |
Thu, 20 Mar 2014 17:56:05 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
* address@hidden (address@hidden) wrote:
> From: ChenLiang <address@hidden>
>
> Rebuild the cache_is_cached function by cache_get_by_addr.
>
> Signed-off-by: ChenLiang <address@hidden>
> Signed-off-by: Gonglei <address@hidden>
> ---
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
> page_cache.c | 38 ++++++++++++++++----------------------
> 1 file changed, 16 insertions(+), 22 deletions(-)
>
> diff --git a/page_cache.c b/page_cache.c
> index c78157b..3190c55 100644
> --- a/page_cache.c
> +++ b/page_cache.c
> @@ -124,24 +124,6 @@ static size_t cache_get_cache_pos(const PageCache *cache,
> return pos;
> }
>
> -bool cache_is_cached(const PageCache *cache, uint64_t addr,
> - uint64_t current_age)
> -{
> - size_t pos;
> -
> - g_assert(cache);
> - g_assert(cache->page_cache);
> -
> - pos = cache_get_cache_pos(cache, addr);
> -
> - if (cache->page_cache[pos].it_addr == addr) {
> - /* update the it_age when the cache hit */
> - cache->page_cache[pos].it_age = current_age;
> - return true;
> - }
> - return false;
> -}
> -
> static CacheItem *cache_get_by_addr(const PageCache *cache, uint64_t addr)
> {
> size_t pos;
> @@ -159,14 +141,26 @@ uint8_t *get_cached_data(const PageCache *cache,
> uint64_t addr)
> return cache_get_by_addr(cache, addr)->it_data;
> }
>
> +bool cache_is_cached(const PageCache *cache, uint64_t addr,
> + uint64_t current_age)
> +{
> + CacheItem *it;
> +
> + it = cache_get_by_addr(cache, addr);
> +
> + if (it->it_addr == addr) {
> + /* update the it_age when the cache hit */
> + it->it_age = current_age;
> + return true;
> + }
> + return false;
> +}
> +
> int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata,
> uint64_t current_age)
> {
>
> - CacheItem *it = NULL;
> -
> - g_assert(cache);
> - g_assert(cache->page_cache);
> + CacheItem *it;
>
> /* actual update of entry */
> it = cache_get_by_addr(cache, addr);
> --
> 1.7.12.4
>
>
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- Re: [Qemu-devel] [PATCH v3 02/10] migration: Add counters of updating the dirty bitmap, (continued)
- [Qemu-devel] [PATCH v3 08/10] migration: optimize xbzrle by reducing data copy, arei.gonglei, 2014/03/18
- [Qemu-devel] [PATCH v3 07/10] migration: Fix the migrate auto converge process, arei.gonglei, 2014/03/18
- [Qemu-devel] [PATCH v3 05/10] XBZRLE: optimize XBZRLE to decrease the cache missing, arei.gonglei, 2014/03/18
- [Qemu-devel] [PATCH v3 10/10] XBZRLE: update the doc of XBZRLE, arei.gonglei, 2014/03/18
- [Qemu-devel] [PATCH v3 03/10] migration: expose the bitmap_sync_counter to the end user, arei.gonglei, 2014/03/18
- [Qemu-devel] [PATCH v3 06/10] XBZRLE: rebuild the cache_is_cached function, arei.gonglei, 2014/03/18
- [Qemu-devel] [PATCH v3 09/10] migration: clear the dead code, arei.gonglei, 2014/03/18
- Re: [Qemu-devel] [PATCH v3 00/10] migration: Optimizate the xbzrle and fix two corruption issues, Eric Blake, 2014/03/20