From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tamas K Lengyel Subject: Re: [PATCH] xen: Don't disable the REP emulation optimizations for regular IO Date: Thu, 10 Mar 2016 15:28:04 +0100 Message-ID: References: <1457604443-32344-1-git-send-email-rcojocaru@bitdefender.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2234569861783848035==" Return-path: In-Reply-To: <1457604443-32344-1-git-send-email-rcojocaru@bitdefender.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Razvan Cojocaru Cc: andrew.cooper3@citrix.com, Keir Fraser , jbeulich@suse.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org --===============2234569861783848035== Content-Type: multipart/alternative; boundary=001a114091bc5790f2052db29f38 --001a114091bc5790f2052db29f38 Content-Type: text/plain; charset=UTF-8 On Mar 10, 2016 11:09, "Razvan Cojocaru" wrote: > > Currently REP emulations optimizations remain disabled even if > the emulation does not happen as a result of a vm_event reply > requestion emulation (i.e. even for regular IO). This patch takes > emulate_each_rep into account only if emulation has been requested > by a vm_event-capable application, and is a noticeable speed > optimization for monitored guests. > > Signed-off-by: Razvan Cojocaru Reviewed-by: Tamas K Lengyel > --- > xen/arch/x86/hvm/emulate.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c > index 082aa30..ddc8007 100644 > --- a/xen/arch/x86/hvm/emulate.c > +++ b/xen/arch/x86/hvm/emulate.c > @@ -498,6 +498,7 @@ static int hvmemul_virtual_to_linear( > { > struct segment_register *reg; > int okay; > + unsigned long max_reps = 4096; > > if ( seg == x86_seg_none ) > { > @@ -506,16 +507,21 @@ static int hvmemul_virtual_to_linear( > } > > /* > + * If introspection has been enabled for this domain, and we're emulating > + * becase a vm_reply asked us to (i.e. not doing regular IO) reps should > + * be at most 1, since optimization might otherwise cause a single > + * vm_event being triggered for repeated writes to a whole page. > + */ > + if ( unlikely(current->domain->arch.mem_access_emulate_each_rep) && > + current->arch.vm_event->emulate_flags != 0 ) > + max_reps = 1; > + > + /* > * Clip repetitions to avoid overflow when multiplying by @bytes_per_rep. > * The chosen maximum is very conservative but it's what we use in > * hvmemul_linear_to_phys() so there is no point in using a larger value. > - * If introspection has been enabled for this domain, *reps should be > - * at most 1, since optimization might otherwise cause a single vm_event > - * being triggered for repeated writes to a whole page. > */ > - *reps = min_t(unsigned long, *reps, > - unlikely(current->domain->arch.mem_access_emulate_each_rep) > - ? 1 : 4096); > + *reps = min_t(unsigned long, *reps, max_reps); > > reg = hvmemul_get_seg_reg(seg, hvmemul_ctxt); > > -- > 1.9.1 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --001a114091bc5790f2052db29f38 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Mar 10, 2016 11:09, "Razvan Cojocaru" <rcojocaru@bitdefender.com> wrote:
>
> Currently REP emulations optimizations remain disabled even if
> the emulation does not happen as a result of a vm_event reply
> requestion emulation (i.e. even for regular IO). This patch takes
> emulate_each_rep into account only if emulation has been requested
> by a vm_event-capable application, and is a noticeable speed
> optimization for monitored guests.
>
> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>

Reviewed-by: Tamas K Lengyel <tamas@tklengyel.com>

> ---
> =C2=A0xen/arch/x86/hvm/emulate.c | 18 ++++++++++++------
> =C2=A01 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c > index 082aa30..ddc8007 100644
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -498,6 +498,7 @@ static int hvmemul_virtual_to_linear(
> =C2=A0{
> =C2=A0 =C2=A0 =C2=A0struct segment_register *reg;
> =C2=A0 =C2=A0 =C2=A0int okay;
> +=C2=A0 =C2=A0 unsigned long max_reps =3D 4096;
>
> =C2=A0 =C2=A0 =C2=A0if ( seg =3D=3D x86_seg_none )
> =C2=A0 =C2=A0 =C2=A0{
> @@ -506,16 +507,21 @@ static int hvmemul_virtual_to_linear(
> =C2=A0 =C2=A0 =C2=A0}
>
> =C2=A0 =C2=A0 =C2=A0/*
> +=C2=A0 =C2=A0 =C2=A0* If introspection has been enabled for this doma= in, and we're emulating
> +=C2=A0 =C2=A0 =C2=A0* becase a vm_reply asked us to (i.e. not doing r= egular IO) reps should
> +=C2=A0 =C2=A0 =C2=A0* be at most 1, since optimization might otherwis= e cause a single
> +=C2=A0 =C2=A0 =C2=A0* vm_event being triggered for repeated writes to= a whole page.
> +=C2=A0 =C2=A0 =C2=A0*/
> +=C2=A0 =C2=A0 if ( unlikely(current->domain->arch.mem_access_em= ulate_each_rep) &&
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0current->arch.vm_event->emula= te_flags !=3D 0 )
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0max_reps =3D 1;
> +
> +=C2=A0 =C2=A0 /*
> =C2=A0 =C2=A0 =C2=A0 * Clip repetitions to avoid overflow when multipl= ying by @bytes_per_rep.
> =C2=A0 =C2=A0 =C2=A0 * The chosen maximum is very conservative but it&= #39;s what we use in
> =C2=A0 =C2=A0 =C2=A0 * hvmemul_linear_to_phys() so there is no point i= n using a larger value.
> -=C2=A0 =C2=A0 =C2=A0* If introspection has been enabled for this doma= in, *reps should be
> -=C2=A0 =C2=A0 =C2=A0* at most 1, since optimization might otherwise c= ause a single vm_event
> -=C2=A0 =C2=A0 =C2=A0* being triggered for repeated writes to a whole = page.
> =C2=A0 =C2=A0 =C2=A0 */
> -=C2=A0 =C2=A0 *reps =3D min_t(unsigned long, *reps,
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unlike= ly(current->domain->arch.mem_access_emulate_each_rep)
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0? 1 : 4096);
> +=C2=A0 =C2=A0 *reps =3D min_t(unsigned long, *reps, max_reps);
>
> =C2=A0 =C2=A0 =C2=A0reg =3D hvmemul_get_seg_reg(seg, hvmemul_ctxt); >
> --
> 1.9.1
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org=
> http://lists.xen.org/xen-de= vel

--001a114091bc5790f2052db29f38-- --===============2234569861783848035== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --===============2234569861783848035==--