Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2275499pxb; Sat, 25 Sep 2021 02:52:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkhSa9CFjNjrrSjRvyryv5clDz+dbSXeo/cy60WrsG6RIAFcou1UCaT+XzMzRgyn2Mrtx6 X-Received: by 2002:a92:dc01:: with SMTP id t1mr12184183iln.267.1632563579280; Sat, 25 Sep 2021 02:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632563579; cv=none; d=google.com; s=arc-20160816; b=wra+9uaW3vf9iKwHuMmZm+evy90aOmxCtSzjX6AIuy52xMN8M04yCzgE1MRF/Kl7Zp 3EWm+FdtO3oPb49Y+++/DHB+lD6CsScJymIIz8uFzszqR6/ddAWauHwO/6dOCypnvc4N 0KvS9Xu5mQAZ0z6s7PHbtMMQppnuHWX1gtQs4svGfd+3dLPG77iKE4tws/aQkGhMywfq hon1bwetSa9rqohS/4bNbR/eLUccjYXgZaO/ppCKEwdwMfK1Dq+ZxGEwlMxyrLBQrbw2 LejZgpMSgERCepa3uQ9+qEo8B91+Gs32CoGIorLdvUzo5QUtdX0XHGq2jWYQbmHhbTxX ynoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=SvzrzrsqDNMBINDvB/EMH34ElaWO5rkvU19ddXq0dHQ=; b=issyHVD5eI/m2whM1nOYtTLbFgPRgrsmkbjp8sJj28rE9BZbwCP9kI9YyIopeWuD3n JCXifrgBwVOBJwrpxOu8RXREtyyVKcr9yeR+heuoYFUBiJ5NzXsjxoAN2ClYSX8lOn30 Wp+8JCaJi/3gdmQFbfpr6pQvscDEl6ri88zV+B5FbbXH2lXk19JnU3QA+IJamKaX/EhL sqljDB4T8FpL/oQmmB414kI+GNMh8JNJ3/I9Gv7iTIyleVA1TAh2gQqtlTqM+gos0JAT YE3QINkNUWPnhmXkNtNTFyK6HHE5+OoRvCSOmiHGp/T1ZYvX8OADS87RgDc3ZgG1/T/R nIcw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si15560616ilv.34.2021.09.25.02.52.33; Sat, 25 Sep 2021 02:52:59 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241912AbhIYJwI (ORCPT + 99 others); Sat, 25 Sep 2021 05:52:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:58102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240182AbhIYJv5 (ORCPT ); Sat, 25 Sep 2021 05:51:57 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 441BD61279; Sat, 25 Sep 2021 09:50:08 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mU4Jq-00Cuoe-EB; Sat, 25 Sep 2021 10:50:06 +0100 Date: Sat, 25 Sep 2021 10:50:05 +0100 Message-ID: <878rzlass2.wl-maz@kernel.org> From: Marc Zyngier To: Sean Christopherson Cc: 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, David Matlack , Jing Zhang Subject: Re: [PATCH 07/14] KVM: Don't block+unblock when halt-polling is successful In-Reply-To: <20210925005528.1145584-8-seanjc@google.com> References: <20210925005528.1145584-1-seanjc@google.com> <20210925005528.1145584-8-seanjc@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: seanjc@google.com, chenhuacai@kernel.org, aleksandar.qemu.devel@gmail.com, paulus@ozlabs.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, pbonzini@redhat.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, david@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, 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, dmatlack@google.com, jingzhangos@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 25 Sep 2021 01:55:21 +0100, Sean Christopherson wrote: > > Invoke the arch hooks for block+unblock if and only if KVM actually > attempts to block the vCPU. The only non-nop implementation is on arm64, > and if halt-polling is successful, there is no need for arm64 to put/load > the vGIC as KVM hasn't relinquished control of the vCPU in any way. This doesn't mean that there is no requirement for any state change. The put/load on GICv4 is crucial for performance, and the VMCR resync is a correctness requirement. > > The primary motivation is to allow future cleanup to split out "block" > from "halt", but this is also likely a small performance boost on arm64 > when halt-polling is successful. > > Adjust the post-block path to update "cur" after unblocking, i.e. include > vGIC load time in halt_wait_ns and halt_wait_hist, so that the behavior > is consistent. Moving just the pre-block arch hook would result in only > the vGIC put latency being included in the halt_wait stats. There is no > obvious evidence that one way or the other is correct, so just ensure KVM > is consistent. This effectively reverts 07ab0f8d9a12 ("KVM: Call kvm_arch_vcpu_blocking early into the blocking sequence"), which was a huge gain on arm64, not to mention a correctness fix. Without this, a GICv4 machine will always pay for the full poll penalty, going into schedule(), and only then get a doorbell interrupt signalling telling the kernel that there was an interrupt. On a non-GICv4 machine, it means that interrupts injected by another thread during the pooling will be evaluated with an outdated priority mask, which can result in either a spurious wake-up or a missed wake-up. If it means introducing a new set of {pre,post}-poll arch-specific hooks, so be it. But I don't think this change is acceptable as is. Thanks, M. -- Without deviation from the norm, progress is not possible.