From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJKBB-0000hK-NC for qemu-devel@nongnu.org; Fri, 28 Feb 2014 04:56:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJKB6-0004Gf-UG for qemu-devel@nongnu.org; Fri, 28 Feb 2014 04:56:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJKB6-0004GV-L6 for qemu-devel@nongnu.org; Fri, 28 Feb 2014 04:56:24 -0500 Date: Fri, 28 Feb 2014 09:56:08 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20140228095608.GE2695@work-vm> References: <33183CC9F5247A488A2544077AF19020815D228D@SZXEMA503-MBS.china.huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33183CC9F5247A488A2544077AF19020815D228D@SZXEMA503-MBS.china.huawei.com> Subject: Re: [Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" Cc: "chenliang (T)" , Peter Maydell , Juan Quintela , "pl@kamp.de" , "qemu-devel@nongnu.org" , "aliguori@amazon.com" , "pbonzini@redhat.com" * Gonglei (Arei) (arei.gonglei@huawei.com) wrote: > Rebuild the cache_is_cached function. > > Signed-off-by: ChenLiang > Signed-off-by: Gonglei > --- > page_cache.c | 33 +++++++++++++++------------------ > 1 file changed, 15 insertions(+), 18 deletions(-) > > diff --git a/page_cache.c b/page_cache.c > index fa58ab2..34ec933 100644 > --- a/page_cache.c > +++ b/page_cache.c > @@ -121,24 +121,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) { > - /* updata 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; > @@ -156,6 +138,21 @@ 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 = NULL; > + > + it = cache_get_by_addr(cache, addr); > + > + if (it->it_addr == addr) { > + /* updata the it_age when the cache hit */ > + it->it_age = current_age; > + return true; > + } > + return false; > +} > + Reviewed-by: Dr. David Alan Gilbert > int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata, > uint64_t current_age) > { > -- > 1.7.12.4 > > Best regards, > -Gonglei > > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK