qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] page_cache: dup memory on insert


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] page_cache: dup memory on insert
Date: Mon, 25 Feb 2013 12:13:02 +0000

On 25 February 2013 11:52, Peter Lieven <address@hidden> wrote:
> The page cache frees all data on finish, on resize and
> if there is collision on insert. So it should be the caches
> responsibility to dup the data that is stored in the cache.

> diff --git a/page_cache.c b/page_cache.c
> index a6c3a15..e670d91 100644
> --- a/page_cache.c
> +++ b/page_cache.c
> @@ -158,7 +158,7 @@ void cache_insert(PageCache *cache, uint64_t addr,
> uint8_t *pdata)
>          g_free(it->it_data);
>      }
>
> -    it->it_data = pdata;
> +    it->it_data = g_memdup(pdata, cache->page_size);
>      it->it_age = ++cache->max_item_age;
>      it->it_addr = addr;
>  }

Doesn't this introduce a leak on cache resize in the case where
the element being moved from the old cache to the new does not
collide with any element we've already moved? [ie the code
path where we just cache_insert() the old item's data].

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]