@@ -168,24 +168,17 @@ module_param_named(preemption_timer, enable_preemption_timer, bool, S_IRUGO);
168168 * Time is measured based on a counter that runs at the same rate as the TSC,
169169 * refer SDM volume 3b section 21.6.13 & 22.1.3.
170170 */
171- #define KVM_VMX_DEFAULT_PLE_GAP 128
172- #define KVM_VMX_DEFAULT_PLE_WINDOW 4096
173- #define KVM_VMX_DEFAULT_PLE_WINDOW_GROW 2
174- #define KVM_VMX_DEFAULT_PLE_WINDOW_SHRINK 0
175- #define KVM_VMX_DEFAULT_PLE_WINDOW_MAX UINT_MAX
176-
177- static unsigned int ple_gap = KVM_VMX_DEFAULT_PLE_GAP ;
178- module_param (ple_gap , uint , 0444 );
171+ static unsigned int ple_gap = KVM_DEFAULT_PLE_GAP ;
179172
180173static unsigned int ple_window = KVM_VMX_DEFAULT_PLE_WINDOW ;
181174module_param (ple_window , uint , 0444 );
182175
183176/* Default doubles per-vcpu window every exit. */
184- static unsigned int ple_window_grow = KVM_VMX_DEFAULT_PLE_WINDOW_GROW ;
177+ static unsigned int ple_window_grow = KVM_DEFAULT_PLE_WINDOW_GROW ;
185178module_param (ple_window_grow , uint , 0444 );
186179
187180/* Default resets per-vcpu window every exit to ple_window. */
188- static unsigned int ple_window_shrink = KVM_VMX_DEFAULT_PLE_WINDOW_SHRINK ;
181+ static unsigned int ple_window_shrink = KVM_DEFAULT_PLE_WINDOW_SHRINK ;
189182module_param (ple_window_shrink , uint , 0444 );
190183
191184/* Default is to compute the maximum so we can never overflow. */
@@ -6982,41 +6975,14 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
69826975 return ret ;
69836976}
69846977
6985- static unsigned int __grow_ple_window (unsigned int val )
6986- {
6987- u64 ret = val ;
6988-
6989- if (ple_window_grow < 1 )
6990- return ple_window ;
6991-
6992- if (ple_window_grow < ple_window )
6993- ret *= ple_window_grow ;
6994- else
6995- ret += ple_window_grow ;
6996-
6997- return min (ret , (u64 )ple_window_max );
6998- }
6999-
7000- static unsigned int __shrink_ple_window (unsigned int val ,
7001- unsigned int modifier , unsigned int minimum )
7002- {
7003- if (modifier < 1 )
7004- return ple_window ;
7005-
7006- if (modifier < ple_window )
7007- val /= modifier ;
7008- else
7009- val -= modifier ;
7010-
7011- return max (val , minimum );
7012- }
7013-
70146978static void grow_ple_window (struct kvm_vcpu * vcpu )
70156979{
70166980 struct vcpu_vmx * vmx = to_vmx (vcpu );
70176981 int old = vmx -> ple_window ;
70186982
7019- vmx -> ple_window = __grow_ple_window (old );
6983+ vmx -> ple_window = __grow_ple_window (old , ple_window ,
6984+ ple_window_grow ,
6985+ ple_window_max );
70206986
70216987 if (vmx -> ple_window != old )
70226988 vmx -> ple_window_dirty = true;
@@ -7029,8 +6995,9 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu)
70296995 struct vcpu_vmx * vmx = to_vmx (vcpu );
70306996 int old = vmx -> ple_window ;
70316997
7032- vmx -> ple_window = __shrink_ple_window (old ,
7033- ple_window_shrink , ple_window );
6998+ vmx -> ple_window = __shrink_ple_window (old , ple_window ,
6999+ ple_window_shrink ,
7000+ ple_window );
70347001
70357002 if (vmx -> ple_window != old )
70367003 vmx -> ple_window_dirty = true;
0 commit comments