Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3726530ybn; Fri, 27 Sep 2019 10:25:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9xufb2P5tk1d6vsgWBs2O3Nho3u2NvwexTvr8vYbhnHGCMLl2Skorq7duun6h6vIewKlx X-Received: by 2002:a17:906:25ca:: with SMTP id n10mr8938393ejb.106.1569605109040; Fri, 27 Sep 2019 10:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569605109; cv=none; d=google.com; s=arc-20160816; b=HPYJjd1O4qfccBpQt2VJc+SrC3hTD/sWbBbvE0GbRhJMDKK9wWzB/5uPD4pJyL/gdZ CrUFI53SXMXUUtFiyCJEV9jOtlo9UW04hKDGfXhdR8KksEkdkI4M0ym7Eh9VNlAVTdaz 3mwqhncyhPc1COjyPW9smDBdORz7bpjCbJKE8R3Bpa2bBDB2u5tIR76Zk2ceqbLJD1KW HXKzS+a8c2lCU6CKUu4Kqc/u9pPDZUOpnsZ3ajP1jk5DxGv6RZQiAl7WnzYiDEX76wHc mBGDZPITonWs+C9xQ/JR7qKTr6RxtKAkiz4jkrCx+ASYyJMbDJNkZrT07h97aIEoqlw/ 21VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PpcaZPGKXjktp7Ou7nWg9NDovAuRkosDkZiGXYJsxFc=; b=Lwi+1Rfn/gUX6MQbTAGv38p2gBoUuFxYKuQ5Q3uFgNkIC8VODaCE92T+VQlS/qi8mN z2KKd+k96EhZkbhm5dZDHBUS7bffC1LFjB1tGcyiQS7O5mRpc5vxS3CpbpI4ADgnFFan zQ6XAOnzItacj/7+CApHUxiu3M+iLwG/vS2k/OPO839tPRIewNnHz0oWzHIEsueFy+6E mSYBYhTnYce5tETiD8fFHFPTRTBH8k4EkwV9QEl6OIGnLnwJeXuKE3KH634+M5/gLKTr xoH84Uip9zH6iDQOYxV7h+kZZpMHasUikvRtjmLutvG41K3JnBvVPKQJM2aghUaGmTGT tgkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w43si2055532edd.332.2019.09.27.10.24.44; Fri, 27 Sep 2019 10:25:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727825AbfI0RYN (ORCPT + 99 others); Fri, 27 Sep 2019 13:24:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58738 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbfI0RYM (ORCPT ); Fri, 27 Sep 2019 13:24:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 432CE898112; Fri, 27 Sep 2019 17:24:12 +0000 (UTC) Received: from amt.cnet (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4693D1001938; Fri, 27 Sep 2019 17:24:09 +0000 (UTC) Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 1AA6710515E; Fri, 27 Sep 2019 12:50:06 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.7/8.14.7/Submit) id x8RFo2cC012646; Fri, 27 Sep 2019 12:50:02 -0300 Date: Fri, 27 Sep 2019 12:50:02 -0300 From: Marcelo Tosatti To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel Subject: Re: [PATCH] KVM: Don't shrink/grow vCPU halt_poll_ns if host side polling is disabled Message-ID: <20190927154958.GB11810@amt.cnet> References: <1569572822-28942-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1569572822-28942-1-git-send-email-wanpengli@tencent.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Fri, 27 Sep 2019 17:24:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 27, 2019 at 04:27:02PM +0800, Wanpeng Li wrote: > From: Wanpeng Li > > Don't waste cycles to shrink/grow vCPU halt_poll_ns if host > side polling is disabled. > > Cc: Marcelo Tosatti > Signed-off-by: Wanpeng Li > --- > virt/kvm/kvm_main.c | 28 +++++++++++++++------------- > 1 file changed, 15 insertions(+), 13 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index e6de315..b368be4 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -2359,20 +2359,22 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) > kvm_arch_vcpu_unblocking(vcpu); > block_ns = ktime_to_ns(cur) - ktime_to_ns(start); > > - if (!vcpu_valid_wakeup(vcpu)) > - shrink_halt_poll_ns(vcpu); > - else if (halt_poll_ns) { > - if (block_ns <= vcpu->halt_poll_ns) > - ; > - /* we had a long block, shrink polling */ > - else if (vcpu->halt_poll_ns && block_ns > halt_poll_ns) > + if (!kvm_arch_no_poll(vcpu)) { > + if (!vcpu_valid_wakeup(vcpu)) > shrink_halt_poll_ns(vcpu); > - /* we had a short halt and our poll time is too small */ > - else if (vcpu->halt_poll_ns < halt_poll_ns && > - block_ns < halt_poll_ns) > - grow_halt_poll_ns(vcpu); > - } else > - vcpu->halt_poll_ns = 0; > + else if (halt_poll_ns) { > + if (block_ns <= vcpu->halt_poll_ns) > + ; > + /* we had a long block, shrink polling */ > + else if (vcpu->halt_poll_ns && block_ns > halt_poll_ns) > + shrink_halt_poll_ns(vcpu); > + /* we had a short halt and our poll time is too small */ > + else if (vcpu->halt_poll_ns < halt_poll_ns && > + block_ns < halt_poll_ns) > + grow_halt_poll_ns(vcpu); > + } else > + vcpu->halt_poll_ns = 0; > + } > > trace_kvm_vcpu_wakeup(block_ns, waited, vcpu_valid_wakeup(vcpu)); > kvm_arch_vcpu_block_finish(vcpu); > -- > 2.7.4 Looks good.