Skip to contentSkip to conversation

Add callgraph support to Xenoprofile

PATCH In review Amitabha Roy 2 participants 6 messages Jun 7, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add callgraph support to Xenoprofile

Hi

This patch implements backtrace support in Xenoprofile. It's been reviewed by Renato. I've tested it out successfully on xen x86_32 and x86_64. I've added stubs for the backtrace for ia64 to ensure that it compiles ok but havent been able to test that out. However, I believe there shouldn't be any problems.

Thanks
-Amitabha

# HG changeset patch
# User [email protected]
# Date 1181186537 -19800
# Node ID 1d47ef825eb4f53fdb6d686ddf4d2ae9e47a70a0 # Parent bd3d6b4c52ec809f080c89c4ffcf61dc6e445978 Add backtrace support to xenoprof

Config.mk +7 -1
diff -r bd3d6b4c52ec -r 1d47ef825eb4 Config.mk
@@ -12,13 +12,19 @@ XEN_TARGET_X86_PAE  ?= y
 XEN_TARGET_X86_PAE  ?= y
 endif
 
+ifneq ($(FRAME_POINTER),y)
+CONFIG_FRAME_POINTER ?= -fomit-frame-pointer
+else
+CONFIG_FRAME_POINTER ?= -DCONFIG_FRAME_POINTER -fno-omit-frame-pointer
+endif 
+
 CONFIG_$(XEN_OS) := y
 
 SHELL     ?= /bin/sh
 
 # Tools to run on system hosting the build
 HOSTCC     = gcc
-HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer
+HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 $(CONFIG_FRAME_POINTER)
 
 DISTDIR     ?= $(XEN_ROOT)/dist
 DESTDIR     ?= /
config/StdGNU.mk +2 -2
diff -r bd3d6b4c52ec -r 1d47ef825eb4 config/StdGNU.mk
@@ -26,8 +26,8 @@ SHLIB_CFLAGS = -shared
 
 ifneq ($(debug),y)
 # Optimisation flags are overridable
-CFLAGS ?= -O2 -fomit-frame-pointer
+CFLAGS ?= -O2 $(CONFIG_FRAME_POINTER)
 else
 # Less than -O1 produces bad code and large stack frames
-CFLAGS ?= -O1 -fno-omit-frame-pointer
+CFLAGS ?= -O1 $(CONFIG_FRAME_POINTER)
 endif
linux-2.6-xen-sparse/drivers/xen/xenoprof/xenoprofile.c +64 -22

132 lines not on this page · raw message

xen/arch/ia64/xen/oprofile/perfmon.c +5 -2
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/arch/ia64/xen/oprofile/perfmon.c
@@ -37,7 +37,7 @@
 #include <asm/ptrace.h>
 
 // XXX move them to an appropriate header file
