diff mbox

[5/9] KVM: VMX: clamp PLE window

Message ID 1408480536-8240-6-git-send-email-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář Aug. 19, 2014, 8:35 p.m. UTC
Modifications could get unwanted values of PLE window. (low or negative)
Use ple_window and the maximal value that cannot overflow as bounds.

ple_window_max defaults to a very high value, but it would make sense to
set it to some fraction of the scheduler tick.

Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 arch/x86/kvm/vmx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini Aug. 20, 2014, 7:18 a.m. UTC | #1
Il 19/08/2014 22:35, Radim Kr?má? ha scritto:
> Modifications could get unwanted values of PLE window. (low or negative)
> Use ple_window and the maximal value that cannot overflow as bounds.
> 
> ple_window_max defaults to a very high value, but it would make sense to
> set it to some fraction of the scheduler tick.
> 
> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> ---
>  arch/x86/kvm/vmx.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 66259fd..e1192fb 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -144,6 +144,10 @@ module_param(ple_window_grow, int, S_IRUGO);
>  static int ple_window_shrink = KVM_VMX_DEFAULT_PLE_WINDOW_SHRINK;
>  module_param(ple_window_shrink, int, S_IRUGO);
>  
> +/* Default is to compute the maximum so we can never overflow. */
> +static int ple_window_max = INT_MAX / KVM_VMX_DEFAULT_PLE_WINDOW_GROW;
> +module_param(ple_window_max, int, S_IRUGO);
> +
>  extern const ulong vmx_return;
>  
>  #define NR_AUTOLOAD_MSRS 8
> @@ -5704,7 +5708,7 @@ static void grow_ple_window(struct kvm_vcpu *vcpu)
>  	else
>  		new = old + ple_window_grow;
>  
> -	vmx->ple_window = new;
> +	vmx->ple_window = min(new, ple_window_max);
>  }

Please introduce a dynamic overflow-avoiding ple_window_max (like what
you have in patch 9) already in patch 4...

>  static void shrink_ple_window(struct kvm_vcpu *vcpu)
> @@ -5720,7 +5724,7 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu)
>  	else
>  		new = old - ple_window_shrink;
>  
> -	vmx->ple_window = new;
> +	vmx->ple_window = max(new, ple_window);

... and also squash this in patch 4.

This patch can then introduce the ple_window_max module parameter (using
module_param_cb to avoid overflows).

Paolo

>  }
>  
>  /*
> 

--
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
Radim Krčmář Aug. 20, 2014, 12:46 p.m. UTC | #2
2014-08-20 09:18+0200, Paolo Bonzini:
> Il 19/08/2014 22:35, Radim Kr?má? ha scritto:
> > Modifications could get unwanted values of PLE window. (low or negative)
> > Use ple_window and the maximal value that cannot overflow as bounds.
> > 
> > ple_window_max defaults to a very high value, but it would make sense to
> > set it to some fraction of the scheduler tick.
> > 
> > Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> > ---
> Please introduce a dynamic overflow-avoiding ple_window_max (like what
> you have in patch 9) already in patch 4...
> 
> >  static void shrink_ple_window(struct kvm_vcpu *vcpu)
> > @@ -5720,7 +5724,7 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu)
> >  	else
> >  		new = old - ple_window_shrink;
> >  
> > -	vmx->ple_window = new;
> > +	vmx->ple_window = max(new, ple_window);
> 
> ... and also squash this in patch 4.
> 
> This patch can then introduce the ple_window_max module parameter (using
> module_param_cb to avoid overflows).

Will do.

---
It is going to make the patches slightly harder to review;
Are we doing it because git doesn't bisect on series boundaries?
--
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
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 66259fd..e1192fb 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -144,6 +144,10 @@  module_param(ple_window_grow, int, S_IRUGO);
 static int ple_window_shrink = KVM_VMX_DEFAULT_PLE_WINDOW_SHRINK;
 module_param(ple_window_shrink, int, S_IRUGO);
 
+/* Default is to compute the maximum so we can never overflow. */
+static int ple_window_max = INT_MAX / KVM_VMX_DEFAULT_PLE_WINDOW_GROW;
+module_param(ple_window_max, int, S_IRUGO);
+
 extern const ulong vmx_return;
 
 #define NR_AUTOLOAD_MSRS 8
@@ -5704,7 +5708,7 @@  static void grow_ple_window(struct kvm_vcpu *vcpu)
 	else
 		new = old + ple_window_grow;
 
-	vmx->ple_window = new;
+	vmx->ple_window = min(new, ple_window_max);
 }
 
 static void shrink_ple_window(struct kvm_vcpu *vcpu)
@@ -5720,7 +5724,7 @@  static void shrink_ple_window(struct kvm_vcpu *vcpu)
 	else
 		new = old - ple_window_shrink;
 
-	vmx->ple_window = new;
+	vmx->ple_window = max(new, ple_window);
 }
 
 /*