LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] KVM: do not shrink halt_poll_ns below grow_start
@ 2021-09-02  3:11 Sergey Senozhatsky
  2021-09-15  1:42 ` Sergey Senozhatsky
  0 siblings, 1 reply; 3+ messages in thread
From: Sergey Senozhatsky @ 2021-09-02  3:11 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Suleiman Souhlal, kvm, linux-kernel, Sergey Senozhatsky

grow_halt_poll_ns() ignores values between 0 and
halt_poll_ns_grow_start (10000 by default). However,
when we shrink halt_poll_ns we may fall way below
halt_poll_ns_grow_start and endup with halt_poll_ns
values that don't make a lot of sense: like 1 or 9,
or 19.

VCPU1 trace (halt_poll_ns_shrink equals 2):

VCPU1 grow 10000
VCPU1 shrink 5000
VCPU1 shrink 2500
VCPU1 shrink 1250
VCPU1 shrink 625
VCPU1 shrink 312
VCPU1 shrink 156
VCPU1 shrink 78
VCPU1 shrink 39
VCPU1 shrink 19
VCPU1 shrink 9
VCPU1 shrink 4

Mirror what grow_halt_poll_ns() does and set halt_poll_ns
to 0 as soon as new shrink-ed halt_poll_ns value falls
below halt_poll_ns_grow_start.

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
 virt/kvm/kvm_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index b25cc69ab90f..c84b1447ca62 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3136,15 +3136,19 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
 
 static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu)
 {
-	unsigned int old, val, shrink;
+	unsigned int old, val, shrink, grow_start;
 
 	old = val = vcpu->halt_poll_ns;
 	shrink = READ_ONCE(halt_poll_ns_shrink);
+	grow_start = READ_ONCE(halt_poll_ns_grow_start);
 	if (shrink == 0)
 		val = 0;
 	else
 		val /= shrink;
 
+	if (val < grow_start)
+		val = 0;
+
 	vcpu->halt_poll_ns = val;
 	trace_kvm_halt_poll_ns_shrink(vcpu->vcpu_id, val, old);
 }
-- 
2.33.0.259.gc128427fd7-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: do not shrink halt_poll_ns below grow_start
  2021-09-02  3:11 [PATCH] KVM: do not shrink halt_poll_ns below grow_start Sergey Senozhatsky
@ 2021-09-15  1:42 ` Sergey Senozhatsky
  2021-09-21 17:50   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Sergey Senozhatsky @ 2021-09-15  1:42 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Suleiman Souhlal, kvm, linux-kernel, Sergey Senozhatsky

On (21/09/02 12:11), Sergey Senozhatsky wrote:
> grow_halt_poll_ns() ignores values between 0 and
> halt_poll_ns_grow_start (10000 by default). However,
> when we shrink halt_poll_ns we may fall way below
> halt_poll_ns_grow_start and endup with halt_poll_ns
> values that don't make a lot of sense: like 1 or 9,
> or 19.
> 
> VCPU1 trace (halt_poll_ns_shrink equals 2):
> 
> VCPU1 grow 10000
> VCPU1 shrink 5000
> VCPU1 shrink 2500
> VCPU1 shrink 1250
> VCPU1 shrink 625
> VCPU1 shrink 312
> VCPU1 shrink 156
> VCPU1 shrink 78
> VCPU1 shrink 39
> VCPU1 shrink 19
> VCPU1 shrink 9
> VCPU1 shrink 4
> 
> Mirror what grow_halt_poll_ns() does and set halt_poll_ns
> to 0 as soon as new shrink-ed halt_poll_ns value falls
> below halt_poll_ns_grow_start.

Gentle ping.

	-ss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: do not shrink halt_poll_ns below grow_start
  2021-09-15  1:42 ` Sergey Senozhatsky
@ 2021-09-21 17:50   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2021-09-21 17:50 UTC (permalink / raw)
  To: Sergey Senozhatsky; +Cc: Suleiman Souhlal, kvm, linux-kernel

On 15/09/21 03:42, Sergey Senozhatsky wrote:
> On (21/09/02 12:11), Sergey Senozhatsky wrote:
>> grow_halt_poll_ns() ignores values between 0 and
>> halt_poll_ns_grow_start (10000 by default). However,
>> when we shrink halt_poll_ns we may fall way below
>> halt_poll_ns_grow_start and endup with halt_poll_ns
>> values that don't make a lot of sense: like 1 or 9,
>> or 19.
>>
>> VCPU1 trace (halt_poll_ns_shrink equals 2):
>>
>> VCPU1 grow 10000
>> VCPU1 shrink 5000
>> VCPU1 shrink 2500
>> VCPU1 shrink 1250
>> VCPU1 shrink 625
>> VCPU1 shrink 312
>> VCPU1 shrink 156
>> VCPU1 shrink 78
>> VCPU1 shrink 39
>> VCPU1 shrink 19
>> VCPU1 shrink 9
>> VCPU1 shrink 4
>>
>> Mirror what grow_halt_poll_ns() does and set halt_poll_ns
>> to 0 as soon as new shrink-ed halt_poll_ns value falls
>> below halt_poll_ns_grow_start.
> 
> Gentle ping.
> 
> 	-ss
> 

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-21 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02  3:11 [PATCH] KVM: do not shrink halt_poll_ns below grow_start Sergey Senozhatsky
2021-09-15  1:42 ` Sergey Senozhatsky
2021-09-21 17:50   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).