public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: cleanup kvm_get_dirty_log()
@ 2010-03-17  3:45 Xiao Guangrong
  2010-03-17  4:29 ` Takuya Yoshikawa
  0 siblings, 1 reply; 3+ messages in thread
From: Xiao Guangrong @ 2010-03-17  3:45 UTC (permalink / raw)
  To: Avi Kivity; +Cc: KVM list, LKML

Using bitmap_empty() to see whether memslot->dirty_bitmap is empty

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
 virt/kvm/kvm_main.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index bcd08b8..497ae14 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -767,8 +767,7 @@ int kvm_get_dirty_log(struct kvm *kvm,
 			struct kvm_dirty_log *log, int *is_dirty)
 {
 	struct kvm_memory_slot *memslot;
-	int r, i;
-	int n;
+	int r, n;
 	unsigned long any = 0;
 
 	r = -EINVAL;
@@ -782,8 +781,7 @@ int kvm_get_dirty_log(struct kvm *kvm,
 
 	n = ALIGN(memslot->npages, BITS_PER_LONG) / 8;
 
-	for (i = 0; !any && i < n/sizeof(long); ++i)
-		any = memslot->dirty_bitmap[i];
+	any = !bitmap_empty(memslot->dirty_bitmap, memslot->npages);
 
 	r = -EFAULT;
 	if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n))
-- 
1.6.1.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: cleanup kvm_get_dirty_log()
  2010-03-17  4:29 ` Takuya Yoshikawa
@ 2010-03-17  4:27   ` Xiao Guangrong
  0 siblings, 0 replies; 3+ messages in thread
From: Xiao Guangrong @ 2010-03-17  4:27 UTC (permalink / raw)
  To: Takuya Yoshikawa; +Cc: Avi Kivity, KVM list, LKML



Takuya Yoshikawa wrote:
> Xiao Guangrong wrote:
>> Using bitmap_empty() to see whether memslot->dirty_bitmap is empty
>>
> 
> You can do this for arch specific get_dirty_log() too.

OK, i'll do it in the next version

> 
>> Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
>> ---
>>  virt/kvm/kvm_main.c |    6 ++----
>>  1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index bcd08b8..497ae14 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -767,8 +767,7 @@ int kvm_get_dirty_log(struct kvm *kvm,
>>              struct kvm_dirty_log *log, int *is_dirty)
>>  {
>>      struct kvm_memory_slot *memslot;
>> -    int r, i;
>> -    int n;
>> +    int r, n;
>>      unsigned long any = 0;
> 
> any is no longer need to be unsigned long, if you do this?

Yeah, right, thanks for you point out.

Xiao

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: cleanup kvm_get_dirty_log()
  2010-03-17  3:45 [PATCH] KVM: cleanup kvm_get_dirty_log() Xiao Guangrong
@ 2010-03-17  4:29 ` Takuya Yoshikawa
  2010-03-17  4:27   ` Xiao Guangrong
  0 siblings, 1 reply; 3+ messages in thread
From: Takuya Yoshikawa @ 2010-03-17  4:29 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: Avi Kivity, KVM list, LKML

Xiao Guangrong wrote:
> Using bitmap_empty() to see whether memslot->dirty_bitmap is empty
> 

You can do this for arch specific get_dirty_log() too.

> Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
> ---
>  virt/kvm/kvm_main.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index bcd08b8..497ae14 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -767,8 +767,7 @@ int kvm_get_dirty_log(struct kvm *kvm,
>  			struct kvm_dirty_log *log, int *is_dirty)
>  {
>  	struct kvm_memory_slot *memslot;
> -	int r, i;
> -	int n;
> +	int r, n;
>  	unsigned long any = 0;

any is no longer need to be unsigned long, if you do this?

>  
>  	r = -EINVAL;
> @@ -782,8 +781,7 @@ int kvm_get_dirty_log(struct kvm *kvm,
>  
>  	n = ALIGN(memslot->npages, BITS_PER_LONG) / 8;
>  
> -	for (i = 0; !any && i < n/sizeof(long); ++i)
> -		any = memslot->dirty_bitmap[i];
> +	any = !bitmap_empty(memslot->dirty_bitmap, memslot->npages);
>  
>  	r = -EFAULT;
>  	if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n))


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-17  4:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-17  3:45 [PATCH] KVM: cleanup kvm_get_dirty_log() Xiao Guangrong
2010-03-17  4:29 ` Takuya Yoshikawa
2010-03-17  4:27   ` Xiao Guangrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox