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 9B4F1C433F5 for ; Wed, 27 Oct 2021 15:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DD5C610A0 for ; Wed, 27 Oct 2021 15:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242732AbhJ0PVL (ORCPT ); Wed, 27 Oct 2021 11:21:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57432 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236432AbhJ0PVC (ORCPT ); Wed, 27 Oct 2021 11:21:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635347917; 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=Mqfkyc1h1IacAYuqVX+51EaEIUB4H7XAD3a00wXW0uo=; b=eir2d4PSGJ/MTPo0r1eSoM9O6N4VFKXDD1hvvAQaq/OmUvOjfL3JgzcKWqZpSR40TQT7/V 5yppdYlpv3eWQut0pgSUS19+d0zlLgr/xWEgnJWSREeoteqae9wbhQj0tjb/w/S8kP75vM bMwmT0WYEdaqlxMXrFzgYjfbt2Mq/fw= 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-129-NivpEGWfOKW2rqXDN2Iarw-1; Wed, 27 Oct 2021 11:18:33 -0400 X-MC-Unique: NivpEGWfOKW2rqXDN2Iarw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 090521023F57; Wed, 27 Oct 2021 15:18:26 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37C0260C48; Wed, 27 Oct 2021 15:18:14 +0000 (UTC) Message-ID: <796f9a7d553a0e13da5c44597666962620c64303.camel@redhat.com> Subject: Re: [PATCH v2 18/43] KVM: x86: Invoke kvm_vcpu_block() directly for non-HALTED wait states 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 18:18:13 +0300 In-Reply-To: <20211009021236.4122790-19-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-19-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.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > Call kvm_vcpu_block() directly for all wait states except HALTED so that > kvm_vcpu_halt() is no longer a misnomer on x86. > > Functionally, this means KVM will never attempt halt-polling or adjust > vcpu->halt_poll_ns for INIT_RECEIVED (a.k.a. Wait-For-SIPI (WFS)) or > AP_RESET_HOLD; UNINITIALIZED is handled in kvm_arch_vcpu_ioctl_run(), > and x86 doesn't use any other "wait" states. > > As mentioned above, the motivation of this is purely so that "halt" isn't > overloaded on x86, e.g. in KVM's stats. Skipping halt-polling for WFS > (and RESET_HOLD) has no meaningful effect on guest performance as there > are typically single-digit numbers of INIT-SIPI sequences per AP vCPU, > per boot, versus thousands of HLTs just to boot to console. > > Reviewed-by: David Matlack > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/x86.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index cd51f100e906..e0219acfd9cf 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9899,7 +9899,10 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu) > if (!kvm_arch_vcpu_runnable(vcpu) && > (!kvm_x86_ops.pre_block || static_call(kvm_x86_pre_block)(vcpu) == 0)) { > srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); > - kvm_vcpu_halt(vcpu); > + if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) > + kvm_vcpu_halt(vcpu); > + else > + kvm_vcpu_block(vcpu); > vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); > > if (kvm_x86_ops.post_block) 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 551FEC433EF for ; Wed, 27 Oct 2021 15:18:48 +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 1974C610D2 for ; Wed, 27 Oct 2021 15:18:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1974C610D2 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=Kk6BNm6NBMSZnqL1NRNhIprJRJA1fPqrAlXHlFh4zEE=; b=XS3oJC/DRm0DMp u1knKGaKV4PrAE39okpkwy0vJYD2QAwdF+FXKPNxXfdCQ9C7z3mUG16UvdpCKle8TmamDMjKQPQfL 1HrViH5A5iJfHWRkgp0sF1uCEpIOg/9hxLddiCN71hgJX98Q4w8PC9enNdJ8PukSz/DZL7FSNk970 nU2TawIzxSHLL4JQkch/+9Y6/SJo82xsJ3XeD52TCNwOHTe9Yc56pqREkWQarawr01pFpgY/4sHcl qeqb8PwUM4mmroBrGzLmM/OTfidDP2lPor8HpRSvKXscQeiAevTGrYFtserzx2z/gsn4d73fjnh/g dxi6SDTAskwfOD6j9HLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfkhN-005HLG-07; Wed, 27 Oct 2021 15:18:41 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfkhJ-005HJg-V5 for linux-riscv@lists.infradead.org; Wed, 27 Oct 2021 15:18:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635347917; 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=Mqfkyc1h1IacAYuqVX+51EaEIUB4H7XAD3a00wXW0uo=; b=eir2d4PSGJ/MTPo0r1eSoM9O6N4VFKXDD1hvvAQaq/OmUvOjfL3JgzcKWqZpSR40TQT7/V 5yppdYlpv3eWQut0pgSUS19+d0zlLgr/xWEgnJWSREeoteqae9wbhQj0tjb/w/S8kP75vM bMwmT0WYEdaqlxMXrFzgYjfbt2Mq/fw= 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-129-NivpEGWfOKW2rqXDN2Iarw-1; Wed, 27 Oct 2021 11:18:33 -0400 X-MC-Unique: NivpEGWfOKW2rqXDN2Iarw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 090521023F57; Wed, 27 Oct 2021 15:18:26 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37C0260C48; Wed, 27 Oct 2021 15:18:14 +0000 (UTC) Message-ID: <796f9a7d553a0e13da5c44597666962620c64303.camel@redhat.com> Subject: Re: [PATCH v2 18/43] KVM: x86: Invoke kvm_vcpu_block() directly for non-HALTED wait states 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 18:18:13 +0300 In-Reply-To: <20211009021236.4122790-19-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-19-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.14 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211027_081838_099870_E8DAE987 X-CRM114-Status: GOOD ( 20.05 ) 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:12 -0700, Sean Christopherson wrote: > Call kvm_vcpu_block() directly for all wait states except HALTED so that > kvm_vcpu_halt() is no longer a misnomer on x86. > > Functionally, this means KVM will never attempt halt-polling or adjust > vcpu->halt_poll_ns for INIT_RECEIVED (a.k.a. Wait-For-SIPI (WFS)) or > AP_RESET_HOLD; UNINITIALIZED is handled in kvm_arch_vcpu_ioctl_run(), > and x86 doesn't use any other "wait" states. > > As mentioned above, the motivation of this is purely so that "halt" isn't > overloaded on x86, e.g. in KVM's stats. Skipping halt-polling for WFS > (and RESET_HOLD) has no meaningful effect on guest performance as there > are typically single-digit numbers of INIT-SIPI sequences per AP vCPU, > per boot, versus thousands of HLTs just to boot to console. > > Reviewed-by: David Matlack > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/x86.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index cd51f100e906..e0219acfd9cf 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9899,7 +9899,10 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu) > if (!kvm_arch_vcpu_runnable(vcpu) && > (!kvm_x86_ops.pre_block || static_call(kvm_x86_pre_block)(vcpu) == 0)) { > srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); > - kvm_vcpu_halt(vcpu); > + if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) > + kvm_vcpu_halt(vcpu); > + else > + kvm_vcpu_block(vcpu); > vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); > > if (kvm_x86_ops.post_block) 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 3456EC433EF for ; Wed, 27 Oct 2021 15:19:58 +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 EA3E2610A0 for ; Wed, 27 Oct 2021 15:19:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EA3E2610A0 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=hU9bNmoVDTXsEDEvvvZPQq6pw9wun5Dbhm7kx4zcF0E=; b=2ZS0rGH56gbBrA Uk2WEuFb/CPR9XgTQFudTq8c8TKbQIdWTAdk6jYyFScEy4782dtSPzkm3kwKxr0MDzCzlfxcAF3WE 1+7fjtRpBl6srGIGPzf4k1iu8C4x93HzqjiO/HJ+WxrObNNlquVvaLBJhqBQv7E7AsFLYuhpKmF/t nbuquJaKeUYstuhz2EpAMgYVoLu36tPUn3GT0w7tMGasvYLb0z8qj5nQV/lu33w/tua4/CuSjLzsI PyxSiCsSXlgxg2sFg58BrEI3m1d8A1N4cSOMu57NhFO8Qmm++RIReVCRkmaHoDi2uBA/22tpb6DfM RjZjMnMMxCQu789K88Ww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfkhQ-005HLr-4I; Wed, 27 Oct 2021 15:18:44 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfkhJ-005HJf-VH for linux-arm-kernel@lists.infradead.org; Wed, 27 Oct 2021 15:18:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635347917; 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=Mqfkyc1h1IacAYuqVX+51EaEIUB4H7XAD3a00wXW0uo=; b=eir2d4PSGJ/MTPo0r1eSoM9O6N4VFKXDD1hvvAQaq/OmUvOjfL3JgzcKWqZpSR40TQT7/V 5yppdYlpv3eWQut0pgSUS19+d0zlLgr/xWEgnJWSREeoteqae9wbhQj0tjb/w/S8kP75vM bMwmT0WYEdaqlxMXrFzgYjfbt2Mq/fw= 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-129-NivpEGWfOKW2rqXDN2Iarw-1; Wed, 27 Oct 2021 11:18:33 -0400 X-MC-Unique: NivpEGWfOKW2rqXDN2Iarw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 090521023F57; Wed, 27 Oct 2021 15:18:26 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37C0260C48; Wed, 27 Oct 2021 15:18:14 +0000 (UTC) Message-ID: <796f9a7d553a0e13da5c44597666962620c64303.camel@redhat.com> Subject: Re: [PATCH v2 18/43] KVM: x86: Invoke kvm_vcpu_block() directly for non-HALTED wait states 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 18:18:13 +0300 In-Reply-To: <20211009021236.4122790-19-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-19-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.14 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211027_081838_099099_531FE45F X-CRM114-Status: GOOD ( 21.07 ) 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:12 -0700, Sean Christopherson wrote: > Call kvm_vcpu_block() directly for all wait states except HALTED so that > kvm_vcpu_halt() is no longer a misnomer on x86. > > Functionally, this means KVM will never attempt halt-polling or adjust > vcpu->halt_poll_ns for INIT_RECEIVED (a.k.a. Wait-For-SIPI (WFS)) or > AP_RESET_HOLD; UNINITIALIZED is handled in kvm_arch_vcpu_ioctl_run(), > and x86 doesn't use any other "wait" states. > > As mentioned above, the motivation of this is purely so that "halt" isn't > overloaded on x86, e.g. in KVM's stats. Skipping halt-polling for WFS > (and RESET_HOLD) has no meaningful effect on guest performance as there > are typically single-digit numbers of INIT-SIPI sequences per AP vCPU, > per boot, versus thousands of HLTs just to boot to console. > > Reviewed-by: David Matlack > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/x86.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index cd51f100e906..e0219acfd9cf 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9899,7 +9899,10 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu) > if (!kvm_arch_vcpu_runnable(vcpu) && > (!kvm_x86_ops.pre_block || static_call(kvm_x86_pre_block)(vcpu) == 0)) { > srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); > - kvm_vcpu_halt(vcpu); > + if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) > + kvm_vcpu_halt(vcpu); > + else > + kvm_vcpu_block(vcpu); > vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); > > if (kvm_x86_ops.post_block) 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 66B67C433FE for ; Wed, 27 Oct 2021 16:50:07 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 09176610A3 for ; Wed, 27 Oct 2021 16:50:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 09176610A3 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 B09964B183; Wed, 27 Oct 2021 12:50:06 -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 7Agi5xu2orDZ; Wed, 27 Oct 2021 12:50:05 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 74E994B1D2; Wed, 27 Oct 2021 12:49:58 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BD5CB4B159 for ; Wed, 27 Oct 2021 11:18:36 -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 TG2DuxBu1Lau for ; Wed, 27 Oct 2021 11:18:35 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 379F64B136 for ; Wed, 27 Oct 2021 11:18:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635347915; 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=Mqfkyc1h1IacAYuqVX+51EaEIUB4H7XAD3a00wXW0uo=; b=SntEYb0jgUUY4gljWgTTZDnsfXPpVWtXaLl+3M9lXaew6h4Rv1PM9NAW4a9inCqfDLuhHw loZn7TBlRAIHsO++GEw4i1C4/2F9a6bbpgVpCatC45pwfeLiwBqem6/Drdes8i8XBos0sA f6QEWq+7JGHX9Y7pGhgAKkB6jwCyAL0= 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-129-NivpEGWfOKW2rqXDN2Iarw-1; Wed, 27 Oct 2021 11:18:33 -0400 X-MC-Unique: NivpEGWfOKW2rqXDN2Iarw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 090521023F57; Wed, 27 Oct 2021 15:18:26 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37C0260C48; Wed, 27 Oct 2021 15:18:14 +0000 (UTC) Message-ID: <796f9a7d553a0e13da5c44597666962620c64303.camel@redhat.com> Subject: Re: [PATCH v2 18/43] KVM: x86: Invoke kvm_vcpu_block() directly for non-HALTED wait states 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 18:18:13 +0300 In-Reply-To: <20211009021236.4122790-19-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-19-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.14 X-Mailman-Approved-At: Wed, 27 Oct 2021 12:49:56 -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:12 -0700, Sean Christopherson wrote: > Call kvm_vcpu_block() directly for all wait states except HALTED so that > kvm_vcpu_halt() is no longer a misnomer on x86. > > Functionally, this means KVM will never attempt halt-polling or adjust > vcpu->halt_poll_ns for INIT_RECEIVED (a.k.a. Wait-For-SIPI (WFS)) or > AP_RESET_HOLD; UNINITIALIZED is handled in kvm_arch_vcpu_ioctl_run(), > and x86 doesn't use any other "wait" states. > > As mentioned above, the motivation of this is purely so that "halt" isn't > overloaded on x86, e.g. in KVM's stats. Skipping halt-polling for WFS > (and RESET_HOLD) has no meaningful effect on guest performance as there > are typically single-digit numbers of INIT-SIPI sequences per AP vCPU, > per boot, versus thousands of HLTs just to boot to console. > > Reviewed-by: David Matlack > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/x86.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index cd51f100e906..e0219acfd9cf 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9899,7 +9899,10 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu) > if (!kvm_arch_vcpu_runnable(vcpu) && > (!kvm_x86_ops.pre_block || static_call(kvm_x86_pre_block)(vcpu) == 0)) { > srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); > - kvm_vcpu_halt(vcpu); > + if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) > + kvm_vcpu_halt(vcpu); > + else > + kvm_vcpu_block(vcpu); > vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); > > if (kvm_x86_ops.post_block) 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 15:18:13 +0000 Subject: Re: [PATCH v2 18/43] KVM: x86: Invoke kvm_vcpu_block() directly for non-HALTED wait states Message-Id: <796f9a7d553a0e13da5c44597666962620c64303.camel@redhat.com> List-Id: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-19-seanjc@google.com> In-Reply-To: <20211009021236.4122790-19-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:12 -0700, Sean Christopherson wrote: > Call kvm_vcpu_block() directly for all wait states except HALTED so that > kvm_vcpu_halt() is no longer a misnomer on x86. > > Functionally, this means KVM will never attempt halt-polling or adjust > vcpu->halt_poll_ns for INIT_RECEIVED (a.k.a. Wait-For-SIPI (WFS)) or > AP_RESET_HOLD; UNINITIALIZED is handled in kvm_arch_vcpu_ioctl_run(), > and x86 doesn't use any other "wait" states. > > As mentioned above, the motivation of this is purely so that "halt" isn't > overloaded on x86, e.g. in KVM's stats. Skipping halt-polling for WFS > (and RESET_HOLD) has no meaningful effect on guest performance as there > are typically single-digit numbers of INIT-SIPI sequences per AP vCPU, > per boot, versus thousands of HLTs just to boot to console. > > Reviewed-by: David Matlack > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/x86.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index cd51f100e906..e0219acfd9cf 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9899,7 +9899,10 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu) > if (!kvm_arch_vcpu_runnable(vcpu) && > (!kvm_x86_ops.pre_block || static_call(kvm_x86_pre_block)(vcpu) = 0)) { > srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); > - kvm_vcpu_halt(vcpu); > + if (vcpu->arch.mp_state = KVM_MP_STATE_HALTED) > + kvm_vcpu_halt(vcpu); > + else > + kvm_vcpu_block(vcpu); > vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); > > if (kvm_x86_ops.post_block) Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky