[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9664819e-a767-3a92-5e5d-6a0418984cd4@redhat.com>
Date: Wed, 6 Oct 2021 13:23:04 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sasha Levin <sashal@...nel.org>, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>, kvm@...r.kernel.org
Subject: Re: [PATCH MANUALSEL 5.10 3/7] KVM: do not shrink halt_poll_ns below
grow_start
On 06/10/21 13:12, Sasha Levin wrote:
> From: Sergey Senozhatsky <senozhatsky@...omium.org>
>
> [ Upstream commit ae232ea460888dc5a8b37e840c553b02521fbf18 ]
>
> 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@...omium.org>
> Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
> Message-Id: <20210902031100.252080-1-senozhatsky@...omium.org>
> Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
> Signed-off-by: Sasha Levin <sashal@...nel.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 0e4310c415a8..57c0c3b18bde 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2756,15 +2756,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);
> }
>
Acked-by: Paolo Bonzini <pbonzini@...hat.com>
Powered by blists - more mailing lists