* [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian
@ 2010-04-20 10:57 Takuya Yoshikawa
2010-04-20 11:00 ` [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian issues explicitly Alexander Graf
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Takuya Yoshikawa @ 2010-04-20 10:57 UTC (permalink / raw)
To: kvm-ia64
We are now using generic___set_le_bit() to make dirty bitmaps le.
Though this works well, we have to replace __set_bit() to appropriate
uaccess function to move dirty bitmaps to user space. So this patch
splits generic___set_le_bit() and prepares for that.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
---
virt/kvm/kvm_main.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 6908304..66c4daf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1194,6 +1194,15 @@ int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len)
}
EXPORT_SYMBOL_GPL(kvm_clear_guest);
+static int __mark_page_dirty(unsigned long nr,
+ unsigned long *dirty_bitmap)
+{
+#ifdef __BIG_ENDIAN
+ nr = nr ^ BITOP_LE_SWIZZLE;
+#endif
+ __set_bit(nr, dirty_bitmap);
+}
+
void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
{
struct kvm_memory_slot *memslot;
@@ -1203,11 +1212,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
if (memslot && memslot->dirty_bitmap) {
unsigned long rel_gfn = gfn - memslot->base_gfn;
- /* avoid RMW */
- if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap)) {
- generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
- memslot->is_dirty = true;
- }
+ __mark_page_dirty(rel_gfn, memslot->dirty_bitmap);
+ memslot->is_dirty = true;
}
}
--
1.6.3.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian issues explicitly
2010-04-20 10:57 [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian Takuya Yoshikawa
@ 2010-04-20 11:00 ` Alexander Graf
2010-04-20 11:20 ` [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian Takuya Yoshikawa
2010-04-21 11:15 ` Avi Kivity
2 siblings, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2010-04-20 11:00 UTC (permalink / raw)
To: kvm-ia64
On 20.04.2010, at 13:00, Takuya Yoshikawa wrote:
> We are now using generic___set_le_bit() to make dirty bitmaps le.
> Though this works well, we have to replace __set_bit() to appropriate
> uaccess function to move dirty bitmaps to user space. So this patch
> splits generic___set_le_bit() and prepares for that.
>
> Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
> Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
> ---
> virt/kvm/kvm_main.c | 16 +++++++++++-----
> 1 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 6908304..66c4daf 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1194,6 +1194,15 @@ int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len)
> }
> EXPORT_SYMBOL_GPL(kvm_clear_guest);
>
> +static int __mark_page_dirty(unsigned long nr,
> + unsigned long *dirty_bitmap)
> +{
> +#ifdef __BIG_ENDIAN
> + nr = nr ^ BITOP_LE_SWIZZLE;
Why an XOR here?
Also is this LE set_bit new? I didn't see it when I did the patch back then :).
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian
2010-04-20 10:57 [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian Takuya Yoshikawa
2010-04-20 11:00 ` [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian issues explicitly Alexander Graf
@ 2010-04-20 11:20 ` Takuya Yoshikawa
2010-04-21 11:15 ` Avi Kivity
2 siblings, 0 replies; 4+ messages in thread
From: Takuya Yoshikawa @ 2010-04-20 11:20 UTC (permalink / raw)
To: kvm-ia64
(2010/04/20 20:00), Alexander Graf wrote:
>
> On 20.04.2010, at 13:00, Takuya Yoshikawa wrote:
>
>> We are now using generic___set_le_bit() to make dirty bitmaps le.
>> Though this works well, we have to replace __set_bit() to appropriate
>> uaccess function to move dirty bitmaps to user space. So this patch
>> splits generic___set_le_bit() and prepares for that.
>>
>> Signed-off-by: Takuya Yoshikawa<yoshikawa.takuya@oss.ntt.co.jp>
>> Signed-off-by: Fernando Luis Vazquez Cao<fernando@oss.ntt.co.jp>
>> ---
>> virt/kvm/kvm_main.c | 16 +++++++++++-----
>> 1 files changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 6908304..66c4daf 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -1194,6 +1194,15 @@ int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len)
>> }
>> EXPORT_SYMBOL_GPL(kvm_clear_guest);
>>
>> +static int __mark_page_dirty(unsigned long nr,
>> + unsigned long *dirty_bitmap)
>> +{
>> +#ifdef __BIG_ENDIAN
>> + nr = nr ^ BITOP_LE_SWIZZLE;
>
> Why an XOR here?
Ah, might be my cut and paste mistake. I just copied from generic___set_le_bit().
>
> Also is this LE set_bit new? I didn't see it when I did the patch back then :).
Really? I need to check the git log then. This LE set_bit is not new I think.
>
>
> Alex
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian
2010-04-20 10:57 [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian Takuya Yoshikawa
2010-04-20 11:00 ` [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian issues explicitly Alexander Graf
2010-04-20 11:20 ` [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian Takuya Yoshikawa
@ 2010-04-21 11:15 ` Avi Kivity
2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2010-04-21 11:15 UTC (permalink / raw)
To: kvm-ia64
On 04/20/2010 02:00 PM, Takuya Yoshikawa wrote:
> We are now using generic___set_le_bit() to make dirty bitmaps le.
> Though this works well, we have to replace __set_bit() to appropriate
> uaccess function to move dirty bitmaps to user space. So this patch
> splits generic___set_le_bit() and prepares for that.
>
>
> +static int __mark_page_dirty(unsigned long nr,
> + unsigned long *dirty_bitmap)
> +{
> +#ifdef __BIG_ENDIAN
> + nr = nr ^ BITOP_LE_SWIZZLE;
> +#endif
> + __set_bit(nr, dirty_bitmap);
>
Why not introduce __set_le_bit_user() along with __set_bit_user()? kvm
shouldn't do endian corrections when they can be done in generic code.
> +}
> +
> void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
> {
> struct kvm_memory_slot *memslot;
> @@ -1203,11 +1212,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
> if (memslot&& memslot->dirty_bitmap) {
> unsigned long rel_gfn = gfn - memslot->base_gfn;
>
> - /* avoid RMW */
> - if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap)) {
> - generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
> - memslot->is_dirty = true;
> - }
>
You're also dropping the RMW avoidance. This is fine, but deserves at
least a note in the changelog (or a separate patch).
> + __mark_page_dirty(rel_gfn, memslot->dirty_bitmap);
> + memslot->is_dirty = true;
> }
> }
>
>
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-04-21 11:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-20 10:57 [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian Takuya Yoshikawa
2010-04-20 11:00 ` [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian issues explicitly Alexander Graf
2010-04-20 11:20 ` [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian Takuya Yoshikawa
2010-04-21 11:15 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox