From patchwork Fri Sep 6 02:17:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11134255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2EF71398 for ; Fri, 6 Sep 2019 02:17:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0A7120870 for ; Fri, 6 Sep 2019 02:17:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404340AbfIFCRi (ORCPT ); Thu, 5 Sep 2019 22:17:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50996 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728507AbfIFCRg (ORCPT ); Thu, 5 Sep 2019 22:17:36 -0400 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C63F0806A2 for ; Fri, 6 Sep 2019 02:17:36 +0000 (UTC) Received: by mail-pf1-f199.google.com with SMTP id w126so2080960pfd.22 for ; Thu, 05 Sep 2019 19:17:36 -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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PI0dvyELfgDR6EZuTiL1mpi7X9aW26KSG8PfN04SbrI=; b=oN0NHEgxCElw0qORey0AzjgBHphZBkwdVms0p0rKcOHc8FcUwHToFdNK9joGSEY3cd bhG3Q764w1fjpyaz/XSGKOqlB8aQhCBlJNP1Nyh/7aRZ3cXtuncU9Z5d9b2WBtRnnMRL A9VWRhaZrtf2UOXXd2xpXDcrg0A+GAyqN/ljSObzI7wkyxvD90h3PLoFaUCftwPWZyXH CDKSiEvtUirpnGjLg/J7aExwUngjJv5eejYfaOAmrA1ccelu5UXgsujgYamfPAMXBoJP ZPTM54X4VbGEiOpOxrgylm9GGQJUM+se4fSvWstow1oosDIuSCpeQAgCxOOEcueqRCnt xIIA== X-Gm-Message-State: APjAAAVwm2fWgjD72/no5vpLnLSpaFbSg5YACJo3HdEySWGucrHPdPYB 3Pj5yLhB34PQkxWTSwh6T3U35q5VLCjf1zNr2WK4Z2ExxoJpeI5cOXgZA1A/R72tltW9LL4VZjK O6pm3mmDc8pEX X-Received: by 2002:a17:902:a507:: with SMTP id s7mr6835202plq.66.1567736256237; Thu, 05 Sep 2019 19:17:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHNmYW/Tb/4gB158GISbxVxqvjGZfcetpu67IukX/XY4cAL70pd1u6vIEnBjmgKmkvmFrjng== X-Received: by 2002:a17:902:a507:: with SMTP id s7mr6835191plq.66.1567736256066; Thu, 05 Sep 2019 19:17:36 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id a11sm8212359pfg.94.2019.09.05.19.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 19:17:35 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , Wanpeng Li , Krish Sadhukhan , peterx@redhat.com Subject: [PATCH v4 1/4] KVM: X86: Trace vcpu_id for vmexit Date: Fri, 6 Sep 2019 10:17:19 +0800 Message-Id: <20190906021722.2095-2-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906021722.2095-1-peterx@redhat.com> References: <20190906021722.2095-1-peterx@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Tracing the ID helps to pair vmenters and vmexits for guests with multiple vCPUs. Reviewed-by: Krish Sadhukhan Reviewed-by: Sean Christopherson Signed-off-by: Peter Xu --- arch/x86/kvm/trace.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index b5c831e79094..20d6cac9f157 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -232,17 +232,20 @@ TRACE_EVENT(kvm_exit, __field( u32, isa ) __field( u64, info1 ) __field( u64, info2 ) + __field( unsigned int, vcpu_id ) ), TP_fast_assign( __entry->exit_reason = exit_reason; __entry->guest_rip = kvm_rip_read(vcpu); __entry->isa = isa; + __entry->vcpu_id = vcpu->vcpu_id; kvm_x86_ops->get_exit_info(vcpu, &__entry->info1, &__entry->info2); ), - TP_printk("reason %s rip 0x%lx info %llx %llx", + TP_printk("vcpu %u reason %s rip 0x%lx info %llx %llx", + __entry->vcpu_id, (__entry->isa == KVM_ISA_VMX) ? __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) : __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS), From patchwork Fri Sep 6 02:17:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11134253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CB741593 for ; Fri, 6 Sep 2019 02:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A8A32145D for ; Fri, 6 Sep 2019 02:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404361AbfIFCRn (ORCPT ); Thu, 5 Sep 2019 22:17:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44422 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404345AbfIFCRj (ORCPT ); Thu, 5 Sep 2019 22:17:39 -0400 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEA1BC0578C9 for ; Fri, 6 Sep 2019 02:17:39 +0000 (UTC) Received: by mail-pl1-f198.google.com with SMTP id y18so2622967plr.20 for ; Thu, 05 Sep 2019 19:17:39 -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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U9X2ocg4xLLzJVV8u6FR7s0StrvzfFTOD0TsbOAZvYI=; b=uUEP8/4SKrFUF1FzogdpRQ8yjWtU/rUppVF6jcjwkMXCY6j10Z5Yo3gmF9AJLSEd8i Ti2pS9YwByzuRw7I5zasfT2TdnNgu31SiopOEexbiEUZgEfMknP7+y4RhS2AaY/M7L2d CUAU/ZGUQwD9fa0DynMAOCzHVXqFpVwKvV3rB9RNJLc0scIS4ibXozQT/9Ow/NeaIQRN VhNKo3zqLFHfj6nX8xZ/OReRfiCQrMK1znfIo6Vb7MgPpdgyfjpifwD4VItrWztqBGOg CX0mPqKjgckjTixznAYlFQhFxBO2WA8OJjsAySKCqNg/yQ+JUAYLwKpT+uPHl1gVrflf Ea4g== X-Gm-Message-State: APjAAAU1AcPvT7WqF7UVD+lncKFtPq3zUTQjiBk9rtW9/t9Z4NBFD2pi YXPZTrQLjyTLnSS29VRcYpEsGtCepMG4dxo9s5G30jgoiPYwrq0XfIJUgKWKgtvGC1IwDIn2lmP VFiUl29H4swPA X-Received: by 2002:a17:902:e584:: with SMTP id cl4mr6712910plb.160.1567736259393; Thu, 05 Sep 2019 19:17:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzA7XI63VxKtVoT9lqWgBy/9HesvkQuEH5lLydx5b5gBH692ZTbf+VCfENgHvilhjZtCmHvMQ== X-Received: by 2002:a17:902:e584:: with SMTP id cl4mr6712905plb.160.1567736259246; Thu, 05 Sep 2019 19:17:39 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id a11sm8212359pfg.94.2019.09.05.19.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 19:17:38 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , Wanpeng Li , Krish Sadhukhan , peterx@redhat.com Subject: [PATCH v4 2/4] KVM: X86: Remove tailing newline for tracepoints Date: Fri, 6 Sep 2019 10:17:20 +0800 Message-Id: <20190906021722.2095-3-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906021722.2095-1-peterx@redhat.com> References: <20190906021722.2095-1-peterx@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It's done by TP_printk() already. Reviewed-by: Krish Sadhukhan Reviewed-by: Sean Christopherson Signed-off-by: Peter Xu --- arch/x86/kvm/trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 20d6cac9f157..8a7570f8c943 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -1323,7 +1323,7 @@ TRACE_EVENT(kvm_avic_incomplete_ipi, __entry->index = index; ), - TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u\n", + TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u", __entry->vcpu, __entry->icrh, __entry->icrl, __entry->id, __entry->index) ); @@ -1348,7 +1348,7 @@ TRACE_EVENT(kvm_avic_unaccelerated_access, __entry->vec = vec; ), - TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x\n", + TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x", __entry->vcpu, __entry->offset, __print_symbolic(__entry->offset, kvm_trace_symbol_apic), From patchwork Fri Sep 6 02:17:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11134251 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AECE1593 for ; Fri, 6 Sep 2019 02:17:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46C5A2082C for ; Fri, 6 Sep 2019 02:17:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404372AbfIFCRp (ORCPT ); Thu, 5 Sep 2019 22:17:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53008 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404363AbfIFCRo (ORCPT ); Thu, 5 Sep 2019 22:17:44 -0400 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A54158535C for ; Fri, 6 Sep 2019 02:17:43 +0000 (UTC) Received: by mail-pf1-f199.google.com with SMTP id r17so3349202pfr.19 for ; Thu, 05 Sep 2019 19:17:43 -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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kaVd3OQltvocaICCaNdt1dKy4a2qSML25Bhj/yWBYnU=; b=j51jBw1iElK6q3maPzLQ3ZRZ9mRVL+02TqPItPL0qRpUAlS6Gi/yaypHVtrvFp9ph1 Biq7L1j1YdELd3YV5D/5wK8UkMaAWsA03vbXi8y1XgUAeOrLVTj2mrf0LjVqEyg8d+ij YrP2AOdy39TQf2+LiWFLXvxQ/IrfLwDWDYg1UlSAPNp0hYZ2ZBEa2niuf4Bi5j8rUEwf oFZodurl55/6mVCDqsdELpHD59lSiHm9OrfU4l0lj02hfs8wo74BxLrAvvCz+sT0UsyC Ovcl5BoLfuLOlqsDys/aHwdgvnMSljpDUwpHMoqEstCrGirRZ/PUUu1oQtqG3xy2r3ao ROlw== X-Gm-Message-State: APjAAAUVAqfvBPlvr8v+eQiY6DFzlHF+V1JzWObDdzpSuWzfOH4XzAjG g3seEsDdesHXwLm7sS41d/MTUXralFqHSod9d8la6hHY/aa1joDQzglLJ2UPJkbOFT7iEkkJprw EPPXd+MWCrX4r X-Received: by 2002:a63:c70d:: with SMTP id n13mr5894831pgg.171.1567736262657; Thu, 05 Sep 2019 19:17:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7tCMCiTYtonlv5aU6ntwW21CQCMXwSpkGQ7RtzncHXfkgelMohyB6SmVihEwweFhDyPJ17g== X-Received: by 2002:a63:c70d:: with SMTP id n13mr5894815pgg.171.1567736262401; Thu, 05 Sep 2019 19:17:42 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id a11sm8212359pfg.94.2019.09.05.19.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 19:17:41 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , Wanpeng Li , Krish Sadhukhan , peterx@redhat.com Subject: [PATCH v4 3/4] KVM: VMX: Change ple_window type to unsigned int Date: Fri, 6 Sep 2019 10:17:21 +0800 Message-Id: <20190906021722.2095-4-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906021722.2095-1-peterx@redhat.com> References: <20190906021722.2095-1-peterx@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The VMX ple_window is 32 bits wide, so logically it can overflow with an int. The module parameter is declared as unsigned int which is good, however the dynamic variable is not. Switching all the ple_window references to use unsigned int. The tracepoint changes will also affect SVM, but SVM is using an even smaller width (16 bits) so it's always fine. Suggested-by: Sean Christopherson Signed-off-by: Peter Xu Reviewed-by: Sean Christopherson --- arch/x86/kvm/trace.h | 9 +++++---- arch/x86/kvm/vmx/vmx.c | 4 ++-- arch/x86/kvm/vmx/vmx.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 8a7570f8c943..afe8d269c16c 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -891,14 +891,15 @@ TRACE_EVENT(kvm_pml_full, ); TRACE_EVENT(kvm_ple_window, - TP_PROTO(bool grow, unsigned int vcpu_id, int new, int old), + TP_PROTO(bool grow, unsigned int vcpu_id, unsigned int new, + unsigned int old), TP_ARGS(grow, vcpu_id, new, old), TP_STRUCT__entry( __field( bool, grow ) __field( unsigned int, vcpu_id ) - __field( int, new ) - __field( int, old ) + __field( unsigned int, new ) + __field( unsigned int, old ) ), TP_fast_assign( @@ -908,7 +909,7 @@ TRACE_EVENT(kvm_ple_window, __entry->old = old; ), - TP_printk("vcpu %u: ple_window %d (%s %d)", + TP_printk("vcpu %u: ple_window %u (%s %u)", __entry->vcpu_id, __entry->new, __entry->grow ? "grow" : "shrink", diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 42ed3faa6af8..b172b675d420 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5227,7 +5227,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu) static void grow_ple_window(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); - int old = vmx->ple_window; + unsigned int old = vmx->ple_window; vmx->ple_window = __grow_ple_window(old, ple_window, ple_window_grow, @@ -5242,7 +5242,7 @@ static void grow_ple_window(struct kvm_vcpu *vcpu) static void shrink_ple_window(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); - int old = vmx->ple_window; + unsigned int old = vmx->ple_window; vmx->ple_window = __shrink_ple_window(old, ple_window, ple_window_shrink, diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index 82d0bc3a4d52..64d5a4890aa9 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -253,7 +253,7 @@ struct vcpu_vmx { struct nested_vmx nested; /* Dynamic PLE window. */ - int ple_window; + unsigned int ple_window; bool ple_window_dirty; bool req_immediate_exit; From patchwork Fri Sep 6 02:17:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11134249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDDB21398 for ; Fri, 6 Sep 2019 02:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D18D02082E for ; Fri, 6 Sep 2019 02:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404384AbfIFCRr (ORCPT ); Thu, 5 Sep 2019 22:17:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54246 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404380AbfIFCRr (ORCPT ); Thu, 5 Sep 2019 22:17:47 -0400 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD52E2A09D2 for ; Fri, 6 Sep 2019 02:17:46 +0000 (UTC) Received: by mail-pl1-f199.google.com with SMTP id d11so2645570plo.6 for ; Thu, 05 Sep 2019 19:17:46 -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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HBNEjbH++Cplr+hlTTIn2gJ2guzKt/zMnh4i7J+yi14=; b=aQcbHZrVPW89iTlIYpeV6LKgwiAsdVPtlOcVUpvVt4aD/GyMNQanz1rYL86Ekgo3pi 5YC3Tr1G5QNsvYRPE06sTstiBWljMhFX/OblWR2ACQw4fRNiTZ0qnFKoppaBTV/XBEeG 6859xab+bklTcUFS+bDnEBvjsKgt+Pi5IbNwYBpanlVSUbNECLs13Gc3KlbMpvYpxNNc TgPO6PAJEVC6v2RV4fhupwAfT7pOxYI9/5vocrKCIpil8khchKMIplzPRYqZj1cuMDAM 3StcEC5N9qZs8pta6sr+K+DA2eQ2PqheOAdV0QjVcg0lbxLEj2ILCgQmJZ8wKmnYxqUh o3GQ== X-Gm-Message-State: APjAAAUqIJWb6Hfu8wS7RGjsfcVWnrzCSStirfKRdSS/L0saqwzsBKX2 fCkCOE8Ec4+Gz6jeD4gxl5bkykUvo47gzpOZgb1eQ+6fmBHrlAUiksHwH6uM3N4dktG/kUsX+yt ePJ8Q5AOxMi0d X-Received: by 2002:a63:2043:: with SMTP id r3mr5988064pgm.311.1567736266117; Thu, 05 Sep 2019 19:17:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUec44Alg2d7GbiXyFGAxolQO9nJYnvLN4s2Tf/cBHafByYGpQiuLIicL/1aLfJIR/cNmAwQ== X-Received: by 2002:a63:2043:: with SMTP id r3mr5988045pgm.311.1567736265811; Thu, 05 Sep 2019 19:17:45 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id a11sm8212359pfg.94.2019.09.05.19.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 19:17:45 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , Wanpeng Li , Krish Sadhukhan , peterx@redhat.com Subject: [PATCH v4 4/4] KVM: X86: Tune PLE Window tracepoint Date: Fri, 6 Sep 2019 10:17:22 +0800 Message-Id: <20190906021722.2095-5-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906021722.2095-1-peterx@redhat.com> References: <20190906021722.2095-1-peterx@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The PLE window tracepoint triggers even if the window is not changed, and the wording can be a bit confusing too. One example line: kvm_ple_window: vcpu 0: ple_window 4096 (shrink 4096) It easily let people think of "the window now is 4096 which is shrinked", but the truth is the value actually didn't change (4096). Let's only dump this message if the value really changed, and we make the message even simpler like: kvm_ple_window: vcpu 4 old 4096 new 8192 (growed) Signed-off-by: Peter Xu Reviewed-by: Sean Christopherson --- arch/x86/kvm/svm.c | 16 ++++++++-------- arch/x86/kvm/trace.h | 22 ++++++---------------- arch/x86/kvm/vmx/vmx.c | 14 ++++++++------ arch/x86/kvm/x86.c | 2 +- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index d685491fce4d..d5cb6b5a9254 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1269,11 +1269,11 @@ static void grow_ple_window(struct kvm_vcpu *vcpu) pause_filter_count_grow, pause_filter_count_max); - if (control->pause_filter_count != old) + if (control->pause_filter_count != old) { mark_dirty(svm->vmcb, VMCB_INTERCEPTS); - - trace_kvm_ple_window_grow(vcpu->vcpu_id, - control->pause_filter_count, old); + trace_kvm_ple_window_update(vcpu->vcpu_id, + control->pause_filter_count, old); + } } static void shrink_ple_window(struct kvm_vcpu *vcpu) @@ -1287,11 +1287,11 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu) pause_filter_count, pause_filter_count_shrink, pause_filter_count); - if (control->pause_filter_count != old) + if (control->pause_filter_count != old) { mark_dirty(svm->vmcb, VMCB_INTERCEPTS); - - trace_kvm_ple_window_shrink(vcpu->vcpu_id, - control->pause_filter_count, old); + trace_kvm_ple_window_update(vcpu->vcpu_id, + control->pause_filter_count, old); + } } static __init int svm_hardware_setup(void) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index afe8d269c16c..ae924566c401 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -890,37 +890,27 @@ TRACE_EVENT(kvm_pml_full, TP_printk("vcpu %d: PML full", __entry->vcpu_id) ); -TRACE_EVENT(kvm_ple_window, - TP_PROTO(bool grow, unsigned int vcpu_id, unsigned int new, - unsigned int old), - TP_ARGS(grow, vcpu_id, new, old), +TRACE_EVENT(kvm_ple_window_update, + TP_PROTO(unsigned int vcpu_id, unsigned int new, unsigned int old), + TP_ARGS(vcpu_id, new, old), TP_STRUCT__entry( - __field( bool, grow ) __field( unsigned int, vcpu_id ) __field( unsigned int, new ) __field( unsigned int, old ) ), TP_fast_assign( - __entry->grow = grow; __entry->vcpu_id = vcpu_id; __entry->new = new; __entry->old = old; ), - TP_printk("vcpu %u: ple_window %u (%s %u)", - __entry->vcpu_id, - __entry->new, - __entry->grow ? "grow" : "shrink", - __entry->old) + TP_printk("vcpu %u old %u new %u (%s)", + __entry->vcpu_id, __entry->old, __entry->new, + __entry->old < __entry->new ? "growed" : "shrinked") ); -#define trace_kvm_ple_window_grow(vcpu_id, new, old) \ - trace_kvm_ple_window(true, vcpu_id, new, old) -#define trace_kvm_ple_window_shrink(vcpu_id, new, old) \ - trace_kvm_ple_window(false, vcpu_id, new, old) - TRACE_EVENT(kvm_pvclock_update, TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock), TP_ARGS(vcpu_id, pvclock), diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index b172b675d420..1dbb63ffdd6d 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5233,10 +5233,11 @@ static void grow_ple_window(struct kvm_vcpu *vcpu) ple_window_grow, ple_window_max); - if (vmx->ple_window != old) + if (vmx->ple_window != old) { vmx->ple_window_dirty = true; - - trace_kvm_ple_window_grow(vcpu->vcpu_id, vmx->ple_window, old); + trace_kvm_ple_window_update(vcpu->vcpu_id, + vmx->ple_window, old); + } } static void shrink_ple_window(struct kvm_vcpu *vcpu) @@ -5248,10 +5249,11 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu) ple_window_shrink, ple_window); - if (vmx->ple_window != old) + if (vmx->ple_window != old) { vmx->ple_window_dirty = true; - - trace_kvm_ple_window_shrink(vcpu->vcpu_id, vmx->ple_window, old); + trace_kvm_ple_window_update(vcpu->vcpu_id, + vmx->ple_window, old); + } } /* diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 93b0bd45ac73..69ad184edc90 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10082,7 +10082,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_invlpga); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_skinit); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_nested_intercepts); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_write_tsc_offset); -EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_ple_window); +EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_ple_window_update); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_pml_full); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_pi_irte_update); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_avic_unaccelerated_access);