Skip to contentSkip to conversation

oprofile: ia64 support for oprofile stack trace sampling

PATCH In review Greg Banks 1 participant 1 message Nov 9, 2004

lore
Share & tools
lore

Greg Banks

author
#0 lore raw

PATCH 4/11 oprofile: ia64 support for oprofile stack trace sampling

Signature · 3 lines
-- 
Greg Banks, R&D Software Engineer, SGI Australian Software Group.
I don't speak for SGI.

oprofile ia64 arch updates, including some internal API changes and support for stack trace sampling.

---
 arch/ia64/kernel/ia64_ksyms.c  |    3 
 arch/ia64/kernel/unwind.c      |    2 
 arch/ia64/oprofile/Makefile    |    2 
 arch/ia64/oprofile/backtrace.c |  150 +++++++++++++++++++++++++++++++++++++++++
 arch/ia64/oprofile/init.c      |   10 +-
 arch/ia64/oprofile/perfmon.c   |   15 +---
 6 files changed, 167 insertions(+), 15 deletions(-)
arch/ia64/oprofile/perfmon.c +5 -10
Index: linux/arch/ia64/oprofile/perfmon.c
===================================================================
@@ -21,8 +21,6 @@ static int
 perfmon_handler(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg,
                 struct pt_regs *regs, unsigned long stamp)
 {
-	int cpu = smp_processor_id();
-	unsigned long eip = instruction_pointer(regs);
 	int event = arg->pmd_eventid;
  
 	arg->ovfl_ctrl.bits.reset_ovfl_pmds = 1;
@@ -31,7 +29,7 @@ perfmon_handler(struct task_struct *task
 	 * without perfmon being shutdown (e.g. SIGSEGV)
 	 */
 	if (allow_ints)
-		oprofile_add_sample(eip, !user_mode(regs), event, cpu);
+		oprofile_add_sample(regs, event);
 	return 0;
 }
 
@@ -75,21 +73,18 @@ static char * get_cpu_type(void)
 
 
 /* all the ops are handled via userspace for IA64 perfmon */
-static struct oprofile_operations perfmon_ops = {
-	.start = perfmon_start,
-	.stop = perfmon_stop,
-};
 
 static int using_perfmon;
 
-int perfmon_init(struct oprofile_operations ** ops)
+int perfmon_init(struct oprofile_operations * ops)
 {
 	int ret = pfm_register_buffer_fmt(&oprofile_fmt);
 	if (ret)
 		return -ENODEV;
 
-	perfmon_ops.cpu_type = get_cpu_type();
-	*ops = &perfmon_ops;
+	ops->cpu_type = get_cpu_type();
+	ops->start = perfmon_start;
+	ops->stop = perfmon_stop;
 	using_perfmon = 1;
 	printk(KERN_INFO "oprofile: using perfmon.\n");
 	return 0;
arch/ia64/oprofile/backtrace.c new file +150 -0

150 lines not on this page · raw message

arch/ia64/kernel/unwind.c +2 -0
Index: linux/arch/ia64/kernel/unwind.c
===================================================================
@@ -2110,6 +2110,8 @@ unw_init_frame_info (struct unw_frame_in
 	find_save_locs(info);
 }
 
+EXPORT_SYMBOL(unw_init_frame_info);
+
 void
 unw_init_from_blocked_task (struct unw_frame_info *info, struct task_struct *t)
 {
arch/ia64/oprofile/Makefile +1 -1
Index: linux/arch/ia64/oprofile/Makefile
===================================================================
@@ -6,5 +6,5 @@ DRIVER_OBJS := $(addprefix ../../../driv
 		oprofilefs.o oprofile_stats.o \
 		timer_int.o )
 
-oprofile-y := $(DRIVER_OBJS) init.o
+oprofile-y := $(DRIVER_OBJS) init.o backtrace.o
 oprofile-$(CONFIG_PERFMON) += perfmon.o
arch/ia64/kernel/ia64_ksyms.c +3 -0
Index: linux/arch/ia64/kernel/ia64_ksyms.c
===================================================================
@@ -122,3 +122,6 @@ EXPORT_SYMBOL(ia64_spinlock_contention);
 #  endif
 # endif
 #endif
+
+extern char ia64_ivt[];
+EXPORT_SYMBOL(ia64_ivt);
arch/ia64/oprofile/init.c +6 -4
Index: linux/arch/ia64/oprofile/init.c
===================================================================
@@ -12,15 +12,17 @@
 #include <linux/init.h>
 #include <linux/errno.h>
  
-extern int perfmon_init(struct oprofile_operations ** ops);
+extern int perfmon_init(struct oprofile_operations * ops);
 extern void perfmon_exit(void);
+extern void ia64_backtrace(struct pt_regs * const regs, unsigned int depth);
 
-int __init oprofile_arch_init(struct oprofile_operations ** ops)
+void __init oprofile_arch_init(struct oprofile_operations * ops)
 {
 #ifdef CONFIG_PERFMON
-	return perfmon_init(ops);
+	/* perfmon_init() can fail, but we have no way to report it */
+	perfmon_init(ops);
 #endif
-	return -ENODEV;
+	ops->backtrace = ia64_backtrace;
 }