qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH v2] qemu-kvm: Speed up of the dirty-bitmap-trave


From: Avi Kivity
Subject: [Qemu-devel] Re: [PATCH v2] qemu-kvm: Speed up of the dirty-bitmap-traveling
Date: Sun, 14 Feb 2010 14:34:10 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc12 Thunderbird/3.0.1

On 02/12/2010 04:03 AM, OHMURA Kei wrote:
> On 02/11/2010 Anthony Liguori <address@hidden> wrote:
>   
>> Oh, I see what's happening here. Yes, I think a leul_to_cpu() makes more
>> sense.
>>     
> Maybe I'm missing something here.
> I couldn't find leul_to_cpu(), so have defined it in bswap.h.
> Correct?
>
> --- a/bswap.h
> +++ b/bswap.h
> @@ -205,8 +205,10 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
>  
>  #ifdef HOST_WORDS_BIGENDIAN
>  #define cpu_to_32wu cpu_to_be32wu
> +#define leul_to_cpu(v) le ## HOST_LONG_BITS ## _to_cpu(v)
>  #else
>  #define cpu_to_32wu cpu_to_le32wu
> +#define leul_to_cpu(v) (v)
>  #endif
>
>
>
> On 02/10/2010 Ulrich Drepper <address@hidden> wrote:
>   
>> If you're optimizing this code you might want to do it all.  The
>> compiler might not see through the bswap call and create unnecessary
>> data dependencies.  Especially problematic if the bitmap is really
>> sparse.  Also, the outer test is != while the inner test is >.  Be
>> consistent.  I suggest to replace the inner loop with
>>
>>      do {
>>        ...
>>      } while (c != 0);
>>
>> Depending on how sparse the bitmap is populated this might reduce the
>> number of data dependencies quite a bit.
>>     
> Combining all comments, the code would be like this.
>      
>  if (bitmap_ul[i] != 0) {
>      c = leul_to_cpu(bitmap_ul[i]);
>      do {
>          j = ffsl(c) - 1;
>          c &= ~(1ul << j);
>          page_number = i * HOST_LONG_BITS + j;
>          addr1 = page_number * TARGET_PAGE_SIZE;
>          addr = offset + addr1;
>          ram_addr = cpu_get_physical_page_desc(addr);
>          cpu_physical_memory_set_dirty(ram_addr);
>      } while (c != 0);
>  }
>   

Except you don't need bitmap_ul any more - you can change the type of
the bitmap variable, since all accesses should now be ulongs.

-- 
error compiling committee.c: too many arguments to function





reply via email to

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