From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3131C433EF for ; Wed, 27 Oct 2021 10:57:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3B7C61040 for ; Wed, 27 Oct 2021 10:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239964AbhJ0K7c (ORCPT ); Wed, 27 Oct 2021 06:59:32 -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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33FD2C433EF for ; Wed, 27 Oct 2021 10:57:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4C8D60F5A for ; Wed, 27 Oct 2021 10:57:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C4C8D60F5A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KFNiuTnhBQoaG+xcNxPAIfXKfpcDVQPxXJtR6ftCUd0=; b=LAXXTX3VevNwQ7 JYnpV1p/NHjWoLhOoCttNtiavsK+Eht1uae6tibCDO0HgTRpS6vfS+XQEWhAoJl40At0RRTSNplp4 zdIbKAY2Uh3/+K4Zmd9e88VFxaFM7/YDljPuDEVS61fc5wCa1MORihOMit1fnp1R23AVv0Sks7of+ ElAcdsjEBm6KAo4oo6fWp3Gx5APhxqfojY2uB7kiCvMPqzCCx5rEeTJXB/GHkAnYQM4B3O3KmuuXV XCZ1JfUG9XilSQhxonBe4u1H4aOPnKYw5ZRIbhVu+lO4NYDq33AGBp54YClaQmu3UrY8qNVC2xx+i pNkMTZCyOv09S+sRRUUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfgcH-004dlF-LD; Wed, 27 Oct 2021 10:57:09 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfgcE-004dii-7v for linux-riscv@lists.infradead.org; Wed, 27 Oct 2021 10:57:08 +0000 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> User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211027_035706_411167_98DABF4D X-CRM114-Status: GOOD ( 24.91 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8FD5C433F5 for ; Wed, 27 Oct 2021 10:58:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 856B260C40 for ; Wed, 27 Oct 2021 10:58:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 856B260C40 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PFVntSlIqfwu/k8gslPw0Usk1skYxQXFis8Erzlgkp0=; b=tfT3VQF/O8NKRA Y7v9eeQkYDuKVXt6UfbGDE6eYV8ZYqP9c3Pc9hBy2lcnXa2q+qkirNiUAMdzjp+PAwbn5PZCWA6tf nlo7NHPdvFFfSCP+twKmwMTYOK6q9ZLa0ZmTEbU7/L2SIxKQD/DnBeryf0rXStfX6bz9puPn/re9y NDbVGP+Y3nJW9IpWk2IIDPbItfLlczbEu1iugHZN3b+BvTSXe+lHurz1sC5DapBIeO4f79nu0qM5p 1QrJd5qh9neFI74qV4ddGqeaP6LiqENpH5rfrXEOwD9iDh1gAdnLF33Z4sFNBc6V7Hg/6EXBvkGQF YZyaMTMWCfdErzYk0GlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfgcM-004dmF-6z; Wed, 27 Oct 2021 10:57:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfgcE-004dik-7w for linux-arm-kernel@lists.infradead.org; Wed, 27 Oct 2021 10:57:08 +0000 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> User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211027_035706_404693_312003C7 X-CRM114-Status: GOOD ( 25.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBFD1C433F5 for ; Wed, 27 Oct 2021 12:23:53 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 69F8B610A0 for ; Wed, 27 Oct 2021 12:23:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 69F8B610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id CA1334B16E; Wed, 27 Oct 2021 08:23:52 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tkdt9cqfCCcx; Wed, 27 Oct 2021 08:23:51 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 868114B15E; Wed, 27 Oct 2021 08:23:51 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BB8AB4B106 for ; Wed, 27 Oct 2021 06:57:05 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id StFh62ut9ACD for ; Wed, 27 Oct 2021 06:57:03 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id EACD14B102 for ; Wed, 27 Oct 2021 06:57:03 -0400 (EDT) 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 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> User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mailman-Approved-At: Wed, 27 Oct 2021 08:23:51 -0400 Cc: Wanpeng Li , kvm@vger.kernel.org, David Hildenbrand , linux-kernel@vger.kernel.org, Atish Patra , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Joerg Roedel , kvm-ppc@vger.kernel.org, David Matlack , linux-arm-kernel@lists.infradead.org, Jim Mattson , Cornelia Huck , linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, Vitaly Kuznetsov X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxim Levitsky Date: Wed, 27 Oct 2021 10:56:43 +0000 Subject: Re: [PATCH v2 06/43] KVM: Refactor and document halt-polling stats update helper Message-Id: <4acc8c7fb3751be07953322a8334be140c2b153e.camel@redhat.com> List-Id: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-7-seanjc@google.com> In-Reply-To: <20211009021236.4122790-7-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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