* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
@ 2010-06-23 8:48 ` Avi Kivity
2010-06-23 8:56 ` Takuya Yoshikawa
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Avi Kivity @ 2010-06-23 8:48 UTC (permalink / raw)
To: kvm-ia64
On 06/23/2010 09:01 AM, Takuya Yoshikawa wrote:
> kvm_get_dirty_log() is a helper function for kvm_vm_ioctl_get_dirty_log() which
> is currently used by ia64 and ppc and the following is what it is doing:
>
> - sanity checks
> - bitmap scan to check if the slot is dirty
> - copy_to_user()
>
> Considering the fact that x86 is not using this anymore and sanity checks must
> be done before kvm_ia64_sync_dirty_log(), we can say that this is not working
> for code sharing effectively. So we just remove this.
>
>
> diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
> index 801d9f3..bea6f7c 100644
> --- a/arch/powerpc/kvm/book3s.c
> +++ b/arch/powerpc/kvm/book3s.c
> @@ -1185,28 +1185,43 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
> struct kvm_memory_slot *memslot;
> struct kvm_vcpu *vcpu;
> ulong ga, ga_end;
> - int is_dirty = 0;
> - int r;
> + unsigned long is_dirty = 0;
> + int r, i;
> unsigned long n;
>
> mutex_lock(&kvm->slots_lock);
>
> - r = kvm_get_dirty_log(kvm, log,&is_dirty);
> - if (r)
> + r = -EINVAL;
> + if (log->slot>= KVM_MEMORY_SLOTS)
> + goto out;
> +
> + memslot =&kvm->memslots->memslots[log->slot];
>
Not introduced by this patch, but shouldn't this use rcu_dereference()?
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
2010-06-23 8:48 ` Avi Kivity
@ 2010-06-23 8:56 ` Takuya Yoshikawa
2010-06-23 9:00 ` Avi Kivity
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Takuya Yoshikawa @ 2010-06-23 8:56 UTC (permalink / raw)
To: kvm-ia64
(2010/06/23 17:48), Avi Kivity wrote:
>> diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
>> index 801d9f3..bea6f7c 100644
>> --- a/arch/powerpc/kvm/book3s.c
>> +++ b/arch/powerpc/kvm/book3s.c
>> @@ -1185,28 +1185,43 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
>> struct kvm_memory_slot *memslot;
>> struct kvm_vcpu *vcpu;
>> ulong ga, ga_end;
>> - int is_dirty = 0;
>> - int r;
>> + unsigned long is_dirty = 0;
>> + int r, i;
>> unsigned long n;
>>
>> mutex_lock(&kvm->slots_lock);
>>
>> - r = kvm_get_dirty_log(kvm, log,&is_dirty);
>> - if (r)
>> + r = -EINVAL;
>> + if (log->slot>= KVM_MEMORY_SLOTS)
>> + goto out;
>> +
>> + memslot =&kvm->memslots->memslots[log->slot];
>
> Not introduced by this patch, but shouldn't this use rcu_dereference()?
>
>
I was thinking like that, but sorry I don't know well about ppc.
My final goal is to make everything except
/* If nothing is dirty, don't bother messing with page tables. */
part arch independent, so that we can concentrate on the truely
dirty logging things in the future.
So, making ppc code same as x86, rcu_dereference() for example , really
helps me.
Do you like this approach?
Takuya
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
2010-06-23 8:48 ` Avi Kivity
2010-06-23 8:56 ` Takuya Yoshikawa
@ 2010-06-23 9:00 ` Avi Kivity
2010-06-24 0:58 ` Marcelo Tosatti
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Avi Kivity @ 2010-06-23 9:00 UTC (permalink / raw)
To: kvm-ia64
On 06/23/2010 12:01 PM, Takuya Yoshikawa wrote:
> (2010/06/23 17:48), Avi Kivity wrote:
>
>>> diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
>>> index 801d9f3..bea6f7c 100644
>>> --- a/arch/powerpc/kvm/book3s.c
>>> +++ b/arch/powerpc/kvm/book3s.c
>>> @@ -1185,28 +1185,43 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
>>> struct kvm_memory_slot *memslot;
>>> struct kvm_vcpu *vcpu;
>>> ulong ga, ga_end;
>>> - int is_dirty = 0;
>>> - int r;
>>> + unsigned long is_dirty = 0;
>>> + int r, i;
>>> unsigned long n;
>>>
>>> mutex_lock(&kvm->slots_lock);
>>>
>>> - r = kvm_get_dirty_log(kvm, log,&is_dirty);
>>> - if (r)
>>> + r = -EINVAL;
>>> + if (log->slot>= KVM_MEMORY_SLOTS)
>>> + goto out;
>>> +
>>> + memslot =&kvm->memslots->memslots[log->slot];
>>
>> Not introduced by this patch, but shouldn't this use rcu_dereference()?
>>
>>
>
> I was thinking like that, but sorry I don't know well about ppc.
>
> My final goal is to make everything except
>
> /* If nothing is dirty, don't bother messing with page tables. */
>
> part arch independent, so that we can concentrate on the truely
> dirty logging things in the future.
>
> So, making ppc code same as x86, rcu_dereference() for example , really
> helps me.
>
>
> Do you like this approach?
Well yes, I expect that not using rcu_dereference() (and
srcu_read_lock()) is a bug here.
Marcelo?
On a related note, I'd like to consolidate rcu locking:
- all vcpu ioctls take srcu_read_lock() when they start and drop it at
the end.
- KVM_VCPU_RUN drops the lock when sleeping and entering the guest (also
on context switch?)
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (2 preceding siblings ...)
2010-06-23 9:00 ` Avi Kivity
@ 2010-06-24 0:58 ` Marcelo Tosatti
2010-06-24 8:10 ` Avi Kivity
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Marcelo Tosatti @ 2010-06-24 0:58 UTC (permalink / raw)
To: kvm-ia64
On Wed, Jun 23, 2010 at 12:00:47PM +0300, Avi Kivity wrote:
> On 06/23/2010 12:01 PM, Takuya Yoshikawa wrote:
> >(2010/06/23 17:48), Avi Kivity wrote:
> >
> >>>diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
> >>>index 801d9f3..bea6f7c 100644
> >>>--- a/arch/powerpc/kvm/book3s.c
> >>>+++ b/arch/powerpc/kvm/book3s.c
> >>>@@ -1185,28 +1185,43 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
> >>>struct kvm_memory_slot *memslot;
> >>>struct kvm_vcpu *vcpu;
> >>>ulong ga, ga_end;
> >>>- int is_dirty = 0;
> >>>- int r;
> >>>+ unsigned long is_dirty = 0;
> >>>+ int r, i;
> >>>unsigned long n;
> >>>
> >>>mutex_lock(&kvm->slots_lock);
> >>>
> >>>- r = kvm_get_dirty_log(kvm, log,&is_dirty);
> >>>- if (r)
> >>>+ r = -EINVAL;
> >>>+ if (log->slot>= KVM_MEMORY_SLOTS)
> >>>+ goto out;
> >>>+
> >>>+ memslot =&kvm->memslots->memslots[log->slot];
> >>
> >>Not introduced by this patch, but shouldn't this use rcu_dereference()?
> >>
> >>
> >
> >I was thinking like that, but sorry I don't know well about ppc.
> >
> >My final goal is to make everything except
> >
> > /* If nothing is dirty, don't bother messing with page tables. */
> >
> >part arch independent, so that we can concentrate on the truely
> >dirty logging things in the future.
> >
> >So, making ppc code same as x86, rcu_dereference() for example , really
> >helps me.
> >
> >
> >Do you like this approach?
>
> Well yes, I expect that not using rcu_dereference() (and
> srcu_read_lock()) is a bug here.
>
> Marcelo?
No because slots_lock is held which serializes with memslot updates.
> On a related note, I'd like to consolidate rcu locking:
>
> - all vcpu ioctls take srcu_read_lock() when they start and drop it
> at the end.
> - KVM_VCPU_RUN drops the lock when sleeping and entering the guest
> (also on context switch?)
Yep, makes sense.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (3 preceding siblings ...)
2010-06-24 0:58 ` Marcelo Tosatti
@ 2010-06-24 8:10 ` Avi Kivity
2010-06-25 19:25 ` Alexander Graf
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Avi Kivity @ 2010-06-24 8:10 UTC (permalink / raw)
To: kvm-ia64
On 06/24/2010 03:58 AM, Marcelo Tosatti wrote:
>
>> Well yes, I expect that not using rcu_dereference() (and
>> srcu_read_lock()) is a bug here.
>>
>> Marcelo?
>>
> No because slots_lock is held which serializes with memslot updates.
>
Right, I need to reread Documentation/kvm/locking.txt.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (4 preceding siblings ...)
2010-06-24 8:10 ` Avi Kivity
@ 2010-06-25 19:25 ` Alexander Graf
2010-06-26 0:38 ` Takuya Yoshikawa
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Alexander Graf @ 2010-06-25 19:25 UTC (permalink / raw)
To: kvm-ia64
On 23.06.2010, at 08:01, Takuya Yoshikawa wrote:
> kvm_get_dirty_log() is a helper function for kvm_vm_ioctl_get_dirty_log() which
> is currently used by ia64 and ppc and the following is what it is doing:
>
> - sanity checks
> - bitmap scan to check if the slot is dirty
> - copy_to_user()
>
> Considering the fact that x86 is not using this anymore and sanity checks must
> be done before kvm_ia64_sync_dirty_log(), we can say that this is not working
> for code sharing effectively. So we just remove this.
This patch plus 4/4 broke dirty bitmap updating on PPC. I didn't get around to track down why, but I figured you should now. Is there any way to get you a PPC development box? A simple G4 or G5 should be 200$ on ebay by now :).
Alex
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (5 preceding siblings ...)
2010-06-25 19:25 ` Alexander Graf
@ 2010-06-26 0:38 ` Takuya Yoshikawa
2010-06-26 0:55 ` Takuya Yoshikawa
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Takuya Yoshikawa @ 2010-06-26 0:38 UTC (permalink / raw)
To: kvm-ia64
On Fri, 25 Jun 2010 21:25:57 +0200
Alexander Graf <agraf@suse.de> wrote:
>
> This patch plus 4/4 broke dirty bitmap updating on PPC. I didn't get around to track down why, but I figured you should now. Is there any way to get you a PPC development box? A simple G4 or G5 should be 200$ on ebay by now :).
>
I'm sorry, I thought this change was just trivial code transformation
and test for x86 would be OK: but not actually. Probably the reason is
around the timing of copy_to_user() and newly introduced clear_user()
for clean slot.
>
> Alex
>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (6 preceding siblings ...)
2010-06-26 0:38 ` Takuya Yoshikawa
@ 2010-06-26 0:55 ` Takuya Yoshikawa
2010-06-26 9:38 ` Alexander Graf
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Takuya Yoshikawa @ 2010-06-26 0:55 UTC (permalink / raw)
To: kvm-ia64
> This patch plus 4/4 broke dirty bitmap updating on PPC. I didn't get around to track down why, but I figured you should now. Is there any way to get you a PPC development box? A simple G4 or G5 should be 200$ on ebay by now :).
>
A simple G4 or G5, thanks for the info, I'll buy one.
I hope I can contribute a bit from there to kvm-ppc :).
>
> Alex
>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (7 preceding siblings ...)
2010-06-26 0:55 ` Takuya Yoshikawa
@ 2010-06-26 9:38 ` Alexander Graf
2010-06-27 7:32 ` Avi Kivity
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Alexander Graf @ 2010-06-26 9:38 UTC (permalink / raw)
To: kvm-ia64
On 26.06.2010, at 02:55, Takuya Yoshikawa wrote:
>
>> This patch plus 4/4 broke dirty bitmap updating on PPC. I didn't get around to track down why, but I figured you should now. Is there any way to get you a PPC development box? A simple G4 or G5 should be 200$ on ebay by now :).
>>
>
> A simple G4 or G5, thanks for the info, I'll buy one.
The G4 is 32-bit while the G5 is 64-bit. But since the code paths are very similar on both, you'd be fine with a G4 too. I just checked again and apparently a 1.25Ghz G4 is ~100$ while a dual 1.8Ghz G5 is around 330$.
If it's too troublesome to acquire one yourself, I can also try to buy a notebook and bring it over for the KVM Forum.
I'm looking forward to tested patches :)
Alex
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (8 preceding siblings ...)
2010-06-26 9:38 ` Alexander Graf
@ 2010-06-27 7:32 ` Avi Kivity
2010-06-28 8:14 ` Takuya Yoshikawa
2010-06-28 9:36 ` Avi Kivity
11 siblings, 0 replies; 13+ messages in thread
From: Avi Kivity @ 2010-06-27 7:32 UTC (permalink / raw)
To: kvm-ia64
On 06/25/2010 10:25 PM, Alexander Graf wrote:
> On 23.06.2010, at 08:01, Takuya Yoshikawa wrote:
>
>
>> kvm_get_dirty_log() is a helper function for kvm_vm_ioctl_get_dirty_log() which
>> is currently used by ia64 and ppc and the following is what it is doing:
>>
>> - sanity checks
>> - bitmap scan to check if the slot is dirty
>> - copy_to_user()
>>
>> Considering the fact that x86 is not using this anymore and sanity checks must
>> be done before kvm_ia64_sync_dirty_log(), we can say that this is not working
>> for code sharing effectively. So we just remove this.
>>
> This patch plus 4/4 broke dirty bitmap updating on PPC. I didn't get around to track down why, but I figured you should now. Is there any way to get you a PPC development box? A simple G4 or G5 should be 200$ on ebay by now :).
>
Best to revert these patches and re-apply when fixed.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (9 preceding siblings ...)
2010-06-27 7:32 ` Avi Kivity
@ 2010-06-28 8:14 ` Takuya Yoshikawa
2010-06-28 9:36 ` Avi Kivity
11 siblings, 0 replies; 13+ messages in thread
From: Takuya Yoshikawa @ 2010-06-28 8:14 UTC (permalink / raw)
To: kvm-ia64
(2010/06/27 16:32), Avi Kivity wrote:
> On 06/25/2010 10:25 PM, Alexander Graf wrote:
>> On 23.06.2010, at 08:01, Takuya Yoshikawa wrote:
>>
>>> kvm_get_dirty_log() is a helper function for
>>> kvm_vm_ioctl_get_dirty_log() which
>>> is currently used by ia64 and ppc and the following is what it is doing:
>>>
>>> - sanity checks
>>> - bitmap scan to check if the slot is dirty
>>> - copy_to_user()
>>>
>>> Considering the fact that x86 is not using this anymore and sanity
>>> checks must
>>> be done before kvm_ia64_sync_dirty_log(), we can say that this is not
>>> working
>>> for code sharing effectively. So we just remove this.
>> This patch plus 4/4 broke dirty bitmap updating on PPC. I didn't get
>> around to track down why, but I figured you should now. Is there any
>> way to get you a PPC development box? A simple G4 or G5 should be 200$
>> on ebay by now :).
>
> Best to revert these patches and re-apply when fixed.
>
Please revert. Sincerely sorry.
I'll fix as soon as possible and re-submit when test on PPC gets OK.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log()
2010-06-23 6:01 [PATCH v2 3/4] KVM: cleanup: remove kvm_get_dirty_log() Takuya Yoshikawa
` (10 preceding siblings ...)
2010-06-28 8:14 ` Takuya Yoshikawa
@ 2010-06-28 9:36 ` Avi Kivity
11 siblings, 0 replies; 13+ messages in thread
From: Avi Kivity @ 2010-06-28 9:36 UTC (permalink / raw)
To: kvm-ia64
On 06/28/2010 11:14 AM, Takuya Yoshikawa wrote:
>> Best to revert these patches and re-apply when fixed.
>>
>
>
> Please revert. Sincerely sorry.
>
> I'll fix as soon as possible and re-submit when test on PPC gets OK.
No problem, regressions happen all the time. Lucky Alex caught it so
quickly.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 13+ messages in thread