From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQhCV-0003e6-Q2 for qemu-devel@nongnu.org; Thu, 20 Mar 2014 13:56:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQhCQ-00078m-VE for qemu-devel@nongnu.org; Thu, 20 Mar 2014 13:56:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17350) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQhCQ-00078E-Nd for qemu-devel@nongnu.org; Thu, 20 Mar 2014 13:56:14 -0400 Date: Thu, 20 Mar 2014 17:56:05 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20140320175604.GA13386@work-vm> References: <1395145464-5524-1-git-send-email-arei.gonglei@huawei.com> <1395145464-5524-7-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1395145464-5524-7-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH v3 06/10] XBZRLE: rebuild the cache_is_cached function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: ChenLiang , pbonzini@redhat.com, weidong.huang@huawei.com, qemu-devel@nongnu.org, quintela@redhat.com * arei.gonglei@huawei.com (arei.gonglei@huawei.com) wrote: > From: ChenLiang > > Rebuild the cache_is_cached function by cache_get_by_addr. > > Signed-off-by: ChenLiang > Signed-off-by: Gonglei > --- Reviewed-by: Dr. David Alan Gilbert > 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 / dgilbert@redhat.com / Manchester, UK