Skip to contentSkip to conversation

LTT for 2.5.43 10/10: ARM trace support

PATCH New Karim Yaghmour 1 participant 1 message Oct 18, 2002 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 LTT for 2.5.43 10/10: ARM trace support

D: This patch adds the bare-minimum ARM-specific low-level trace
D: statements.

Here are the file modifications:

 arch/arm/kernel/entry-common.S |   18 ++++++++
 arch/arm/kernel/irq.c          |    5 ++
 arch/arm/kernel/process.c      |    5 ++
 arch/arm/kernel/sys_arm.c      |    3 +
 arch/arm/kernel/traps.c        |   85 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/mm/fault-common.c     |   15 +++++--
 include/asm-arm/trace.h        |   16 +++++++
 7 files changed, 144 insertions(+), 3 deletions(-)

diff -urpN linux-2.5.43/arch/arm/kernel/entry-common.S linux-2.5.43-ltt/arch/arm/kernel/entry-common.S

arch/arm/kernel/entry-common.S +18 -0
@@ -35,6 +35,11 @@ ENTRY(__do_softirq)
  * stack.
  */
 ret_fast_syscall:
+#if (CONFIG_TRACE)
+	mov	r7, r0				@ save returned r0
+	bl	SYMBOL_NAME(trace_real_syscall_exit)
+	mov	r0, r7
+#endif
 	disable_irq r1				@ disable interrupts
 	ldr	r1, [tsk, #TI_FLAGS]
 	tst	r1, #_TIF_WORK_MASK
@@ -134,6 +139,16 @@ ENTRY(vector_swi)
 	mcr	p15, 0, ip, c1, c0		@ update control register
 #endif
 	enable_irq ip
+#if (CONFIG_TRACE)
+	/* zzz note that validity of scno is not yet checked.
+	 * zzz The visualizer checks it.
+	 */
+	add	r1, sp, #S_R0			@ pointer to regs
+	mov	r0, scno  		        @ syscall number
+	bl	SYMBOL_NAME(trace_real_syscall_entry)
+	add	r1, sp, #S_R0			@ pointer to regs
+	ldmia	r1, {r0 - r3}			@ have to reload r0 - r3
+#endif
 
 	str	r4, [sp, #-S_OFF]!		@ push fifth arg
 
@@ -174,6 +189,9 @@ __sys_trace:
 
 __sys_trace_return:
 	str	r0, [sp, #S_R0 + S_OFF]!	@ save returned r0
+#if (CONFIG_TRACE)
+	bl	SYMBOL_NAME(trace_real_syscall_exit)
+#endif
 	mov	r1, sp
 	mov	r0, #1				@ trace exit [IP = 1]
 	bl	syscall_trace
arch/arm/kernel/irq.c +5 -0
diff -urpN linux-2.5.43/arch/arm/kernel/irq.c linux-2.5.43-ltt/arch/arm/kernel/irq.c
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/seq_file.h>
 #include <linux/errno.h>
+#include <linux/trace.h>
 
 #include <asm/irq.h>
 #include <asm/system.h>
@@ -330,6 +331,8 @@ asmlinkage void asm_do_IRQ(int irq, stru
 {
 	struct irqdesc *desc = irq_desc + irq;
 
+	TRACE_IRQ_ENTRY(irq, !(user_mode(regs)));
+
 	/*
 	 * Some hardware gives randomly wrong interrupts.  Rather
 	 * than crashing, do something sensible.
@@ -342,6 +345,8 @@ asmlinkage void asm_do_IRQ(int irq, stru
 	desc->handle(irq, desc, regs);
 	spin_unlock(&irq_controller_lock);
 	irq_exit();
+
+	TRACE_IRQ_EXIT();
 }
 
 void __set_irq_handler(unsigned int irq, irq_handler_t handle, int is_chained)
arch/arm/kernel/process.c +5 -0
diff -urpN linux-2.5.43/arch/arm/kernel/process.c linux-2.5.43-ltt/arch/arm/kernel/process.c
@@ -24,6 +24,7 @@
 #include <linux/reboot.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/trace.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -405,6 +406,10 @@ pid_t kernel_thread(int (*fn)(void *), v
         : "=r" (__ret)
         : "Ir" (flags), "I" (CLONE_VM), "r" (fn), "r" (arg)
 	: "r0", "r1", "lr");
+#if (CONFIG_TRACE)
+	if (__ret > 0)
+		TRACE_PROCESS(TRACE_EV_PROCESS_KTHREAD, __ret, (int) fn);
+#endif
 	return __ret;
 }
 
arch/arm/kernel/sys_arm.c +3 -0
diff -urpN linux-2.5.43/arch/arm/kernel/sys_arm.c linux-2.5.43-ltt/arch/arm/kernel/sys_arm.c
@@ -24,6 +24,7 @@
 #include <linux/fs.h>
 #include <linux/file.h>
 #include <linux/utsname.h>
+#include <linux/trace.h>
 
 #include <asm/uaccess.h>
 #include <asm/ipc.h>
@@ -167,6 +168,8 @@ asmlinkage int sys_ipc (uint call, int f
 	version = call >> 16; /* hack for backward compatibility */
 	call &= 0xffff;
 
+	TRACE_IPC(TRACE_EV_IPC_CALL, call, first);
+
 	switch (call) {
 	case SEMOP:
 		return sys_semop (first, (struct sembuf *)ptr, second);
arch/arm/kernel/traps.c +85 -0

127 lines not on this page · raw message

arch/arm/mm/fault-common.c +12 -3
diff -urpN linux-2.5.43/arch/arm/mm/fault-common.c linux-2.5.43-ltt/arch/arm/mm/fault-common.c
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/proc_fs.h>
 #include <linux/init.h>
+#include <linux/trace.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
@@ -253,6 +254,8 @@ int do_page_fault(unsigned long addr, un
 	if (in_interrupt() || !mm)
 		goto no_context;
 
+	TRACE_TRAP_ENTRY(14, instruction_pointer(regs));
+
 	down_read(&mm->mmap_sem);
 	fault = __do_page_fault(mm, addr, fsr, tsk);
 	up_read(&mm->mmap_sem);
@@ -260,8 +263,10 @@ int do_page_fault(unsigned long addr, un
 	/*
 	 * Handle the "normal" case first
 	 */
-	if (fault > 0)
-		return 0;
+	if (fault > 0) {
+		TRACE_TRAP_EXIT();
+ 		return 0;
+	}
 
 	/*
 	 * We had some memory, but were unable to
@@ -287,6 +292,7 @@ int do_page_fault(unsigned long addr, un
 	} else
 		__do_user_fault(tsk, addr, fsr, fault == -1 ?
 				SEGV_ACCERR : SEGV_MAPERR, regs);
+	TRACE_TRAP_EXIT();
 	return 0;
 
 
@@ -309,11 +315,14 @@ do_sigbus:
 #endif
 
 	/* Kernel mode? Handle exceptions or die */
-	if (user_mode(regs))
+	if (user_mode(regs)) {
+		TRACE_TRAP_EXIT();
 		return 0;
+	}
 
 no_context:
 	__do_kernel_fault(mm, addr, fsr, regs);
+	TRACE_TRAP_EXIT();
 	return 0;
 }
 
include/asm-arm/trace.h +16 -0
diff -urpN linux-2.5.43/include/asm-arm/trace.h linux-2.5.43-ltt/include/asm-arm/trace.h
@@ -0,0 +1,16 @@
+/*
+ * linux/include/asm-arm/trace.h
+ *
+ * Copyright (C) 2002, Karim Yaghmour
+ *
+ * ARM definitions for tracing system
+ */
+
+#include <linux/trace.h>
+#include <asm-generic/trace.h>
+
+/* Current arch type */
+#define TRACE_ARCH_TYPE TRACE_ARCH_TYPE_ARM
+
+/* Current variant type */
+#define TRACE_ARCH_VARIANT TRACE_ARCH_VARIANT_NONE