[Top][All Lists]

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

Re: [Qemu-devel] [PATCH 1/2] Make cow_co_is_allocated and cow_update_bit

From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 1/2] Make cow_co_is_allocated and cow_update_bitmap more efficient
Date: Wed, 21 Aug 2013 11:19:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8

Il 21/08/2013 11:11, Charlie Shepherd ha scritto:
>> For cow_co_is_allocated, you have the luxury of returning information
>> only for the fewer than nb_sectors.  That is, you can set *num_same to a
>> smaller value than nb_sectors, even if sector_num + *num_same has the
>> same state as the [sector_num, sector_num + *num_same) range.  It will
>> cause extra calls to is_allocated in the callers, but that's it.
> So we can report a conservative estimate of *num_same?

Yes.  We can set *num_same to the number of bits from sector_num to the
end of the bitmap sector.

> It still seems
> worthwhile to me to be as efficient as possible, I guess that means
> processing a sector's worth of metadata at a time?

Yes, that's what my patches do.  My is_allocated and flushing strategy +
something like your replacement of cow_set_bit (just without the
unbounded allocation) should be pretty good.

Perhaps you can use a cow_co_is_allocated loop after writing the data.
If it returns 0, you flush (the first time only) and call your
cow_update_bitmap.  Then you advance by num_same sectors and go on until
you did all the nb_sectors.  The disadvantage is that it does two reads
(one in cow_co_is_allocated, one in cow_update_bitmap).  The advantage
is that unbounded allocation goes away because cow_co_is_allocated will
never consider more than a sector of bitmap data.  And you can reuse all
your cow_update_bitmap code.

To be as efficient as possible, you could keep a memory copy of the
bitmap, so that you only have to do writes, not reads.  The memory copy
would be somewhat expensive of course but perhaps reasonable (256M of
memory for a 1T image).  The largest cost would be loading the bitmap
from memory at startup.  But that can be done later.


reply via email to

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