* [Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function
@ 2014-02-28 4:10 Gonglei (Arei)
2014-02-28 9:56 ` Dr. David Alan Gilbert
2014-02-28 13:13 ` Eric Blake
0 siblings, 2 replies; 3+ messages in thread
From: Gonglei (Arei) @ 2014-02-28 4:10 UTC (permalink / raw)
To: qemu-devel@nongnu.org
Cc: Peter Maydell, Juan Quintela, pl@kamp.de, owasserm@redhat.com,
aliguori@amazon.com, chenliang (T), pbonzini@redhat.com
Rebuild the cache_is_cached function.
Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
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;
+}
+
int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata,
uint64_t current_age)
{
--
1.7.12.4
Best regards,
-Gonglei
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function
2014-02-28 4:10 [Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function Gonglei (Arei)
@ 2014-02-28 9:56 ` Dr. David Alan Gilbert
2014-02-28 13:13 ` Eric Blake
1 sibling, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2014-02-28 9:56 UTC (permalink / raw)
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 <chenliang88@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> 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 <dgilbert@redhat.com>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function
2014-02-28 4:10 [Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function Gonglei (Arei)
2014-02-28 9:56 ` Dr. David Alan Gilbert
@ 2014-02-28 13:13 ` Eric Blake
1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2014-02-28 13:13 UTC (permalink / raw)
To: Gonglei (Arei), qemu-devel@nongnu.org
Cc: Peter Maydell, Juan Quintela, pl@kamp.de, owasserm@redhat.com,
aliguori@amazon.com, chenliang (T), pbonzini@redhat.com
[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]
On 02/27/2014 09:10 PM, Gonglei (Arei) wrote:
> Rebuild the cache_is_cached function.
>
> Signed-off-by: ChenLiang <chenliang88@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> 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)
Indentation was off pre-patch...
>
> +bool cache_is_cached(const PageCache *cache, uint64_t addr,
> + uint64_t current_age)
...but you should take the opportunity to fix it here.
bool cache_is_cached(const PageCache *cache, uint64_t addr,
uint64_t current_age)
> + if (it->it_addr == addr) {
> + /* updata the it_age when the cache hit */
s/updata/update/
--
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 --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-28 13:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28 4:10 [Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function Gonglei (Arei)
2014-02-28 9:56 ` Dr. David Alan Gilbert
2014-02-28 13:13 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).