Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp882074pxb; Wed, 27 Oct 2021 14:23:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWD5nHhr39aWll0r/IPdcrr/PhVMb2W6xTYcMlGGWPPfpfL0qfHeA77B1SVtLJ+jrKYOHp X-Received: by 2002:a17:907:6d9f:: with SMTP id sb31mr46544ejc.195.1635369837622; Wed, 27 Oct 2021 14:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635369837; cv=none; d=google.com; s=arc-20160816; b=TS/D4e+4D5HCAi1XNMIwoE53HUxeAu1MquNB+h9GrzVC8AohTTb+FJ5B8dA/b4EbJg MVk5S+CRNxJ8z1t2WlFHatzcZ1GJlpm1kHsYTp3RC21LE7Y2jIs07OXgmEqDfjDtRWfZ 0+zwZE3HbqrbHxeA+0hvn2vQLLSpWR9rMMfeOB94lfcztmd+Q6WncCaACY7r5vSgH+YI 53u8R8U/yQC7sZj9zL+B/pB/GVbVxQmQyOidvtf6cczedxExF/RCp5RQfxXpu/pfrn4K k2qtZAbAdl609q+EMpVk7k7kWxb6InAJirkLXIuXauBFMjMDpWfg6AjsBRev8Q9DvkPy f/gA== 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=q0cqoEHWoafdN/neNzYUeAZhdEpkcTz/8jBJYOGEWjQ=; b=Qr5AZZeMZolK2E9nnpxkn9eopSkvTJLsF3aybQ4a03yYitkN35Kwyd+Nti71KxsoPE mCsXTUHstn0Bv3cQtXpFqWniIUtrUritJ9eY0dbWET1kIXjYbLIgEhgn2yClT07Lj371 A7XFFiu43vhlgxNobYHhkdWNZDWYzRicMgLPlLpAklc0+UAD9rO/Mn5sQtwACv49YSMU torh1bvbrcneEmrb8trrhR+siuycnTYML82c6yI/zU1HjYrUkEPe4HHcN4oTc84T6TuZ Wzak0cO3OzQqW1fnerVheWwh8hcHVNvfUeEd/MCD56GUEhFauvVmHtXlJqPcS/etajEZ Bwsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MjdPA2i3; 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 hb32si1414160ejc.344.2021.10.27.14.23.34; Wed, 27 Oct 2021 14:23:57 -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=MjdPA2i3; 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 S239947AbhJ0K7a (ORCPT + 97 others); Wed, 27 Oct 2021 06:59:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38425 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239832AbhJ0K73 (ORCPT ); Wed, 27 Oct 2021 06:59:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635332223; 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=q0cqoEHWoafdN/neNzYUeAZhdEpkcTz/8jBJYOGEWjQ=; b=MjdPA2i37KSVL9JuUpe6F7hgc2uCocfLNY70l6lcl73NMAR5ff33SIiH6q26C3k0MMbEWX kagjt6DZ97rfTYViECwQwDfGQSNWQ/9PxYSLtGFkTmQJXrfeNS6nHkMlPKzd9BoCk2B2vL VUYjxkYgeqFK5mtEUxXF8mZf/kssvn4= 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-528-yDgbhhxWNqOR-mR8eneedg-1; Wed, 27 Oct 2021 06:57:00 -0400 X-MC-Unique: yDgbhhxWNqOR-mR8eneedg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAFF59F92B; Wed, 27 Oct 2021 10:56:56 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEBD457CA5; Wed, 27 Oct 2021 10:56:44 +0000 (UTC) Message-ID: <4acc8c7fb3751be07953322a8334be140c2b153e.camel@redhat.com> Subject: Re: [PATCH v2 06/43] KVM: Refactor and document halt-polling stats update helper 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:56:43 +0300 In-Reply-To: <20211009021236.4122790-7-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-7-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.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-10-08 at 19:11 -0700, Sean Christopherson wrote: > Add a comment to document that halt-polling is considered successful even > if the polling loop itself didn't detect a wake event, i.e. if a wake > event was detect in the final kvm_vcpu_check_block(). Invert the param > to update helper so that the helper is a dumb function that is "told" > whether or not polling was successful, as opposed to determining success > based on blocking behavior. > > Opportunistically tweak the params to the update helper to reduce the > line length for the call site so that it fits on a single line, and so > that the prototype conforms to the more traditional kernel style. > > No functional change intended. > > Reviewed-by: David Matlack > Signed-off-by: Sean Christopherson > --- > virt/kvm/kvm_main.c | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 6156719bcbbc..4dfcd736b274 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3201,13 +3201,15 @@ static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu) > return ret; > } > > -static inline void > -update_halt_poll_stats(struct kvm_vcpu *vcpu, u64 poll_ns, bool waited) > +static inline void update_halt_poll_stats(struct kvm_vcpu *vcpu, ktime_t start, > + ktime_t end, bool success) > { > - if (waited) > - vcpu->stat.generic.halt_poll_fail_ns += poll_ns; > - else > + u64 poll_ns = ktime_to_ns(ktime_sub(end, start)); > + > + if (success) > vcpu->stat.generic.halt_poll_success_ns += poll_ns; > + else > + vcpu->stat.generic.halt_poll_fail_ns += poll_ns; > } > > /* > @@ -3277,9 +3279,13 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) > kvm_arch_vcpu_unblocking(vcpu); > block_ns = ktime_to_ns(cur) - ktime_to_ns(start); > > + /* > + * Note, halt-polling is considered successful so long as the vCPU was > + * never actually scheduled out, i.e. even if the wake event arrived > + * after of the halt-polling loop itself, but before the full wait. > + */ > if (do_halt_poll) > - update_halt_poll_stats( > - vcpu, ktime_to_ns(ktime_sub(poll_end, start)), waited); > + update_halt_poll_stats(vcpu, start, poll_end, !waited); > > if (halt_poll_allowed) { > if (!vcpu_valid_wakeup(vcpu)) { Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky