Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp914529pxb; Wed, 27 Oct 2021 15:06:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywlje/w0G5KZVNmErSnxRrDww7SvE2dILlkhv/BByGBe0bj263WS04l4BH/iLISE/dPQTr X-Received: by 2002:a17:903:2091:b0:141:64ae:f56e with SMTP id d17-20020a170903209100b0014164aef56emr216075plc.76.1635372413318; Wed, 27 Oct 2021 15:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635372413; cv=none; d=google.com; s=arc-20160816; b=yVs81PcD8XUds0KxFnxQNXZehcvO61NDnQ4RLm6FZGxKrPxVtO4GvDqERXlauhjTbb YPuF7OE/6Qx3uue+kXiMfYsV+s4PGVCbmz4u/jzGa2weRi/4Gs7yKJV9mG5zK7J+lO6j moi0pm/37yI7VbcFbxmRwkzZJd+xK2aJN9WvSK9FGVqFZQTZ+XHH8TS5D0DTTU08FMXx /JwmYxTC4u3raE+0+kqrWK6+SCOnZENSjibPdhO8a2BuF9lqDmNXspIXOeqOrRb1UZsd ENL1kkoIKKTi82QAxkARpr7AhIRj2Jhw8CHDG5T4pI/RCc0H/YbAAWEZSz1dDDeazZFG GrEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=0f27XW5ipOgXyw7srO4b+jUX50VuAlw+C7sxFBFkpEA=; b=MeoyWPZ3lbc640o0aiRxvAws+juQK6kx7/f37kKutOuXAIcK1NJGFo4l0pP9/JaiAw Ca2t4L5aiKd8vwt6eDCCMTdGBwYT/8L4ox9tjHV0dzmpUzLvcljcRHemc4jpeQA3T2sn 15jes3te8uWMUD9A+K7nmUs6OCZpHjZZqXmc8kd0IMIKBHqRHxYvYYZ1mddylZ9d/t9F 5JXnSlCqKji2uvZSwiujWP+CN0Ia3wULVJMCyJWHRoYjq7TQj0MnOlCX/VpXwvSlblIo yOIY5EPe/vjPdfznGZkAl6XdRIZwZMz5RAvOb8mTrDR4g7UFxvLFrbgslMF5OjAovxWq vE4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z4xywkau; 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 h6si1687320pfc.21.2021.10.27.15.06.40; Wed, 27 Oct 2021 15:06: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=Z4xywkau; 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 S239171AbhJ0KVT (ORCPT + 97 others); Wed, 27 Oct 2021 06:21:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27524 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232533AbhJ0KVS (ORCPT ); Wed, 27 Oct 2021 06:21:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635329933; 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=0f27XW5ipOgXyw7srO4b+jUX50VuAlw+C7sxFBFkpEA=; b=Z4xywkau7qK0Pa6XDZcZ14UI/7PrtgD9YDOHNSg5tYFg5d/88pFRakzhidvff6NyyCoF+U UDZYk0YkczFVpynDIUCugpAIiwewCx6UJfWFEu3GTMfnycj77uYUuJFsVKazk/uNMNNdhc FzPOv7pWxTVcTnUvnq/+cO3NTe7tYHw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-578-NX_vwU-ZN9SDSZWcd7uWxg-1; Wed, 27 Oct 2021 06:18:50 -0400 X-MC-Unique: NX_vwU-ZN9SDSZWcd7uWxg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2879100C661; Wed, 27 Oct 2021 10:18:45 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC5315BAE0; Wed, 27 Oct 2021 10:18:25 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 05/43] KVM: Update halt-polling stats if and only if halt-polling was attempted From: Maxim Levitsky To: Sean Christopherson , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , Oliver Upton , Jing Zhang Date: Wed, 27 Oct 2021 13:18:24 +0300 In-Reply-To: <20211009021236.4122790-6-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-6-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-10-08 at 19:11 -0700, Sean Christopherson wrote: > Don't update halt-polling stats if halt-polling wasn't attempted. This > is a nop as @poll_ns is guaranteed to be '0' (poll_end == start), but it > will allow a future patch to move the histogram stats into the helper to > resolve a discrepancy in what is considered a "successful" halt-poll. > > No functional change intended. > > Reviewed-by: David Matlack > Signed-off-by: Sean Christopherson > --- > virt/kvm/kvm_main.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 5d4a90032277..6156719bcbbc 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3217,6 +3217,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) > { > struct rcuwait *wait = kvm_arch_vcpu_get_wait(vcpu); > bool halt_poll_allowed = !kvm_arch_no_poll(vcpu); > + bool do_halt_poll = halt_poll_allowed && vcpu->halt_poll_ns; > ktime_t start, cur, poll_end; > bool waited = false; > u64 block_ns; > @@ -3224,7 +3225,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) > kvm_arch_vcpu_blocking(vcpu); > > start = cur = poll_end = ktime_get(); > - if (vcpu->halt_poll_ns && halt_poll_allowed) { > + if (do_halt_poll) { > ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); > > ++vcpu->stat.generic.halt_attempted_poll; > @@ -3276,8 +3277,9 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) > kvm_arch_vcpu_unblocking(vcpu); > block_ns = ktime_to_ns(cur) - ktime_to_ns(start); > > - update_halt_poll_stats( > - vcpu, ktime_to_ns(ktime_sub(poll_end, start)), waited); > + if (do_halt_poll) > + update_halt_poll_stats( > + vcpu, ktime_to_ns(ktime_sub(poll_end, start)), waited); > > if (halt_poll_allowed) { > if (!vcpu_valid_wakeup(vcpu)) { Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky