All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use Little Endian for Dirty Bitmap
@ 2009-07-27 10:38 ` Alexander Graf
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2009-07-27 10:38 UTC (permalink / raw)
  To: kvm-ppc-u79uwXL29TY76Z2rM5mHXA
  Cc: kvm-u79uwXL29TY76Z2rM5mHXA, benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r

We currently use host endian long types to store information
in the dirty bitmap.

This works reasonably well on Little Endian targets, because the
u32 after the first contains the next 32 bits. On Big Endian this
breaks completely though, forcing us to be inventive here.

So Ben suggested to always use Little Endian, which looks reasonable.

We only have dirty bitmap implemented in Little Endian targets so far
and since PowerPC would be the first Big Endian platform, we can just
as well switch to Little Endian always with little effort without
breaking existing targets.

Signed-off-by: Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>
---
 virt/kvm/kvm_main.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 17d8688..3482ad1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -48,6 +48,7 @@
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
+#include <asm-generic/bitops/le.h>
 
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
 #include "coalesced_mmio.h"
@@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
 		unsigned long rel_gfn = gfn - memslot->base_gfn;
 
 		/* avoid RMW */
-		if (!test_bit(rel_gfn, memslot->dirty_bitmap))
-			set_bit(rel_gfn, memslot->dirty_bitmap);
+		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
+			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
 	}
 }
 
-- 
1.6.0.2

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH] Use Little Endian for Dirty Bitmap
@ 2009-07-27 10:38 ` Alexander Graf
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2009-07-27 10:38 UTC (permalink / raw)
  To: kvm-ppc-u79uwXL29TY76Z2rM5mHXA
  Cc: kvm-u79uwXL29TY76Z2rM5mHXA, benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r

We currently use host endian long types to store information
in the dirty bitmap.

This works reasonably well on Little Endian targets, because the
u32 after the first contains the next 32 bits. On Big Endian this
breaks completely though, forcing us to be inventive here.

So Ben suggested to always use Little Endian, which looks reasonable.

We only have dirty bitmap implemented in Little Endian targets so far
and since PowerPC would be the first Big Endian platform, we can just
as well switch to Little Endian always with little effort without
breaking existing targets.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 virt/kvm/kvm_main.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 17d8688..3482ad1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -48,6 +48,7 @@
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
+#include <asm-generic/bitops/le.h>
 
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
 #include "coalesced_mmio.h"
@@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
 		unsigned long rel_gfn = gfn - memslot->base_gfn;
 
 		/* avoid RMW */
-		if (!test_bit(rel_gfn, memslot->dirty_bitmap))
-			set_bit(rel_gfn, memslot->dirty_bitmap);
+		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
+			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
 	}
 }
 
-- 
1.6.0.2


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

* Re: [PATCH] Use Little Endian for Dirty Bitmap
       [not found] ` <1248691134-54120-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
@ 2009-09-26 14:35     ` Alexander Graf
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2009-09-26 14:35 UTC (permalink / raw)
  To: Alexander Graf
  Cc: kvm-ppc, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org list,
	Benjamin Herrenschmidt, Avi Kivity

bump

On 27.07.2009, at 12:38, Alexander Graf wrote:

> We currently use host endian long types to store information
> in the dirty bitmap.
>
> This works reasonably well on Little Endian targets, because the
> u32 after the first contains the next 32 bits. On Big Endian this
> breaks completely though, forcing us to be inventive here.
>
> So Ben suggested to always use Little Endian, which looks reasonable.
>
> We only have dirty bitmap implemented in Little Endian targets so far
> and since PowerPC would be the first Big Endian platform, we can just
> as well switch to Little Endian always with little effort without
> breaking existing targets.
>
> Signed-off-by: Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>
> ---
> virt/kvm/kvm_main.c |    5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 17d8688..3482ad1 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -48,6 +48,7 @@
> #include <asm/io.h>
> #include <asm/uaccess.h>
> #include <asm/pgtable.h>
> +#include <asm-generic/bitops/le.h>
>
> #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
> #include "coalesced_mmio.h"
> @@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
> 		unsigned long rel_gfn = gfn - memslot->base_gfn;
>
> 		/* avoid RMW */
> -		if (!test_bit(rel_gfn, memslot->dirty_bitmap))
> -			set_bit(rel_gfn, memslot->dirty_bitmap);
> +		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
> +			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
> 	}
> }
>
> -- 
> 1.6.0.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] Use Little Endian for Dirty Bitmap
@ 2009-09-26 14:35     ` Alexander Graf
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2009-09-26 14:35 UTC (permalink / raw)
  To: Alexander Graf
  Cc: kvm-ppc, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org list,
	Benjamin Herrenschmidt, Avi Kivity

bump

On 27.07.2009, at 12:38, Alexander Graf wrote:

> We currently use host endian long types to store information
> in the dirty bitmap.
>
> This works reasonably well on Little Endian targets, because the
> u32 after the first contains the next 32 bits. On Big Endian this
> breaks completely though, forcing us to be inventive here.
>
> So Ben suggested to always use Little Endian, which looks reasonable.
>
> We only have dirty bitmap implemented in Little Endian targets so far
> and since PowerPC would be the first Big Endian platform, we can just
> as well switch to Little Endian always with little effort without
> breaking existing targets.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
> virt/kvm/kvm_main.c |    5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 17d8688..3482ad1 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -48,6 +48,7 @@
> #include <asm/io.h>
> #include <asm/uaccess.h>
> #include <asm/pgtable.h>
> +#include <asm-generic/bitops/le.h>
>
> #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
> #include "coalesced_mmio.h"
> @@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
> 		unsigned long rel_gfn = gfn - memslot->base_gfn;
>
> 		/* avoid RMW */
> -		if (!test_bit(rel_gfn, memslot->dirty_bitmap))
> -			set_bit(rel_gfn, memslot->dirty_bitmap);
> +		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
> +			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
> 	}
> }
>
> -- 
> 1.6.0.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH] Use Little Endian for Dirty Bitmap
  2009-07-27 10:38 ` Alexander Graf
