From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Date: Tue, 11 May 2010 16:00:42 +0000 Subject: Re: [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like Message-Id: <4BE97F2A.5080900@suse.de> List-Id: References: <20100504220418.083929bc.takuya.yoshikawa@gmail.com> In-Reply-To: <20100504220418.083929bc.takuya.yoshikawa@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm-ia64@vger.kernel.org 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 > Signed-off-by: Fernando Luis Vazquez Cao > CC: Alexander Graf > CC: Benjamin Herrenschmidt > CC: Paul Mackerras > --- > 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Date: Tue, 11 May 2010 16:00:42 +0000 Subject: Re: [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like Message-Id: <4BE97F2A.5080900@suse.de> List-Id: References: <20100504215645.6448af8f.takuya.yoshikawa@gmail.com> <20100504220418.083929bc.takuya.yoshikawa@gmail.com> In-Reply-To: <20100504220418.083929bc.takuya.yoshikawa@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Takuya Yoshikawa Cc: avi@redhat.com, mtosatti@redhat.com, yoshikawa.takuya@oss.ntt.co.jp, fernando@oss.ntt.co.jp, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-ia64@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, benh@kernel.crashing.org, paulus@samba.org, linuxppc-dev@ozlabs.org, arnd@arndb.de, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org 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 > Signed-off-by: Fernando Luis Vazquez Cao > CC: Alexander Graf > CC: Benjamin Herrenschmidt > CC: Paul Mackerras > --- > 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Subject: Re: [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like function for bitmaps in user space Date: Tue, 11 May 2010 18:00:42 +0200 Message-ID: <4BE97F2A.5080900@suse.de> References: <20100504215645.6448af8f.takuya.yoshikawa@gmail.com> <20100504220418.083929bc.takuya.yoshikawa@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20100504220418.083929bc.takuya.yoshikawa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Sender: kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Takuya Yoshikawa Cc: avi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, yoshikawa.takuya-gVGce1chcLdL9jVzuh4AOg@public.gmane.org, fernando-gVGce1chcLdL9jVzuh4AOg@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org, mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org, x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org, paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org, arnd-r2nGTMty4D4@public.gmane.org, linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-arch.vger.kernel.org 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 > Signed-off-by: Fernando Luis Vazquez Cao > CC: Alexander Graf > CC: Benjamin Herrenschmidt > CC: Paul Mackerras > --- > 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cantor.suse.de ([195.135.220.2]:39569 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751431Ab0EKQAn (ORCPT ); Tue, 11 May 2010 12:00:43 -0400 Message-ID: <4BE97F2A.5080900@suse.de> Date: Tue, 11 May 2010 18:00:42 +0200 From: Alexander Graf MIME-Version: 1.0 Subject: Re: [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like function for bitmaps in user space References: <20100504215645.6448af8f.takuya.yoshikawa@gmail.com> <20100504220418.083929bc.takuya.yoshikawa@gmail.com> In-Reply-To: <20100504220418.083929bc.takuya.yoshikawa@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Takuya Yoshikawa Cc: avi@redhat.com, mtosatti@redhat.com, yoshikawa.takuya@oss.ntt.co.jp, fernando@oss.ntt.co.jp, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-ia64@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, benh@kernel.crashing.org, paulus@samba.org, linuxppc-dev@ozlabs.org, arnd@arndb.de, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <20100511160042.CgB5uGI_hBcmmo5GWq4bfbRZVtT1w4muSc6L7Vu9C1w@z> 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 > Signed-off-by: Fernando Luis Vazquez Cao > CC: Alexander Graf > CC: Benjamin Herrenschmidt > CC: Paul Mackerras > --- > 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.suse.de (cantor.suse.de [195.135.220.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx1.suse.de", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 50A89B7D91 for ; Wed, 12 May 2010 02:00:46 +1000 (EST) Message-ID: <4BE97F2A.5080900@suse.de> Date: Tue, 11 May 2010 18:00:42 +0200 From: Alexander Graf MIME-Version: 1.0 To: Takuya Yoshikawa Subject: Re: [RFC][PATCH 7/12 not tested yet] PPC: introduce __set_bit() like function for bitmaps in user space References: <20100504215645.6448af8f.takuya.yoshikawa@gmail.com> <20100504220418.083929bc.takuya.yoshikawa@gmail.com> In-Reply-To: <20100504220418.083929bc.takuya.yoshikawa@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Cc: linux-arch@vger.kernel.org, x86@kernel.org, arnd@arndb.de, kvm@vger.kernel.org, kvm-ia64@vger.kernel.org, fernando@oss.ntt.co.jp, mtosatti@redhat.com, linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp, linuxppc-dev@ozlabs.org, mingo@redhat.com, paulus@samba.org, avi@redhat.com, hpa@zytor.com, tglx@linutronix.de List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 > Signed-off-by: Fernando Luis Vazquez Cao > CC: Alexander Graf > CC: Benjamin Herrenschmidt > CC: Paul Mackerras > --- > 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