-extern void xenoprof_log_event(struct vcpu *vcpu,
+extern void xenoprof_log_event(struct vcpu *vcpu, struct pt_regs * regs,
                                unsigned long eip, int mode, int event);
 extern int is_active(struct domain *d);
 
@@ -55,7 +55,10 @@ xenoprof_handler(struct task_struct *tas
     if (!allow_virq || !allow_ints)
         return 0;
 
-    xenoprof_log_event(current, ip, xenoprofile_get_mode(task, regs), event);
+    // Note that log event actually expect cpu_user_regs, cast back 
+    // appropriately when doing the backtrace implementation in ia64
+    xenoprof_log_event(current, regs, ip, xenoprofile_get_mode(task, regs), 
+					   event);
     
     // send VIRQ_XENOPROF
     if (is_active(current->domain) && !ring_0(regs))
xen/arch/x86/oprofile/Makefile +1 -0
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/arch/x86/oprofile/Makefile
@@ -3,3 +3,4 @@ obj-y += op_model_p4.o
 obj-y += op_model_p4.o
 obj-y += op_model_ppro.o
 obj-y += op_model_athlon.o
+obj-y += backtrace.o
xen/arch/x86/oprofile/op_model_athlon.c +3 -3
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/arch/x86/oprofile/op_model_athlon.c
@@ -43,8 +43,8 @@
 
 static unsigned long reset_value[NUM_COUNTERS];
 
-extern void xenoprof_log_event(struct vcpu *v, unsigned long eip,
-			       int mode, int event);
+extern void xenoprof_log_event(struct vcpu *v, struct cpu_user_regs * regs, 
+			       unsigned long eip, int mode, int event);
 extern int xenoprofile_get_mode(struct vcpu *v,
 				struct cpu_user_regs * const regs);
 
@@ -130,7 +130,7 @@ static int athlon_check_ctrs(unsigned in
 	for (i = 0 ; i < NUM_COUNTERS; ++i) {
 		CTR_READ(low, high, msrs, i);
 		if (CTR_OVERFLOWED(low)) {
-			xenoprof_log_event(current, eip, mode, i);
+			xenoprof_log_event(current, regs, eip, mode, i);
 			CTR_WRITE(reset_value[i], msrs, i);
 			ovf = 1;
 		}
xen/arch/x86/oprofile/op_model_p4.c +4 -4
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/arch/x86/oprofile/op_model_p4.c
@@ -620,8 +620,8 @@ static void p4_setup_ctrs(struct op_msrs
 	}
 }
 
-extern void xenoprof_log_event(struct vcpu *v, unsigned long eip,
-			       int mode, int event);
+extern void xenoprof_log_event(struct vcpu *v, struct cpu_user_regs * regs, 
+			       unsigned long eip, int mode, int event);
 extern int xenoprofile_get_mode(struct vcpu *v,
 				struct cpu_user_regs * const regs);
 
@@ -664,8 +664,8 @@ static int p4_check_ctrs(unsigned int co
 		CCCR_READ(low, high, real);
  		CTR_READ(ctr, high, real);
 		if (CCCR_OVF_P(low) || CTR_OVERFLOW_P(ctr)) {
-			xenoprof_log_event(current, eip, mode, i);
- 			CTR_WRITE(reset_value[i], real);
+			xenoprof_log_event(current, regs, eip, mode, i);
+			CTR_WRITE(reset_value[i], real);
 			CCCR_CLEAR_OVF(low);
 			CCCR_WRITE(low, high, real);
  			CTR_WRITE(reset_value[i], real);
xen/arch/x86/oprofile/op_model_ppro.c +3 -3
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/arch/x86/oprofile/op_model_ppro.c
@@ -88,8 +88,8 @@ static void ppro_setup_ctrs(struct op_ms
 	}
 }
 
-extern void xenoprof_log_event(struct vcpu *v, unsigned long eip,
-			       int mode, int event);
+extern void xenoprof_log_event(struct vcpu *v, struct cpu_user_regs * regs, 
+			       unsigned long eip, int mode, int event);
 extern int xenoprofile_get_mode(struct vcpu *v,
 				struct cpu_user_regs * const regs);
  
@@ -106,7 +106,7 @@ static int ppro_check_ctrs(unsigned int 
 	for (i = 0 ; i < NUM_COUNTERS; ++i) {
 		CTR_READ(low, high, msrs, i);
 		if (CTR_OVERFLOWED(low)) {
-			xenoprof_log_event(current, eip, mode, i);
+			xenoprof_log_event(current, regs, eip, mode, i);
 			CTR_WRITE(reset_value[i], msrs, i);
 			ovf = 1;
 		}
xen/common/xenoprof.c +132 -41

215 lines not on this page · raw message

xen/include/asm-ia64/xenoprof.h +10 -1
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/include/asm-ia64/xenoprof.h
@@ -37,7 +37,16 @@ struct vcpu;
 struct vcpu;
 struct cpu_user_regs;
 int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs);
-
+static inline int arch_backtrace_supported(void)
+{
+	return 0;
+}
+static inline void backtrace(struct domain *d, struct vcpu *vcpu, 
+                      struct pt_regs *const regs, unsigned long depth, int mode)
+{
+    /* To be implemented */
+    return;
+}
 #define xenoprof_shared_gmfn(d, gmaddr, maddr)  \
     assign_domain_page((d), (gmaddr), (maddr));
 
xen/include/asm-x86/xenoprof.h +6 -0
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/include/asm-x86/xenoprof.h
@@ -47,6 +47,12 @@ struct vcpu;
 struct vcpu;
 struct cpu_user_regs;
 int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs);
+static inline int arch_backtrace_supported(void)
+{
+	return 1;
+}
+void backtrace(struct domain *d, struct vcpu *vcpu, 
+               struct cpu_user_regs *const regs, unsigned long depth, int mode);
 #define xenoprof_shared_gmfn(d, gmaddr, maddr)                      \
     do {                                                            \
         (void)(maddr);                                              \
xen/include/public/xenoprof.h +7 -1
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/include/public/xenoprof.h
@@ -49,7 +49,8 @@
 #define XENOPROF_release_counters   12
 #define XENOPROF_shutdown           13
 #define XENOPROF_get_buffer         14
-#define XENOPROF_last_op            14
+#define XENOPROF_set_backtrace      15
+#define XENOPROF_last_op            15
 
 #define MAX_OPROF_EVENTS    32
 #define MAX_OPROF_DOMAINS   25
@@ -61,6 +62,11 @@ struct event_log {
     uint8_t mode;
     uint8_t event;
 };
+
+/* PC value that indicates a special code */
+#define XENOPROF_ESCAPE_CODE ~0UL
+/* Transient events for the xenoprof->oprofile cpu buf */
+#define XENOPROF_TRACE_BEGIN 1
 
 /* Xenoprof buffer shared between Xen and domain - 1 per VCPU */
 struct xenoprof_buf {
xen/include/xen/xenoprof.h +2 -0
diff -r bd3d6b4c52ec -r 1d47ef825eb4 xen/include/xen/xenoprof.h
@@ -66,6 +66,8 @@ void free_xenoprof_pages(struct domain *
 void free_xenoprof_pages(struct domain *d);
 
 int do_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg);
+int xenoprof_add_trace(struct domain *d, struct vcpu *v, 
+                       unsigned long eip, int mode);
 
 extern struct domain *xenoprof_primary_profiler;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Amitabha Roy

This patch implements backtrace support in Xenoprofile. It's been reviewed by Renato. I've tested it out successfully on xen x86_32 and x86_64. I've added stubs for the backtrace for ia64 to ensure that it compiles ok but havent been able to test that out. However, I believe there shouldn't be any problems.

Coding style is all over the shop. Where does CONFIG_FRAME_POINTER get used? I'm not sure that FRAME_POINTER needs to be a top-level option -- it's only necessary for Xen build isn't it?

-- Keir

#2 lore raw

Hi Keir

Coding style is likely because I've preserved the formatting of the original files (esp. of backtrace.c from Linux for simple diffs). There isnt a consistent style across the files that I could follow.

CONFIG_FRAME_POINTER gets used in config/StdGNU.mk.
I simply followed whatever was done for XEN_TARGET_X86_PAE. However unlike the PAE case I haven't ensured that frame pointers are turned on both in the kernel and Xen. If you want I can move all the frame pointer related stuff into xen/Rules.mk.

-Amitabha

Quoted 15 lines · Keir Fraser
Quoted 5 lines · Amitabha Roy

This patch implements backtrace support in Xenoprofile. It's been reviewed by Renato. I've tested it out successfully on xen x86_32 and x86_64. I've added stubs for the backtrace for ia64 to ensure that it compiles ok but havent been able to test that out. However, I believe there shouldn't be any problems.

Coding style is all over the shop. Where does CONFIG_FRAME_POINTER get used? I'm not sure that FRAME_POINTER needs to be a top-level option -- it's only necessary for Xen build isn't it?

-- Keir

#3 lore raw
Quoted 3 lines · Amitabha Roy

Coding style is likely because I've preserved the formatting of the original files (esp. of backtrace.c from Linux for simple diffs). There isnt a consistent style across the files that I could follow.

Linux-derived files follow Linux style (this will apply to many of the files under arch/x86/oprofile). Xen-specific files follow Xen style as in e.g., page_alloc.c, xmalloc.c, xenoprof.c).

If any of the files you edit don't follow this, please fix them first, and send a separate patch as a prerequisite for your own.

Quoted 5 lines

CONFIG_FRAME_POINTER gets used in config/StdGNU.mk.
I simply followed whatever was done for XEN_TARGET_X86_PAE. However unlike the PAE case I haven't ensured that frame pointers are turned on both in the kernel and Xen. If you want I can move all the frame pointer related stuff into xen/Rules.mk.

Yes, please. Call the option frame_pointer, in line with other Xen-specific options which are also lower case.

-- Keir

author Reviewed-by Jose Renato G Santos
#4 lore raw

I've moved the frame pointer code into the xen specific makefile. I've also fixed the per file inconsistencies. I noticed that some files already have a few inconsistencies within themselves in places other than my code.

Perhaps you could accept this patch and I can send a separate one later fixing those ?
One of the suggestions I had from Renato was to minimize any diffs of files based off linux versions so that pulling in updates will be easier. So I can look into those on a case by case basis with him.

-Amitabha

Quoted 19 lines · Keir Fraser
Quoted 3 lines · Amitabha Roy

Coding style is likely because I've preserved the formatting of the original files (esp. of backtrace.c from Linux for simple diffs). There isnt a consistent style across the files that I could follow.

Linux-derived files follow Linux style (this will apply to many of the files under arch/x86/oprofile). Xen-specific files follow Xen style as in e.g., page_alloc.c, xmalloc.c, xenoprof.c).

If any of the files you edit don't follow this, please fix them first, and send a separate patch as a prerequisite for your own.

Quoted 5 lines

CONFIG_FRAME_POINTER gets used in config/StdGNU.mk.
I simply followed whatever was done for XEN_TARGET_X86_PAE. However unlike the PAE case I haven't ensured that frame pointers are turned on both in the kernel and Xen. If you want I can move all the frame pointer related stuff into xen/Rules.mk.

Quoted 6 lines

Yes, please. Call the option frame_pointer, in line with other Xen-specific options which are also lower case.

-- Keir

# HG changeset patch
# User [email protected]
# Date 1181216195 -19800
# Node ID e6f484a96f435fd882de142797f6b309928a1ee9 # Parent bd3d6b4c52ec809f080c89c4ffcf61dc6e445978 Add backtrace support to xenoprof

linux-2.6-xen-sparse/drivers/xen/xenoprof/xenoprofile.c +67 -22
diff -r bd3d6b4c52ec -r e6f484a96f43 linux-2.6-xen-sparse/drivers/xen/xenoprof/xenoprofile.c
@@ -51,6 +51,8 @@ static int xenoprof_is_primary = 0;
 static int xenoprof_is_primary = 0;
 static int active_defined;
 
+extern unsigned long backtrace_depth;
+
 /* Number of buffers in shared area (one per VCPU) */
 int nbuf;
 /* Mappings of VIRQ_XENOPROF to irq number (per cpu) */
@@ -115,38 +117,59 @@ unsigned int pdomains;
 unsigned int pdomains;
 struct xenoprof_passive passive_domains[MAX_OPROF_DOMAINS];
 
+
+/* Check whether the given entry is an escape code */
+static int xenoprof_is_escape(xenoprof_buf_t * buf, int tail)
+{
+	return (buf->event_log[tail].eip == XENOPROF_ESCAPE_CODE);
+}
+
+/* Get the event at the given entry  */
+static uint8_t xenoprof_get_event(xenoprof_buf_t * buf, int tail)
+{
+	return (buf->event_log[tail].event);
+}
+
+
+
+
 static void xenoprof_add_pc(xenoprof_buf_t *buf, int is_passive)
 {
 	int head, tail, size;
+	int tracing = 0;
 
 	head = buf->event_head;
 	tail = buf->event_tail;
 	size = buf->event_size;
 
-	if (tail > head) {
-		while (tail < size) {
-			oprofile_add_pc(buf->event_log[tail].eip,
-					buf->event_log[tail].mode,
-					buf->event_log[tail].event);
+	while(tail != head) {
+		if(xenoprof_is_escape(buf, tail) && 
+		   xenoprof_get_event(buf, tail)==XENOPROF_TRACE_BEGIN){
+			tracing=1;
+			oprofile_add_pc(ESCAPE_CODE, buf->event_log[tail].mode, 
+					CPU_TRACE_BEGIN); 
 			if (!is_passive)
 				oprofile_samples++;
 			else
 				p_oprofile_samples++;
-			tail++;
-		}
-		tail = 0;
-	}
-	while (tail < head) {
-		oprofile_add_pc(buf->event_log[tail].eip,
-				buf->event_log[tail].mode,
-				buf->event_log[tail].event);
-		if (!is_passive)
-			oprofile_samples++;
-		else
-			p_oprofile_samples++;
+			
+		}
+		else{
+			oprofile_add_pc(buf->event_log[tail].eip,
+					buf->event_log[tail].mode,
+					buf->event_log[tail].event);
+			if(!tracing){
+				if (!is_passive)
+					oprofile_samples++;
+				else
+					p_oprofile_samples++;
+			}
+       
+		}
 		tail++;
-	}
-
+		if(tail==size)
+		    tail=0;
+	}
 	buf->event_tail = tail;
 }
 
@@ -294,9 +317,16 @@ static int xenoprof_setup(void)
 			active_defined = 1;
 		}
 
+		if(backtrace_depth > 0){
+			ret = HYPERVISOR_xenoprof_op(XENOPROF_set_backtrace, 
+						 &backtrace_depth);
+			if (ret)
+			backtrace_depth = 0;
+		}
 		ret = HYPERVISOR_xenoprof_op(XENOPROF_reserve_counters, NULL);
 		if (ret)
 			goto err;
+		
 		xenoprof_arch_counter();
 		ret = HYPERVISOR_xenoprof_op(XENOPROF_setup_events, NULL);
 
@@ -438,8 +468,22 @@ out:
 	for (j = 0; j < i; j++)
 		xenoprof_arch_unmap_shared_buffer(&p_shared_buffer[i]);
 
- 	return ret;
-}
+	return ret;
+}
+
+
+/* The dummy backtrace function to keep oprofile happy
+ * The real backtrace is done in xen
+ */
+static void xenoprof_dummy_backtrace(struct pt_regs * const regs, 
+				     unsigned int depth)
+{
+	/* this should never be called */
+	BUG();
+	return;
+}
+
+
 
 struct oprofile_operations xenoprof_ops = {
 #ifdef HAVE_XENOPROF_CREATE_FILES
@@ -450,7 +494,8 @@ struct oprofile_operations xenoprof_ops 
 	.setup 		= xenoprof_setup,
 	.shutdown	= xenoprof_shutdown,
 	.start		= xenoprof_start,
-	.stop		= xenoprof_stop
+	.stop		= xenoprof_stop,
+	.backtrace	= xenoprof_dummy_backtrace
 };
 
 
xen/Rules.mk +14 -4
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/Rules.mk
@@ -3,10 +3,11 @@
 # If you change any of these configuration options then you must
 # 'make clean' before rebuilding.
 #
-verbose     ?= n
-perfc       ?= n
-perfc_arrays?= n
-crash_debug ?= n
+verbose      ?= n
+perfc        ?= n
+perfc_arrays ?= n
+crash_debug  ?= n
+frame_pointer?= n
 
 XEN_ROOT=$(BASEDIR)/..
 include $(XEN_ROOT)/Config.mk
@@ -19,6 +20,15 @@ ifeq ($(perfc_arrays),y)
 ifeq ($(perfc_arrays),y)
 perfc := y
 endif
+ifeq ($(frame_pointer),y)
+FRAME_ON := -fno-omit-frame-pointer -DCONFIG_FRAME_POINTER
+ifdef $(CFLAGS)
+CFLAGS   :=  $(shell echo $(CFLAGS) |\
+               sed -e 's/-fomit-frame-pointer/'"$(FRAME_ON)/")
+else
+CFLAGS   := $(FRAME_ON) 
+endif # CFLAGS defined ?
+endif # Need frame pointer
 
 # Set ARCH/SUBARCH appropriately.
 override COMPILE_SUBARCH := $(XEN_COMPILE_ARCH)
xen/arch/ia64/xen/oprofile/perfmon.c +5 -2
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/arch/ia64/xen/oprofile/perfmon.c
@@ -37,7 +37,7 @@
 #include <asm/ptrace.h>
 
 // XXX move them to an appropriate header file
-extern void xenoprof_log_event(struct vcpu *vcpu,
+extern void xenoprof_log_event(struct vcpu *vcpu, struct pt_regs * regs,
                                unsigned long eip, int mode, int event);
 extern int is_active(struct domain *d);
 
@@ -55,7 +55,10 @@ xenoprof_handler(struct task_struct *tas
     if (!allow_virq || !allow_ints)
         return 0;
 
-    xenoprof_log_event(current, ip, xenoprofile_get_mode(task, regs), event);
+    // Note that log event actually expect cpu_user_regs, cast back 
+    // appropriately when doing the backtrace implementation in ia64
+    xenoprof_log_event(current, regs, ip, xenoprofile_get_mode(task, regs), 
+					   event);
     
     // send VIRQ_XENOPROF
     if (is_active(current->domain) && !ring_0(regs))
xen/arch/x86/oprofile/Makefile +1 -0
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/arch/x86/oprofile/Makefile
@@ -3,3 +3,4 @@ obj-y += op_model_p4.o
 obj-y += op_model_p4.o
 obj-y += op_model_ppro.o
 obj-y += op_model_athlon.o
+obj-y += backtrace.o
xen/arch/x86/oprofile/op_model_athlon.c +3 -3
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/arch/x86/oprofile/op_model_athlon.c
@@ -43,8 +43,8 @@
 
 static unsigned long reset_value[NUM_COUNTERS];
 
-extern void xenoprof_log_event(struct vcpu *v, unsigned long eip,
-			       int mode, int event);
+extern void xenoprof_log_event(struct vcpu *v, struct cpu_user_regs * regs, 
+			       unsigned long eip, int mode, int event);
 extern int xenoprofile_get_mode(struct vcpu *v,
 				struct cpu_user_regs * const regs);
 
@@ -130,7 +130,7 @@ static int athlon_check_ctrs(unsigned in
 	for (i = 0 ; i < NUM_COUNTERS; ++i) {
 		CTR_READ(low, high, msrs, i);
 		if (CTR_OVERFLOWED(low)) {
-			xenoprof_log_event(current, eip, mode, i);
+			xenoprof_log_event(current, regs, eip, mode, i);
 			CTR_WRITE(reset_value[i], msrs, i);
 			ovf = 1;
 		}
xen/arch/x86/oprofile/op_model_p4.c +4 -4
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/arch/x86/oprofile/op_model_p4.c
@@ -620,8 +620,8 @@ static void p4_setup_ctrs(struct op_msrs
 	}
 }
 
-extern void xenoprof_log_event(struct vcpu *v, unsigned long eip,
-			       int mode, int event);
+extern void xenoprof_log_event(struct vcpu *v, struct cpu_user_regs * regs, 
+			       unsigned long eip, int mode, int event);
 extern int xenoprofile_get_mode(struct vcpu *v,
 				struct cpu_user_regs * const regs);
 
@@ -664,8 +664,8 @@ static int p4_check_ctrs(unsigned int co
 		CCCR_READ(low, high, real);
  		CTR_READ(ctr, high, real);
 		if (CCCR_OVF_P(low) || CTR_OVERFLOW_P(ctr)) {
-			xenoprof_log_event(current, eip, mode, i);
- 			CTR_WRITE(reset_value[i], real);
+			xenoprof_log_event(current, regs, eip, mode, i);
+			CTR_WRITE(reset_value[i], real);
 			CCCR_CLEAR_OVF(low);
 			CCCR_WRITE(low, high, real);
  			CTR_WRITE(reset_value[i], real);
xen/arch/x86/oprofile/op_model_ppro.c +3 -3
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/arch/x86/oprofile/op_model_ppro.c
@@ -88,8 +88,8 @@ static void ppro_setup_ctrs(struct op_ms
 	}
 }
 
-extern void xenoprof_log_event(struct vcpu *v, unsigned long eip,
-			       int mode, int event);
+extern void xenoprof_log_event(struct vcpu *v, struct cpu_user_regs * regs, 
+			       unsigned long eip, int mode, int event);
 extern int xenoprofile_get_mode(struct vcpu *v,
 				struct cpu_user_regs * const regs);
  
@@ -106,7 +106,7 @@ static int ppro_check_ctrs(unsigned int 
 	for (i = 0 ; i < NUM_COUNTERS; ++i) {
 		CTR_READ(low, high, msrs, i);
 		if (CTR_OVERFLOWED(low)) {
-			xenoprof_log_event(current, eip, mode, i);
+			xenoprof_log_event(current, regs, eip, mode, i);
 			CTR_WRITE(reset_value[i], msrs, i);
 			ovf = 1;
 		}
xen/common/xenoprof.c +132 -41

215 lines not on this page · raw message

xen/include/asm-ia64/xenoprof.h +10 -1
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/include/asm-ia64/xenoprof.h
@@ -37,7 +37,16 @@ struct vcpu;
 struct vcpu;
 struct cpu_user_regs;
 int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs);
-
+static inline int arch_backtrace_supported(void)
+{
+    return 0;
+}
+static inline void backtrace(struct domain *d, struct vcpu *vcpu, 
+                      struct pt_regs *const regs, unsigned long depth, int mode)
+{
+    /* To be implemented */
+    return;
+}
 #define xenoprof_shared_gmfn(d, gmaddr, maddr)  \
     assign_domain_page((d), (gmaddr), (maddr));
 
xen/include/asm-x86/xenoprof.h +6 -0
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/include/asm-x86/xenoprof.h
@@ -47,6 +47,12 @@ struct vcpu;
 struct vcpu;
 struct cpu_user_regs;
 int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs);
+static inline int arch_backtrace_supported(void)
+{
+    return 1;
+}
+void backtrace(struct domain *d, struct vcpu *vcpu, 
+               struct cpu_user_regs *const regs, unsigned long depth, int mode);
 #define xenoprof_shared_gmfn(d, gmaddr, maddr)                      \
     do {                                                            \
         (void)(maddr);                                              \
xen/include/public/xenoprof.h +7 -1
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/include/public/xenoprof.h
@@ -49,7 +49,8 @@
 #define XENOPROF_release_counters   12
 #define XENOPROF_shutdown           13
 #define XENOPROF_get_buffer         14
-#define XENOPROF_last_op            14
+#define XENOPROF_set_backtrace      15
+#define XENOPROF_last_op            15
 
 #define MAX_OPROF_EVENTS    32
 #define MAX_OPROF_DOMAINS   25
@@ -61,6 +62,11 @@ struct event_log {
     uint8_t mode;
     uint8_t event;
 };
+
+/* PC value that indicates a special code */
+#define XENOPROF_ESCAPE_CODE ~0UL
+/* Transient events for the xenoprof->oprofile cpu buf */
+#define XENOPROF_TRACE_BEGIN 1
 
 /* Xenoprof buffer shared between Xen and domain - 1 per VCPU */
 struct xenoprof_buf {
xen/include/xen/xenoprof.h +2 -0
diff -r bd3d6b4c52ec -r e6f484a96f43 xen/include/xen/xenoprof.h
@@ -66,6 +66,8 @@ void free_xenoprof_pages(struct domain *
 void free_xenoprof_pages(struct domain *d);
 
 int do_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg);
+int xenoprof_add_trace(struct domain *d, struct vcpu *v, 
+                       unsigned long eip, int mode);
 
 extern struct domain *xenoprof_primary_profiler;
 
xen/arch/x86/oprofile/backtrace.c new file +138 -0

138 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw

Forgot to mention, the CONFIG_FRAME_POINTER is needed by the backtrace.c file I pulled from linux.

Quoted 42 lines · Amitabha Roy

I've moved the frame pointer code into the xen specific makefile. I've also fixed the per file inconsistencies. I noticed that some files already have a few inconsistencies within themselves in places other than my code.

Perhaps you could accept this patch and I can send a separate one later fixing those ?
One of the suggestions I had from Renato was to minimize any diffs of files based off linux versions so that pulling in updates will be easier. So I can look into those on a case by case basis with him.

-Amitabha

Quoted 25 lines · Keir Fraser
Quoted 3 lines · Amitabha Roy

Coding style is likely because I've preserved the formatting of the original files (esp. of backtrace.c from Linux for simple diffs). There isnt a consistent style across the files that I could follow.

Linux-derived files follow Linux style (this will apply to many of the files under arch/x86/oprofile). Xen-specific files follow Xen style as in e.g., page_alloc.c, xmalloc.c, xenoprof.c).

If any of the files you edit don't follow this, please fix them first, and send a separate patch as a prerequisite for your own.

Quoted 5 lines

CONFIG_FRAME_POINTER gets used in config/StdGNU.mk.
I simply followed whatever was done for XEN_TARGET_X86_PAE. However unlike the PAE case I haven't ensured that frame pointers are turned on both in the kernel and Xen. If you want I can move all the frame pointer related stuff into xen/Rules.mk.

Yes, please. Call the option frame_pointer, in line with other Xen-specific options which are also lower case.

-- Keir