@ 2009-09-29  0:08   ` Hollis Blanchard
  -1 siblings, 0 replies; 8+ messages in thread
From: Hollis Blanchard @ 2009-09-29  0:08 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kvm-ppc, kvm, benh, Avi Kivity

On Mon, 2009-07-27 at 12:38 +0200, Alexander Graf wrote:
> We currently use host endian long types to store information
> in the dirty bitmap.
> 
> This works reasonably well on Little Endian targets, because the
> u32 after the first contains the next 32 bits. On Big Endian this
> breaks completely though, forcing us to be inventive here.
> 
> So Ben suggested to always use Little Endian, which looks reasonable.
> 
> We only have dirty bitmap implemented in Little Endian targets so far
> and since PowerPC would be the first Big Endian platform, we can just
> as well switch to Little Endian always with little effort without
> breaking existing targets.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  virt/kvm/kvm_main.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 17d8688..3482ad1 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -48,6 +48,7 @@
>  #include <asm/io.h>
>  #include <asm/uaccess.h>
>  #include <asm/pgtable.h>
> +#include <asm-generic/bitops/le.h>
> 
>  #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
>  #include "coalesced_mmio.h"
> @@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
>  		unsigned long rel_gfn = gfn - memslot->base_gfn;
> 
>  		/* avoid RMW */
> -		if (!test_bit(rel_gfn, memslot->dirty_bitmap))
> -			set_bit(rel_gfn, memslot->dirty_bitmap);
> +		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
> +			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
>  	}
>  }

I don't think I've ever exercised the dirty bitmap code, and I don't
really have an opinion. Avi?

-- 
Hollis Blanchard
IBM Linux Technology Center


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

* Re: [PATCH] Use Little Endian for Dirty Bitmap
@ 2009-09-29  0:08   ` Hollis Blanchard
  0 siblings, 0 replies; 8+ messages in thread
From: Hollis Blanchard @ 2009-09-29  0:08 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kvm-ppc, kvm, benh, Avi Kivity

On Mon, 2009-07-27 at 12:38 +0200, Alexander Graf wrote:
> We currently use host endian long types to store information
> in the dirty bitmap.
> 
> This works reasonably well on Little Endian targets, because the
> u32 after the first contains the next 32 bits. On Big Endian this
> breaks completely though, forcing us to be inventive here.
> 
> So Ben suggested to always use Little Endian, which looks reasonable.
> 
> We only have dirty bitmap implemented in Little Endian targets so far
> and since PowerPC would be the first Big Endian platform, we can just
> as well switch to Little Endian always with little effort without
> breaking existing targets.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  virt/kvm/kvm_main.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 17d8688..3482ad1 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -48,6 +48,7 @@
>  #include <asm/io.h>
>  #include <asm/uaccess.h>
>  #include <asm/pgtable.h>
> +#include <asm-generic/bitops/le.h>
> 
>  #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
>  #include "coalesced_mmio.h"
> @@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
>  		unsigned long rel_gfn = gfn - memslot->base_gfn;
> 
>  		/* avoid RMW */
> -		if (!test_bit(rel_gfn, memslot->dirty_bitmap))
> -			set_bit(rel_gfn, memslot->dirty_bitmap);
> +		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
> +			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
>  	}
>  }

I don't think I've ever exercised the dirty bitmap code, and I don't
really have an opinion. Avi?

-- 
Hollis Blanchard
IBM Linux Technology Center


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

* Re: [PATCH] Use Little Endian for Dirty Bitmap
       [not found]   ` <1254182880.15622.157.camel-yDUrRDS8jBVhsM67afOH+sxtgHpCUUYS@public.gmane.org>
@ 2009-09-29  0:10       ` Alexander Graf
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2009-09-29  0:10 UTC (permalink / raw)
  To: Hollis Blanchard
  Cc: kvm-ppc-u79uwXL29TY76Z2rM5mHXA, kvm-u79uwXL29TY76Z2rM5mHXA,
	benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r, Avi Kivity


