Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp364443pxb; Wed, 6 Oct 2021 06:40:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy26pt1XWh+NtefqPE+DKMZ6AyexGLrfKJSBzuSoCkdfwnFvZbv/3P2uK5hsjwbLhqDfhB7 X-Received: by 2002:a05:6402:4d1:: with SMTP id n17mr35274088edw.337.1633527653695; Wed, 06 Oct 2021 06:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633527653; cv=none; d=google.com; s=arc-20160816; b=spRnHH9A+dZ/BqkvTwWI7Mu9hUW+x4/c0tARzaYWcIDiMzAjHoNfzxbJxIXESwagbE xIgGnrDiLEYV7XdA1zymEwb2QkZvvkgqb+qxUtXTls+STDOCtP+7ZsJBqqf/OQy10Brm EkIdSQ05kf0zY7DuKFO4sWCeOwG71Jk1aYmXZKtF2U54/Cr07I6CKjGB7Ql+OUcr1wv/ q8QTJ1KV6MPjOLBDnTJrymjuRWSsf/jLUuyMkkca+lDtuF+zu/gCd1Fu+RmcVuRisC7f qeXATIZJp5r6Orc2l2gra6jUMIRDEKl4s5bBLb9Z5gjAhugWlYDWTVy4ms7KK7mSuwFP 25+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=mdCtjmJ1UXZrI9DLoQzPgnLklkeoiryi6u7rrgv0/LQ=; b=Qaxz/BujYcpMjuROtgoaBqcRvya2cl1Y7CoFgm5zuuntIisjmB42fmmPuQw76eP0Ax UyZwNj/ybfz61GKRZzL2tABfuERDmaBe4b800aNl0fU/zjkUSSc/8j/0AR/2LFCggNBE 1EwNjfXqqCllsolJIc4YO45RYhDlY8A7XVWxLuOtZjJ5RuSriXOBZJ6XsM9YoEGMnbl6 uT9naTEjvMj5SYM6XQF+IILL4C/fBWi6MyXkvnTA0yv47/t7lJd60EEJ5FeUDrk7QCO5 icHRG97cMxiOCOcD5HqHPneUpn7NGsFkchNCZRgYOHx4oajenadTJUmmYwq8TbvP73nO v31Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TkVUvQF0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si27663236ejm.298.2021.10.06.06.40.28; Wed, 06 Oct 2021 06:40:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TkVUvQF0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238816AbhJFNi0 (ORCPT + 99 others); Wed, 6 Oct 2021 09:38:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42104 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239005AbhJFNiV (ORCPT ); Wed, 6 Oct 2021 09:38:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633527389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mdCtjmJ1UXZrI9DLoQzPgnLklkeoiryi6u7rrgv0/LQ=; b=TkVUvQF0J1sX4zB+K+Klpvzd86F6Khm6U4cK7duRMygRG6T7wYuvX6OIlwH4PqmORp6k1A JjVDweLEqSOn5tRWpq6NnWfrHYAhocQzgZ+CnNuFJuVpsSY7KMmKhBLqsPk7EMVWcc+9CQ uCnnCCw2OVs4d1ckHz5LJoQJ2Z0aNpg= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-NpGXfRC3PuGU8ReZ2Wf-zw-1; Wed, 06 Oct 2021 09:36:28 -0400 X-MC-Unique: NpGXfRC3PuGU8ReZ2Wf-zw-1 Received: by mail-ed1-f70.google.com with SMTP id d11-20020a50cd4b000000b003da63711a8aso2623905edj.20 for ; Wed, 06 Oct 2021 06:36:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=mdCtjmJ1UXZrI9DLoQzPgnLklkeoiryi6u7rrgv0/LQ=; b=dZvhTvUupgQLQTAgf7IdZL2Rp5ph76XUThLiwjHO2adwuE7eyTlt8gNtF9FnSW2ANu OUo2vBMDDbDDrg7H3yFS3An2TjdrOH25cCjTGxJ6zWRvFjWQFsjFW+mUq5VC5rkqqBky MgP8qLt9XSEVv9a8u1HOVQ8B9k0Zftv3laZxVJp4J4JsUL8nlIKwmk1U0i5ZQsszc5+h 0sT1TVkUqUOEBnM5Ve4RpOXu2dM/bW4JlPauFNxP0GWUtJxs3KObidwT1qGM0w4OV4ZG oMwxBMDIwBwb60QPWvjlGgNrllpiDVLYcW4YYwR+JRJgHTuEac7NQ3gRTbwAAJRBx6e0 aqvg== X-Gm-Message-State: AOAM532CnP/VRkLbnqtMwERbw6Mjk7nOEOTBUBvhKaTaBqKdnPz9LLpL yjVA1VAlRN+N5h1xm20VnzkHCE8XVQWbY0U0kv21Vd/fbQ89m6S7PzoB5Pv0vG5Cz+oj25umTq6 0lbCGR+b4FhGtbULj7ugCFALt X-Received: by 2002:a05:6402:19b5:: with SMTP id o21mr34283820edz.214.1633527386841; Wed, 06 Oct 2021 06:36:26 -0700 (PDT) X-Received: by 2002:a05:6402:19b5:: with SMTP id o21mr34283798edz.214.1633527386673; Wed, 06 Oct 2021 06:36:26 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id eg31sm770602edb.38.2021.10.06.06.36.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Oct 2021 06:36:26 -0700 (PDT) Message-ID: Date: Wed, 6 Oct 2021 15:36:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH MANUALSEL 5.14 3/9] KVM: do not shrink halt_poll_ns below grow_start Content-Language: en-US To: Sasha Levin , linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sergey Senozhatsky , kvm@vger.kernel.org References: <20211006133021.271905-1-sashal@kernel.org> <20211006133021.271905-3-sashal@kernel.org> From: Paolo Bonzini In-Reply-To: <20211006133021.271905-3-sashal@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/10/21 15:30, Sasha Levin wrote: > From: Sergey Senozhatsky > > [ 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 > Signed-off-by: Paolo Bonzini > Message-Id: <20210902031100.252080-1-senozhatsky@chromium.org> > Signed-off-by: Paolo Bonzini > Signed-off-by: Sasha Levin > --- > 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 b50dbe269f4b..1a11dcb670a3 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3053,15 +3053,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