Skip to contentSkip to conversation

xen: make tracebuffer configurable

PATCH Superseded Baodong Chen 2 participants 3 messages Jun 5, 2019 – Jun 10, 2019

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 xen: make tracebuffer configurable

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.

---
 xen/common/Kconfig      |  9 +++++++++
 xen/common/Makefile     |  2 +-
 xen/include/xen/trace.h | 26 ++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)
xen/common/Kconfig +9 -0
index c838506..d908fe1 100644
@@ -368,4 +368,13 @@ config DOM0_MEM
 
 	  Leave empty if you are not sure what to specify.
 
+config TRACEBUFFER
+	bool "Enable tracing infrastructure"  if EXPERT = "y"
+	default y
+	---help---
+	  Enable in tracing infrastructure and pre-defined tracepoints within Xen.
+	  This will allow live information about Xen’s execution and performance
+	  to be collected at run time for debugging or performance analysis.
+	  Memory and execution overhead when not active is minimal.
+
 endmenu
xen/common/Makefile +1 -1
index bca48e6..9fd1bd2 100644
@@ -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
xen/include/xen/trace.h +26 -0
index 12966ea..fad92c7 100644
@@ -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 {                                        \
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 22 lines · Baodong Chen

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.

---

xen/common/Kconfig      |  9 +++++++++
xen/common/Makefile     |  2 +-
xen/include/xen/trace.h | 26 ++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
xen/common/Kconfig +0 -0
index c838506..d908fe1 100644

xen/common/Kconfig config DOM0_MEM · line 375

Quoted 8 lines
xen/common/Kconfig +5 -0
@@ -368,4 +368,13 @@ config DOM0_MEM
 
 	  Leave empty if you are not sure what to specify.
 
+config TRACEBUFFER
+	bool "Enable tracing infrastructure"  if EXPERT = "y"
+	default y
+	---help---
+	  Enable in tracing infrastructure and pre-defined tracepoints within Xen.

Sorry, an editing mistake caused me to include a stray ‘in’ in this sentence when I suggested this text. :-)

This could be removed on check-in. With that fixed, the commit message looks OK to me.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 24 lines · George Dunlap
Quoted 24 lines · Baodong Chen

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.

---

xen/common/Kconfig      |  9 +++++++++
xen/common/Makefile     |  2 +-
xen/include/xen/trace.h | 26 ++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
xen/common/Kconfig +0 -0
index c838506..d908fe1 100644
@@ -368,4 +368,13 @@ config DOM0_MEM
 
 	  Leave empty if you are not sure what to specify.
 
Quoted 8 lines

xen/common/Kconfig config DOM0_MEM · line 375

Quoted 5 lines
xen/common/Kconfig +5 -0
+config TRACEBUFFER
+	bool "Enable tracing infrastructure"  if EXPERT = "y"
+	default y
+	---help---
+	  Enable in tracing infrastructure and pre-defined tracepoints within Xen.

Sorry, an editing mistake caused me to include a stray ‘in’ in this sentence when I suggested this text. :-)

This could be removed on check-in. With that fixed, the commit message looks OK to me.

Hello George,

sorry for the late reply.

Fixed according to your comments in v4.

Quoted 2 lines

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel