* [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like
@ 2010-05-04 13:04 Takuya Yoshikawa
2010-05-11 16:00 ` Alexander Graf
2010-05-12 9:25 ` Takuya Yoshikawa
0 siblings, 2 replies; 3+ messages in thread
From: Takuya Yoshikawa @ 2010-05-04 13:04 UTC (permalink / raw)
To: kvm-ia64
During the work of KVM's dirty page logging optimization, we encountered
the need of manipulating bitmaps in user space efficiantly. To achive this,
we introduce a uaccess function for setting a bit in user space following
Avi's suggestion.
KVM is now using dirty bitmaps for live-migration and VGA. Although we need
to update them from kernel side, copying them every time for updating the
dirty log is a big bottleneck. Especially, we tested that zero-copy bitmap
manipulation improves responses of GUI manipulations a lot.
We also found one similar need in drivers/vhost/vhost.c in which the author
implemented set_bit_to_user() locally using inefficient functions: see TODO
at the top of that.
Probably, this kind of need would be common for virtualization area.
So we introduce a function set_bit_user_non_atomic().
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
CC: Alexander Graf <agraf@suse.de>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
---
arch/powerpc/include/asm/uaccess.h | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 3a01ce8..f878326 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -321,6 +321,25 @@ do { \
__gu_err; \
})
+static inline int set_bit_user_non_atomic(int nr, void __user *addr)
+{
+ u8 __user *p;
+ u8 val;
+
+ p = (u8 __user *)((unsigned long)addr + nr / BITS_PER_BYTE);
+ if (!access_ok(VERIFY_WRITE, p, 1))
+ return -EFAULT;
+
+ if (__get_user(val, p))
+ return -EFAULT;
+
+ val |= 1U << (nr % BITS_PER_BYTE);
+ if (__put_user(val, p))
+ return -EFAULT;
+
+ return 0;
+}
+
/* more complex routines */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like
2010-05-04 13:04 [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like Takuya Yoshikawa
@ 2010-05-11 16:00 ` Alexander Graf
2010-05-12 9:25 ` Takuya Yoshikawa
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2010-05-11 16:00 UTC (permalink / raw)
To: kvm-ia64
Takuya Yoshikawa wrote:
> During the work of KVM's dirty page logging optimization, we encountered
> the need of manipulating bitmaps in user space efficiantly. To achive this,
> we introduce a uaccess function for setting a bit in user space following
> Avi's suggestion.
>
> KVM is now using dirty bitmaps for live-migration and VGA. Although we need
> to update them from kernel side, copying them every time for updating the
> dirty log is a big bottleneck. Especially, we tested that zero-copy bitmap
> manipulation improves responses of GUI manipulations a lot.
>
> We also found one similar need in drivers/vhost/vhost.c in which the author
> implemented set_bit_to_user() locally using inefficient functions: see TODO
> at the top of that.
>
> Probably, this kind of need would be common for virtualization area.
>
> So we introduce a function set_bit_user_non_atomic().
>
> Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
> Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
> CC: Alexander Graf <agraf@suse.de>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> ---
> arch/powerpc/include/asm/uaccess.h | 19 +++++++++++++++++++
> 1 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
> index 3a01ce8..f878326 100644
> --- a/arch/powerpc/include/asm/uaccess.h
> +++ b/arch/powerpc/include/asm/uaccess.h
> @@ -321,6 +321,25 @@ do { \
> __gu_err; \
> })
>
> +static inline int set_bit_user_non_atomic(int nr, void __user *addr)
> +{
> + u8 __user *p;
> + u8 val;
> +
> + p = (u8 __user *)((unsigned long)addr + nr / BITS_PER_BYTE);
>
Does C do the + or the / first? Either way, I'd like to see brackets here :)
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like
2010-05-04 13:04 [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like Takuya Yoshikawa
2010-05-11 16:00 ` Alexander Graf
@ 2010-05-12 9:25 ` Takuya Yoshikawa
1 sibling, 0 replies; 3+ messages in thread
From: Takuya Yoshikawa @ 2010-05-12 9:25 UTC (permalink / raw)
To: kvm-ia64
>>
>> +static inline int set_bit_user_non_atomic(int nr, void __user *addr)
>> +{
>> + u8 __user *p;
>> + u8 val;
>> +
>> + p = (u8 __user *)((unsigned long)addr + nr / BITS_PER_BYTE);
>>
>
> Does C do the + or the / first? Either way, I'd like to see brackets here :)
OK, I'll change like that! I like brackets style too :)
>
>
> Alex
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-12 9:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-04 13:04 [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like Takuya Yoshikawa
2010-05-11 16:00 ` Alexander Graf
2010-05-12 9:25 ` Takuya Yoshikawa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox