From patchwork Wed Nov 5 19:46:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 5237761 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A9BBBC11AC for ; Wed, 5 Nov 2014 19:46:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6E902015E for ; Wed, 5 Nov 2014 19:46:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2DF42015A for ; Wed, 5 Nov 2014 19:46:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751764AbaKETqt (ORCPT ); Wed, 5 Nov 2014 14:46:49 -0500 Received: from mail-ie0-f173.google.com ([209.85.223.173]:33342 "EHLO mail-ie0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751410AbaKETqr (ORCPT ); Wed, 5 Nov 2014 14:46:47 -0500 Received: by mail-ie0-f173.google.com with SMTP id tr6so1448321ieb.32 for ; Wed, 05 Nov 2014 11:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=mPpv7HMyCGk7K3C2/M+WZ1kFzDhGNq8z8J7v0LBzyAk=; b=cb1QIyr12NnOLZbYnALr7sQzvSYRWnSfIrL/RVaVi6xmuxvBzbe1dmhrndI1G93Y5n bDiDnpb0Ty2w6rNUEk9SOzOsdVKaAGekbMLFdWv8XyhcxvgCzID3YM0t5CQsjKzKW0bG 2/ZaZqadaYzztHgYuTBMRp+MKx38dVCx6ueK4IUoRnlgp0MptPA177IZFAvZIv5WWV+e 4gjpIJrkqrp6hOiqxNCdkMroOu3vpxeuRgijYbJgS+klmiCVJ5slf4VyAYo3LErBAuHi qF/wuTgnU2IgJ7YNI7/gJucLg2lNpXxIIn+6+HBE2HIPgRS9HpCnIriSJAMX4LfE22s3 wF5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mPpv7HMyCGk7K3C2/M+WZ1kFzDhGNq8z8J7v0LBzyAk=; b=hkoae1C5qeukPrb7v/ILK+G4vnzzynfBuLM8/B3XWZijoKvq/6U61a+PKN0FhQ0naD TzmuRleaM3WWlpRmJA66v42m4GKRt8CAqWylpr0tBKFsOxvKh2muRuVzKJ40HlinsnCS 4nMX5C/dIQMndZA9o3/AQ4xqg1ynqwEITpl18BPP9aCUyqlU+8rqR8XYG08R7Cau/H/X 9OXQ1lGsPIshaZHs2t2Lom/M0VEt7djgzr5wAh1+f1dcF4FLOmmCo7VpVbQ92PNFIJNg DREB4mFlwkWcz29aNTaSu+inAp3uaavwwAikfrdLQGZ8J9loJFYdpqzRnZ4j0fulTZR8 vlCQ== X-Gm-Message-State: ALoCoQktIFptk13tDtSAXtdcH0EtBwFgikqLS4Rq6cndCdQX0OBWq/Z0YHCXmMfLut8RHNDMlbdo X-Received: by 10.43.164.200 with SMTP id mt8mr6836761icc.22.1415216807204; Wed, 05 Nov 2014 11:46:47 -0800 (PST) Received: from dmatlack-linux.kir.corp.google.com ([172.31.88.63]) by mx.google.com with ESMTPSA id w197sm1901161iod.24.2014.11.05.11.46.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Nov 2014 11:46:46 -0800 (PST) From: David Matlack To: pbonzini@redhat.com, kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, David Matlack Subject: [PATCH] kvm: x86: add trace event for pvclock updates Date: Wed, 5 Nov 2014 11:46:42 -0800 Message-Id: <1415216802-19201-1-git-send-email-dmatlack@google.com> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 The new trace event records: * the id of vcpu being updated * the pvclock_vcpu_time_info struct being written to guest memory This is useful for debugging pvclock bugs, such as the bug fixed by "[PATCH] kvm: x86: Fix kvm clock versioning.". Signed-off-by: David Matlack --- arch/x86/kvm/trace.h | 37 +++++++++++++++++++++++++++++++++++++ arch/x86/kvm/x86.c | 2 ++ 2 files changed, 39 insertions(+) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 6b06ab8..c2a34bb 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -5,6 +5,7 @@ #include #include #include +#include #undef TRACE_SYSTEM #define TRACE_SYSTEM kvm @@ -877,6 +878,42 @@ TRACE_EVENT(kvm_ple_window, #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), + + TP_STRUCT__entry( + __field( unsigned int, vcpu_id ) + __field( __u32, version ) + __field( __u64, tsc_timestamp ) + __field( __u64, system_time ) + __field( __u32, tsc_to_system_mul ) + __field( __s8, tsc_shift ) + __field( __u8, flags ) + ), + + TP_fast_assign( + __entry->vcpu_id = vcpu_id; + __entry->version = pvclock->version; + __entry->tsc_timestamp = pvclock->tsc_timestamp; + __entry->system_time = pvclock->system_time; + __entry->tsc_to_system_mul = pvclock->tsc_to_system_mul; + __entry->tsc_shift = pvclock->tsc_shift; + __entry->flags = pvclock->flags; + ), + + TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, " + "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, " + "flags 0x%x }", + __entry->vcpu_id, + __entry->version, + __entry->tsc_timestamp, + __entry->system_time, + __entry->tsc_to_system_mul, + __entry->tsc_shift, + __entry->flags) +); + #endif /* _TRACE_KVM_H */ #undef TRACE_INCLUDE_PATH diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0033df3..0f533df 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1662,6 +1662,8 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) vcpu->hv_clock.flags = pvclock_flags; + trace_kvm_pvclock_update(v->vcpu_id, &vcpu->hv_clock); + kvm_write_guest_cached(v->kvm, &vcpu->pv_time, &vcpu->hv_clock, sizeof(vcpu->hv_clock));