From patchwork Thu Aug 15 10:34:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11095525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41F1D6C5 for ; Thu, 15 Aug 2019 10:35:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31E1228789 for ; Thu, 15 Aug 2019 10:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2550B287A6; Thu, 15 Aug 2019 10:35:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAC6528789 for ; Thu, 15 Aug 2019 10:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730986AbfHOKfP (ORCPT ); Thu, 15 Aug 2019 06:35:15 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33516 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729838AbfHOKfO (ORCPT ); Thu, 15 Aug 2019 06:35:14 -0400 Received: by mail-pf1-f193.google.com with SMTP id g2so1172828pfq.0 for ; Thu, 15 Aug 2019 03:35:14 -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=MmetD9yuNOrneVgW+Ws3yNNgT+hSrMad8QH4+681/0w=; b=C84PiUf6eL2l7BUNLvibKFhvbnoldzZ5aNfJqXwMRkmNxGFObdgoeTJ0DfWd/oBxx0 xI/GNTgMgDywf/vlSVG9gWX9Vw8HSD3wkvNRYf32NBJaAvd2nKB8UlzxT3l+TMYHTnyC jucynL1cOnTIOwos9ZQ3V2Ct50Ef01kqvlsV0AMlV1/Wo8UYqLgPML4GDhIVcWAlmfol XAogCgc/cmdcJSikXUrKnWad5lhSFqs7MLBMSAg5O/B+ATXjd/8h8W17PFz5exO/N8iA PxhqYvYYPAXka7TTrt+6Y76n7oy1wThy9GMUOu1fxwu4mxSLj6BLBc4YO44zd6RbTGPo zldQ== X-Gm-Message-State: APjAAAXkD2jgRQhygxb6SkA1ZS4AlE339Ly11uTgkqwGJA5qtkZSzcBe qi4zmeYMXoSW9qJblksU+Eojh/p5YcSrcQ== X-Google-Smtp-Source: APXvYqxKKF0KfKHwNQj3s+wlVd2MyW5RDnuq7+O3uAwel68MJtSEcu2G+KFYOLwfS91JP2EQjeV2Dg== X-Received: by 2002:aa7:9903:: with SMTP id z3mr4536091pff.200.1565865313856; Thu, 15 Aug 2019 03:35:13 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id o128sm2481066pfb.42.2019.08.15.03.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2019 03:35:13 -0700 (PDT) From: Peter Xu To: kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , Wanpeng Li , Krish Sadhukhan , peterx@redhat.com Subject: [PATCH v2 1/3] KVM: X86: Trace vcpu_id for vmexit Date: Thu, 15 Aug 2019 18:34:56 +0800 Message-Id: <20190815103458.23207-2-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190815103458.23207-1-peterx@redhat.com> References: <20190815103458.23207-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 X-Virus-Scanned: ClamAV using ClamSMTP Tracing the ID helps to pair vmenters and vmexits for guests with multiple vCPUs. Reviewed-by: Krish Sadhukhan 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..c682f3f7f998 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( 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 %d 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 Thu Aug 15 10:34:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11095527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4591B1399 for ; Thu, 15 Aug 2019 10:35:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33D9728789 for ; Thu, 15 Aug 2019 10:35:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27D48287A6; Thu, 15 Aug 2019 10:35:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9CE928789 for ; Thu, 15 Aug 2019 10:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731023AbfHOKfT (ORCPT ); Thu, 15 Aug 2019 06:35:19 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46579 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730938AbfHOKfS (ORCPT ); Thu, 15 Aug 2019 06:35:18 -0400 Received: by mail-pg1-f196.google.com with SMTP id m3so538354pgv.13 for ; Thu, 15 Aug 2019 03:35:18 -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=zChKo2Uz5JQYeXc3YwPovpGzjABj57VUJELuv2bvYYs=; b=OnvXxyqveBg/8YODNcQkj4BZbMyK/5mjfVEb+poRSrFyF6/TPM+usX1J7N+Vr9/97O F9gnwJl2dgjYgnNFiBRMMkIASzoB8Y/MqYV6X60Rk1l8zmeAXrtIEODCjpnhSJfk+Cmg 2e007yhfFB4v9oFLUHm2j6ZM9n8BmIJhvU5dsbH8f0jevrNUgdXUSOVhoAbb7wFYhGo7 wPi2ctpxNmdBrY8YXNyDfeGmeGU5yFqHHPenWcfa86vaUFi7w3JkJzuuKGYf54Ua6wqX 8kgDbtOa+THdFsW8D8/Ev8ATIaAEoHJRPj0HKa4/qMhQfuDRHv3ySkQnzwq01lXu9+Ym FeMw== X-Gm-Message-State: APjAAAXnW7MVVAtlDK/OY+zZ8CCtk0/WK9aAhXUCa7XU/IKrAxclxrTO 4kJ1w4hTL+a6yLvNUxwk051x4n9SK56omw== X-Google-Smtp-Source: APXvYqwI2QTk5mCHY4Q0WG7Hsbi2PIhtBcBFYCFgj/3jd2bHVzCVlHpyB0G552ORrBN9WHP+UrCgyA== X-Received: by 2002:a63:2bd2:: with SMTP id r201mr2916911pgr.193.1565865317543; Thu, 15 Aug 2019 03:35:17 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id o128sm2481066pfb.42.2019.08.15.03.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2019 03:35:16 -0700 (PDT) From: Peter Xu To: kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , Wanpeng Li , Krish Sadhukhan , peterx@redhat.com Subject: [PATCH v2 2/3] KVM: X86: Remove tailing newline for tracepoints Date: Thu, 15 Aug 2019 18:34:57 +0800 Message-Id: <20190815103458.23207-3-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190815103458.23207-1-peterx@redhat.com> References: <20190815103458.23207-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 X-Virus-Scanned: ClamAV using ClamSMTP It's done by TP_printk() already. Reviewed-by: Krish Sadhukhan Signed-off-by: Peter Xu Reviewed-by: Sean Christopherson --- 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 c682f3f7f998..76a39bc25b95 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 Thu Aug 15 10:34:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11095529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D63DB6C5 for ; Thu, 15 Aug 2019 10:35:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4A5028789 for ; Thu, 15 Aug 2019 10:35:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7FEF28895; Thu, 15 Aug 2019 10:35:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12715287A3 for ; Thu, 15 Aug 2019 10:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731052AbfHOKfX (ORCPT ); Thu, 15 Aug 2019 06:35:23 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33530 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731000AbfHOKfX (ORCPT ); Thu, 15 Aug 2019 06:35:23 -0400 Received: by mail-pf1-f194.google.com with SMTP id g2so1172959pfq.0 for ; Thu, 15 Aug 2019 03:35:22 -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=33m3O5DWLYAcsEqCH2UFmqPmQO/B9Pi/tzCFYezMsSg=; b=nul6GQum/jEJ5hD25mOYaUqnAqpOS9+r2C69xMZi4yBAT0or6/USOkZTyHMmYialFI sHrg7I6XP4HBuQy75+GnUQjdREqmzXWBKNalfqRIowrg8NtWL6AFuWA4mslXYLFQtYjt MQzWH16HuqcTA0SCg8XPhyfG8JCe6EIb82GDqKXNUD2dIMHFFdW8Lj3bT5+2JagDVcB7 C1l9CzgcOgORnHMuH15Ou3P00AX7hNJavY59GBTO8Pe+SZ9xtSDILD0q4n6Wgapb523R dU/uu0FnJ1pcyOpbMY6eUyGqSgwR6NwmxYNOsvU2opK07WmAX1jChKOHxxf5M1fj1kbp 8YaQ== X-Gm-Message-State: APjAAAXHQvCIdtsu/sWU2tUhGhaPHppv+S9Be0l6J3UCeIfiB0JUQ05P Wx9CC/yj3Kp8ercfBKoRJ8QdaOlaFlsztQ== X-Google-Smtp-Source: APXvYqzD9VtGZFtWkEE3gyAU7NDFFdGziq2HH36MqPoEwFmKcAAMBzg11AkYbPytTuxzsS7qJHq/HA== X-Received: by 2002:a65:621a:: with SMTP id d26mr2975540pgv.153.1565865321459; Thu, 15 Aug 2019 03:35:21 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id o128sm2481066pfb.42.2019.08.15.03.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2019 03:35:20 -0700 (PDT) From: Peter Xu To: kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , Wanpeng Li , Krish Sadhukhan , peterx@redhat.com Subject: [PATCH v2 3/3] KVM: X86: Tune PLE Window tracepoint Date: Thu, 15 Aug 2019 18:34:58 +0800 Message-Id: <20190815103458.23207-4-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190815103458.23207-1-peterx@redhat.com> References: <20190815103458.23207-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 X-Virus-Scanned: ClamAV using ClamSMTP 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 --- arch/x86/kvm/svm.c | 16 ++++++++-------- arch/x86/kvm/trace.h | 21 ++++++--------------- arch/x86/kvm/vmx/vmx.c | 14 ++++++++------ arch/x86/kvm/x86.c | 2 +- 4 files changed, 23 insertions(+), 30 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 76a39bc25b95..97df9d7cae71 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -890,36 +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, int new, int old), - TP_ARGS(grow, vcpu_id, new, old), +TRACE_EVENT(kvm_ple_window_update, + TP_PROTO(unsigned int vcpu_id, int new, int old), + TP_ARGS(vcpu_id, new, old), TP_STRUCT__entry( - __field( bool, grow ) __field( unsigned int, vcpu_id ) __field( int, new ) __field( 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 %d (%s %d)", - __entry->vcpu_id, - __entry->new, - __entry->grow ? "grow" : "shrink", - __entry->old) + TP_printk("vcpu %u old %d new %d (%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 42ed3faa6af8..469c4134a4a7 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);