Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1079203ybg; Wed, 29 Jul 2020 05:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1SBHBzzfmOI6qD+s4adEX0RNwmmnhW8cBAeRdzS0LbQwl7FgCu6Co/f5/95P9dgAbSReo X-Received: by 2002:a17:906:1d5b:: with SMTP id o27mr32204196ejh.367.1596025427645; Wed, 29 Jul 2020 05:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596025427; cv=none; d=google.com; s=arc-20160816; b=pJzbcmQ2NxRxP4QeqUpASKsQKDY8Gt4s5LweNWCLmm1RxnsJuOcEHBElp4aqGhHyd7 j7o1ZNnDYz2TS/Z/xf+TcZ4i047N31dnrLQZ+bq4fbxxdRD6uHI6mxaWhk8cRFNNL3ME hA6TBPyV0BunESekDYHGEtavSeVwemXMvLQuEfAsdrT3Vwtd9TMGgX9ewr3YcPszD9eM FPDjMOJ7OjXwoNbNdEz9bpXoqmxVi++WU2BxjXaxewwA2DwEmHBKYqHq9f208qW0R35z 2iSTmTiQTpmFtFoukVqostQKEUSB7S/c9BJ7KcSDV6a50JN8PvqEDqoeMY6ddBQ6oKZI 2oyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=d6W1T974VZvK5aHdyDKfm8iT0P3+yUruO/0hQztff7w=; b=ULp0Qj0uaDqHp9UWUpfuhvrQRUVg4sXUg35fDG6IyH9RNohGaJewYCLQ7t9P6g8x5J yFKbSrmtqKucKTTUTZCnSsCZKadqMA73griZIYIfKiftFyySIBL9w2h6jhHCrSZnkQFy rzd8/GWmZpVsjyccks6Sj/nyiP8LBty2WS/G/rJ0rkhhIRuLJoWL51BrHNAaxNEkpxa2 RTjDvXVXQHRJyYL2aFqqJgGZZS33Jt3HNdi/Gx8A65BFisMbPH3gFoVuO7hLnu1hkAv4 nkxUttXuTwebTuss/5T2yd9XEzzEKuTGKz1VIkekkLOhsNx2FiNxBYnN2u340gw1o5Mx IOnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OULqUF8W; 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 dc15si964505ejb.374.2020.07.29.05.23.25; Wed, 29 Jul 2020 05:23:47 -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=OULqUF8W; 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 S1726847AbgG2MVC (ORCPT + 99 others); Wed, 29 Jul 2020 08:21:02 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:36272 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgG2MVB (ORCPT ); Wed, 29 Jul 2020 08:21:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596025260; 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: in-reply-to:in-reply-to:references:references; bh=d6W1T974VZvK5aHdyDKfm8iT0P3+yUruO/0hQztff7w=; b=OULqUF8WQ+jBXyTFiyqDCBvQPyHTde9J5Lk6aOUxznUqwGmfyDJkRPu5c//BgneRKkAaYZ pHk0QTrPZyBHi03s10yLnaGdSMvmarIY8Ko8ZmfpbCyvotZm80ey8MfBiMYf/GLBHcXbzS t/r9+VNUlQWdf6BNQeKRqQaSvEhk9c0= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-511-8j5gBKxlMPWwXEr-4k2bSw-1; Wed, 29 Jul 2020 08:20:58 -0400 X-MC-Unique: 8j5gBKxlMPWwXEr-4k2bSw-1 Received: by mail-ed1-f71.google.com with SMTP id i3so8259672edq.21 for ; Wed, 29 Jul 2020 05:20:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=d6W1T974VZvK5aHdyDKfm8iT0P3+yUruO/0hQztff7w=; b=aMUnYURapv8RGHJV02mgwgcXyje8G0tGabVIu2oBrOzXSkbP/tG3jbjdRZlBKhuFFX UGcejQ5mMkl+fDq8pJjgBiuB0lVVoDYxg4G9vo+qy68XTMsY4F93+0dxJV4zIQPDoWAN 3FPHnQs2dqlYa1F+XumSMhCUqJ1WGM5fUB+B/kF7CpVlRIxfG7B3ft95nuEwC1iCYmOi 5ffDDfQMufjrznJh0NlJ/tjdvrj7zsbxXMQHcY+5Oh44knMFB1ulbc4YQnu4DmeZ7a7H +20yWXQx7TEojJFe6oSXSxf9fORo3ZC990xeUnjY5lsOS7uL0jgf6HD6DlvxdJzgw7mi HIeQ== X-Gm-Message-State: AOAM532QHt5fz4vwVXwE5Nbp37xZl8oU/FDr6HEyOktba3TApFtiAqMs rijO33rePssQB/vztkX4opF8oquVj1efvLYEiT0Yy+paj6FJc8cukox4I467kmcB1DTc3DjPLgJ 4DoDKGHXRd03FaRJIHRkCpyUC X-Received: by 2002:a05:6402:2031:: with SMTP id ay17mr4496494edb.46.1596025257246; Wed, 29 Jul 2020 05:20:57 -0700 (PDT) X-Received: by 2002:a05:6402:2031:: with SMTP id ay17mr4496471edb.46.1596025257037; Wed, 29 Jul 2020 05:20:57 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id o7sm1655137edq.53.2020.07.29.05.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 05:20:56 -0700 (PDT) From: Vitaly Kuznetsov To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Wanpeng Li , Jim Mattson , Joerg Roedel Subject: Re: [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM In-Reply-To: <1595929506-9203-3-git-send-email-wanpengli@tencent.com> References: <1595929506-9203-1-git-send-email-wanpengli@tencent.com> <1595929506-9203-3-git-send-email-wanpengli@tencent.com> Date: Wed, 29 Jul 2020 14:20:54 +0200 Message-ID: <87k0ymldg9.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wanpeng Li writes: > From: Wanpeng Li > > Commit 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM) drops > disable pause loop exit/pause filtering capability completely, I guess it > is a merge fault by Radim since disable vmexits capabilities and pause > loop exit for SVM patchsets are merged at the same time. This patch > reintroduces the disable pause loop exit/pause filtering capability > support. > > We can observe 2.9% hackbench improvement for a 92 vCPUs guest on AMD > Rome Server. > > Reported-by: Haiwei Li > Tested-by: Haiwei Li > Fixes: 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM) > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/svm/svm.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index c0da4dd..c20f127 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -1090,7 +1090,7 @@ static void init_vmcb(struct vcpu_svm *svm) > svm->nested.vmcb = 0; > svm->vcpu.arch.hflags = 0; > > - if (pause_filter_count) { > + if (pause_filter_count && !kvm_pause_in_guest(svm->vcpu.kvm)) { > control->pause_filter_count = pause_filter_count; > if (pause_filter_thresh) > control->pause_filter_thresh = pause_filter_thresh; > @@ -2693,7 +2693,7 @@ static int pause_interception(struct vcpu_svm *svm) > struct kvm_vcpu *vcpu = &svm->vcpu; > bool in_kernel = (svm_get_cpl(vcpu) == 0); > > - if (pause_filter_thresh) > + if (!kvm_pause_in_guest(vcpu->kvm)) > grow_ple_window(vcpu); > > kvm_vcpu_on_spin(vcpu, in_kernel); > @@ -3780,7 +3780,7 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu) > > static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu) > { > - if (pause_filter_thresh) > + if (!kvm_pause_in_guest(vcpu->kvm)) > shrink_ple_window(vcpu); > } > > @@ -3958,6 +3958,9 @@ static void svm_vm_destroy(struct kvm *kvm) > > static int svm_vm_init(struct kvm *kvm) > { > + if (!pause_filter_thresh) > + kvm->arch.pause_in_guest = true; Would it make sense to do if (!pause_filter_count || !pause_filter_thresh) kvm->arch.pause_in_guest = true; here and simplify the condition in init_vmcb()? > + > if (avic) { > int ret = avic_vm_init(kvm); > if (ret) -- Vitaly