diff mbox series

[v2] xen: make tracebuffer configurable

Message ID 1559639503-1705-1-git-send-email-chenbaodong@mxnavi.com (mailing list archive)
State Superseded
Headers show
Series [v2] xen: make tracebuffer configurable | expand

Commit Message

chenbaodong June 4, 2019, 9:11 a.m. UTC
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 <chenbaodong@mxnavi.com>
---
 xen/common/Kconfig      | 12 ++++++++++++
 xen/common/Makefile     |  2 +-
 xen/include/xen/trace.h | 26 ++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
diff mbox series

Patch

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..fad92c7 100644
--- a/xen/include/xen/trace.h
+++ b/xen/include/xen/trace.h
@@ -21,12 +21,18 @@ 
 #ifndef __XEN_TRACE_H__
 #define __XEN_TRACE_H__
 
+/* Put 'tb_init_done' here because 'asm/trace.h' may use it */
+#ifdef CONFIG_TRACEBUFFER
 extern int tb_init_done;
+#else
+#define tb_init_done false
+#endif
 
 #include <public/sysctl.h>
 #include <public/trace.h>
 #include <asm/trace.h>
 
+#ifdef CONFIG_TRACEBUFFER
 /* Used to initialise trace buffer functionality */
 void init_trace_bufs(void);
 
@@ -47,6 +53,26 @@  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
+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 {                                        \