Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp5172249pxb; Tue, 28 Sep 2021 12:04:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqVOADzbQ+8On3uT0Bm18lsJhg+gUHyA4bajRq2J0EW/mQ3Vx68JaAs5DSf9KKv8Ej4eJL X-Received: by 2002:a17:907:1df1:: with SMTP id og49mr8601893ejc.35.1632855884636; Tue, 28 Sep 2021 12:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632855884; cv=none; d=google.com; s=arc-20160816; b=y/KMjSEI7tw2+/qhq2mMq0peTQiw0G4+VVm7/U0cfq5oA93xyK6VFMr17vEB/v2i4o a1fkcMxY8t8CPuIwXo7AIgEtY+MdDJ5Bd0Y7y8VeyH0SHuLBtDUTarV4wnUJmwvVVCxd tbW64zkZF4/bm8U9rtwzZVezZE9oHIIPpMfQRxDsqe2hiV/BRItRdBA5Fw1QhYiryBOy D0khz6+2qe8qb+Wuo99iCn0FarNjX57gUsfp60Njzsy0Put3Zqlga9RW4glZ/Yd2Shv7 mSyjXILejBfolvnQnVS/mIONu310l9eC7qFJBmWKcUw35b1OVjoJIcpnfEPtpY1A+sHb cmTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xt0gEcyOTVXB3cbfAORCeU0aPfpfHLNMXNfI9X69CVQ=; b=rQogxQGfRzlzSxViwKoYcbaahmaAN6Klv4rLUfdg5ZaTAoemJkdP8mgzXX8PJq9l8m kxuBIo7yHZtSUlA36W4J1+sptxQB3AzfiGZUPK0kbl/zVYWQc7tZqfGiOPTsc1LtZiv0 YWVSDaFrnxwy0cpG149zaXmh6LNNw4KAojk0eDJHlWpRyuXQ8Qi/dlQ9PhChEUmDSOzD 07pWZutUz+zgNDOXw0mc6geRyXTxLjqvAUosiFqM5t/Zf+JdGIMnmcmVf9Nr7Be9VRYW +SOBnVlaxBl60kTZEv77HRCAZ8I3b1kIaynWiIqMMH3h6nbdWXnQVuL7sdnoxbt5u7rp JqPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=P2WbyomA; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e25si4060414edr.609.2021.09.28.12.04.13; Tue, 28 Sep 2021 12:04:44 -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=@google.com header.s=20210112 header.b=P2WbyomA; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242169AbhI1TDX (ORCPT + 99 others); Tue, 28 Sep 2021 15:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242333AbhI1TDW (ORCPT ); Tue, 28 Sep 2021 15:03:22 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC6EAC061749 for ; Tue, 28 Sep 2021 12:01:42 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id y5so12406106pll.3 for ; Tue, 28 Sep 2021 12:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=xt0gEcyOTVXB3cbfAORCeU0aPfpfHLNMXNfI9X69CVQ=; b=P2WbyomAz9CC+YDhARNtEQPob4jnZ2g2oykK3Tx9s3ZzF3kIhs4M8u5I6nL6TYVoGq rrOLmGGUE/wsUTWlv/vaHIT0qruIxiC5Hconls6bpVJIAswiiw3izm0NUdKLNEX/vTj1 hNuCFj8rB/KJEKNYPyTIjrwmUxsuMdqXz/A3MzGuI1a3Kwyq70MOLXcjCuAwjRmB7Dhb kf47CJCAyIoWzJus9Q6TAK/lSg8ZsxvgmyTdZgT9A2DiUE772alKYF35OPb474XMP0BJ 1g92CPbM5JIG9MA0Bz7RxJUC/t1T7o89IaaifLPvH7z+3t2ti9exdaFi/jE6y9Sz0Jjp UImg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xt0gEcyOTVXB3cbfAORCeU0aPfpfHLNMXNfI9X69CVQ=; b=OCY1ykDn7enM58m8I6/miw7QIZAJRRQYcVOc/XUxcPw90YN3q0iA1b+k2p2FFTVpPT vNSAM8XtpxHh58EFQGMVXzTdJsDkmqAe7w0ESY7vAuXZEYnoBVXIdsEZ0Gr2xeQJtK3D nR97SznWWf2MO5hPog/ZcRrXQ2qdHRqLGkYKbA6ODH3VSzoWVxP71e927hw3aryq89V7 bcPGnDhHIWpoYn9eyRzutj/CVldyBts5BfB+lMtV4AaYd1EQUp3fgZ1XshLvCIjvOUtE jHYT+2e6/Xhme9qJxFZGhBVSVBLJLm7ytzOTTpjdap1xJB+nNY2xDe2tDv7/yTMOTXXr Sjww== X-Gm-Message-State: AOAM533wAXNS0GDhgnIomPnulZng9EHmH8f/QLgSKPVMu4uGyYshaYqh XzDNJ62GWDdWdS9DvBEvoqTi4w== X-Received: by 2002:a17:902:b909:b0:13a:2d8e:12bc with SMTP id bf9-20020a170902b90900b0013a2d8e12bcmr6453208plb.6.1632855701799; Tue, 28 Sep 2021 12:01:41 -0700 (PDT) Received: from google.com (254.80.82.34.bc.googleusercontent.com. [34.82.80.254]) by smtp.gmail.com with ESMTPSA id j24sm20993011pfh.65.2021.09.28.12.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 12:01:41 -0700 (PDT) Date: Tue, 28 Sep 2021 19:01:38 +0000 From: David Matlack To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , 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, linux-kernel@vger.kernel.org, Jing Zhang Subject: Re: [PATCH 03/14] KVM: Refactor and document halt-polling stats update helper Message-ID: References: <20210925005528.1145584-1-seanjc@google.com> <20210925005528.1145584-4-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210925005528.1145584-4-seanjc@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 24, 2021 at 05:55:17PM -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 the update helper so that the helper is a dumb function that is "told" > whether or not polling was successful, as opposed to having it determinine > success/failure 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. > > Signed-off-by: Sean Christopherson Reviewed-by: David Matlack > --- > 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 8b33f5045b4d..12fe91a0a4c8 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3199,13 +3199,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; > } > > /* > @@ -3274,9 +3276,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)) { > -- > 2.33.0.685.g46640cef36-goog >