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 Lieven
Subject: Re: [Qemu-devel] [PATCH] page_cache: dup memory on insert
Date: Mon, 25 Feb 2013 13:17:45 +0100

Am 25.02.2013 um 13:13 schrieb Peter Maydell <address@hidden>:

> 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].

you are right. maybe we need different functions for inserts made during resize 
and inserts
from outside.

Peter

> 
> -- PMM




reply via email to

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