On 29.09.2009, at 02:08, Hollis Blanchard wrote:

> On Mon, 2009-07-27 at 12:38 +0200, Alexander Graf wrote:
>> We currently use host endian long types to store information
>> in the dirty bitmap.
>>
>> This works reasonably well on Little Endian targets, because the
>> u32 after the first contains the next 32 bits. On Big Endian this
>> breaks completely though, forcing us to be inventive here.
>>
>> So Ben suggested to always use Little Endian, which looks reasonable.
>>
>> We only have dirty bitmap implemented in Little Endian targets so far
>> and since PowerPC would be the first Big Endian platform, we can just
>> as well switch to Little Endian always with little effort without
>> breaking existing targets.
>>
>> Signed-off-by: Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>
>> ---
>> virt/kvm/kvm_main.c |    5 +++--
>> 1 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 17d8688..3482ad1 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -48,6 +48,7 @@
>> #include <asm/io.h>
>> #include <asm/uaccess.h>
>> #include <asm/pgtable.h>
>> +#include <asm-generic/bitops/le.h>
>>
>> #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
>> #include "coalesced_mmio.h"
>> @@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t  
>> gfn)
>> 		unsigned long rel_gfn = gfn - memslot->base_gfn;
>>
>> 		/* avoid RMW */
>> -		if (!test_bit(rel_gfn, memslot->dirty_bitmap))
>> -			set_bit(rel_gfn, memslot->dirty_bitmap);
>> +		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
>> +			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
>> 	}
>> }
>
> I don't think I've ever exercised the dirty bitmap code, and I don't
> really have an opinion. Avi?

No big endian kvm target currently implements dirty bitmaps. In fact,  
IIRC only x86 does atm. So by pinning it to LE now, we save ourselves  
from much trouble for any later user.

Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] Use Little Endian for Dirty Bitmap
@ 2009-09-29  0:10       ` Alexander Graf
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2009-09-29  0:10 UTC (permalink / raw)
  To: Hollis Blanchard
  Cc: kvm-ppc-u79uwXL29TY76Z2rM5mHXA, kvm-u79uwXL29TY76Z2rM5mHXA,
	benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r, Avi Kivity


On 29.09.2009, at 02:08, Hollis Blanchard wrote:

> On Mon, 2009-07-27 at 12:38 +0200, Alexander Graf wrote:
>> We currently use host endian long types to store information
>> in the dirty bitmap.
>>
>> This works reasonably well on Little Endian targets, because the
>> u32 after the first contains the next 32 bits. On Big Endian this
>> breaks completely though, forcing us to be inventive here.
>>
>> So Ben suggested to always use Little Endian, which looks reasonable.
>>
>> We only have dirty bitmap implemented in Little Endian targets so far
>> and since PowerPC would be the first Big Endian platform, we can just
>> as well switch to Little Endian always with little effort without
>> breaking existing targets.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>> virt/kvm/kvm_main.c |    5 +++--
>> 1 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 17d8688..3482ad1 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -48,6 +48,7 @@
>> #include <asm/io.h>
>> #include <asm/uaccess.h>
>> #include <asm/pgtable.h>
>> +#include <asm-generic/bitops/le.h>
>>
>> #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
>> #include "coalesced_mmio.h"
>> @@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t  
>> gfn)
>> 		unsigned long rel_gfn = gfn - memslot->base_gfn;
>>
>> 		/* avoid RMW */
>> -		if (!test_bit(rel_gfn, memslot->dirty_bitmap))
>> -			set_bit(rel_gfn, memslot->dirty_bitmap);
>> +		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
>> +			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
>> 	}
>> }
>
> I don't think I've ever exercised the dirty bitmap code, and I don't
> really have an opinion. Avi?

No big endian kvm target currently implements dirty bitmaps. In fact,  
IIRC only x86 does atm. So by pinning it to LE now, we save ourselves  
from much trouble for any later user.

Alex


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

end of thread, other threads:[~2009-09-29  0:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-27 10:38 [PATCH] Use Little Endian for Dirty Bitmap Alexander Graf
2009-07-27 10:38 ` Alexander Graf
     [not found] ` <1248691134-54120-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
2009-09-26 14:35   ` Alexander Graf
2009-09-26 14:35     ` Alexander Graf
2009-09-29  0:08 ` Hollis Blanchard
2009-09-29  0:08   ` Hollis Blanchard
     [not found]   ` <1254182880.15622.157.camel-yDUrRDS8jBVhsM67afOH+sxtgHpCUUYS@public.gmane.org>
2009-09-29  0:10     ` Alexander Graf
2009-09-29  0:10       ` Alexander Graf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.