From patchwork Tue Aug 25 06:35:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 7068471 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 039459F344 for ; Tue, 25 Aug 2015 06:36:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 32BF820824 for ; Tue, 25 Aug 2015 06:36:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F99920821 for ; Tue, 25 Aug 2015 06:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932205AbbHYGgX (ORCPT ); Tue, 25 Aug 2015 02:36:23 -0400 Received: from blu004-omc1s28.hotmail.com ([65.55.116.39]:61279 "EHLO BLU004-OMC1S28.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754892AbbHYGgW (ORCPT ); Tue, 25 Aug 2015 02:36:22 -0400 Received: from BLU436-SMTP242 ([65.55.116.9]) by BLU004-OMC1S28.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Mon, 24 Aug 2015 23:36:21 -0700 X-TMN: [DGWisW/fXxI/T+wgEOVzpelcnIZtUQSkjspwjbf2zx4=] X-Originating-Email: [wanpeng.li@hotmail.com] Message-ID: From: Wanpeng Li To: Paolo Bonzini CC: David Matlack , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Wanpeng Li Subject: [PATCH v2 3/3] KVM: trace kvm_halt_poll_ns grow/shrink Date: Tue, 25 Aug 2015 14:35:19 +0800 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440484519-2709-1-git-send-email-wanpeng.li@hotmail.com> References: <1440484519-2709-1-git-send-email-wanpeng.li@hotmail.com> X-OriginalArrivalTime: 25 Aug 2015 06:36:20.0295 (UTC) FILETIME=[5A5F8D70:01D0DF00] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Tracepoint for dynamic halt_pool_ns, fired on every potential change. Signed-off-by: Wanpeng Li --- include/trace/events/kvm.h | 30 ++++++++++++++++++++++++++++++ virt/kvm/kvm_main.c | 8 ++++++++ 2 files changed, 38 insertions(+) diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index a44062d..75ddf80 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h @@ -356,6 +356,36 @@ TRACE_EVENT( __entry->address) ); +TRACE_EVENT(kvm_halt_poll_ns, + TP_PROTO(bool grow, unsigned int vcpu_id, int new, 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) + ), + + TP_fast_assign( + __entry->grow = grow; + __entry->vcpu_id = vcpu_id; + __entry->new = new; + __entry->old = old; + ), + + TP_printk("vcpu %u: halt_pool_ns %d (%s %d)", + __entry->vcpu_id, + __entry->new, + __entry->grow ? "grow" : "shrink", + __entry->old) +); + +#define trace_kvm_halt_poll_ns_grow(vcpu_id, new, old) \ + trace_kvm_halt_poll_ns(true, vcpu_id, new, old) +#define trace_kvm_halt_poll_ns_shrink(vcpu_id, new, old) \ + trace_kvm_halt_poll_ns(false, vcpu_id, new, old) + #endif #endif /* _TRACE_KVM_MAIN_H */ diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2a4962b..04f62e0 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1957,13 +1957,21 @@ static unsigned int __shrink_halt_poll_ns(int val, int modifier, int minimum) static void grow_halt_poll_ns(struct kvm_vcpu *vcpu) { + int old = vcpu->halt_poll_ns; + vcpu->halt_poll_ns = __grow_halt_poll_ns(vcpu->halt_poll_ns); + + trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, vcpu->halt_poll_ns, old); } static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu) { + int old = vcpu->halt_poll_ns; + vcpu->halt_poll_ns = __shrink_halt_poll_ns(vcpu->halt_poll_ns, halt_poll_ns_shrink, halt_poll_ns); + + trace_kvm_halt_poll_ns_shrink(vcpu->vcpu_id, vcpu->halt_poll_ns, old); } static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu)