From patchwork Tue Jun 4 00:44:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenbaodong X-Patchwork-Id: 10974097 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 BF4546C5 for ; Tue, 4 Jun 2019 00:47:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD30228764 for ; Tue, 4 Jun 2019 00:47:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A13002875F; Tue, 4 Jun 2019 00:47:35 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08ED528764 for ; Tue, 4 Jun 2019 00:47:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXxZl-0002TA-3f; Tue, 04 Jun 2019 00:45:17 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXxZj-0002T5-Tk for xen-devel@lists.xenproject.org; Tue, 04 Jun 2019 00:45:15 +0000 X-Inumbo-ID: 025ac852-8662-11e9-8980-bc764e045a96 Received: from mxnavi-mail.mxnavi.com (unknown [116.90.87.199]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 025ac852-8662-11e9-8980-bc764e045a96; Tue, 04 Jun 2019 00:45:13 +0000 (UTC) Received: from localhost.localdomain (61.161.186.150) by mxnavi-mail.mxnavi.com (116.90.87.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Tue, 4 Jun 2019 08:43:00 +0800 From: Baodong Chen To: Date: Tue, 4 Jun 2019 08:44:56 +0800 Message-ID: <1559609096-11356-1-git-send-email-chenbaodong@mxnavi.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [61.161.186.150] X-ClientProxiedBy: mxnavi-mail.mxnavi.com (116.90.87.199) To mxnavi-mail.mxnavi.com (116.90.87.199) Subject: [Xen-devel] [PATCH v1] xen: make tracebuffer configurable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Baodong Chen Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Xen internal running status(trace event) will be saved to trace memory when enabled. trace event data and config params can be read/changed by system control hypercall at run time. Can be disabled for smaller code footprint. Signed-off-by: Baodong Chen --- xen/common/Kconfig | 12 ++++++++++++ xen/common/Makefile | 2 +- xen/include/xen/trace.h | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index c838506..3459f56 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -368,4 +368,16 @@ config DOM0_MEM Leave empty if you are not sure what to specify. +config TRACEBUFFER + bool "Enable trace event logs" if EXPERT = "y" + ---help--- + Xen internal running status(trace event) will be saved to trace memory + when enabled. trace event data and config params can be read/changed + by system control hypercall at run time. + + This is used to record xen internal running status. + with a litte performance overhead. + Can be set to 'N' if you dont want this function. + When not configured, 'XEN_STSCTL_tbuf_op' command will result 'ENOSYS'. + endmenu diff --git a/xen/common/Makefile b/xen/common/Makefile index bca48e6..9fd1bd2 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -56,7 +56,7 @@ obj-y += sysctl.o obj-y += tasklet.o obj-y += time.o obj-y += timer.o -obj-y += trace.o +obj-$(CONFIG_TRACEBUFFER) += trace.o obj-y += version.o obj-y += virtual_region.o obj-y += vm_event.o diff --git a/xen/include/xen/trace.h b/xen/include/xen/trace.h index 12966ea..da781fa 100644 --- a/xen/include/xen/trace.h +++ b/xen/include/xen/trace.h @@ -21,12 +21,15 @@ #ifndef __XEN_TRACE_H__ #define __XEN_TRACE_H__ +#ifdef CONFIG_TRACEBUFFER extern int tb_init_done; +#endif #include #include #include +#ifdef CONFIG_TRACEBUFFER /* Used to initialise trace buffer functionality */ void init_trace_bufs(void); @@ -47,6 +50,20 @@ static inline void trace_var(u32 event, int cycles, int extra, void __trace_hypercall(uint32_t event, unsigned long op, const xen_ulong_t *args); +#else +#define tb_init_done false +static inline void init_trace_bufs(void) {} +static inline int tb_control(struct xen_sysctl_tbuf_op *tbc) { return -ENOSYS; } + +static inline int trace_will_trace_event(uint32_t event) { return 0; } +static inline void trace_var(uint32_t event, int cycles, int extra, + const void *extra_data) {} +static inline void __trace_var(uint32_t event, bool cycles, unsigned int extra, + const void *extra_data) {} +static inline void __trace_hypercall(uint32_t event, unsigned long op, + const xen_ulong_t *args) {} +#endif + /* Convenience macros for calling the trace function. */ #define TRACE_0D(_e) \ do { \