Skip to contentSkip to conversation

LTT for 2.5.38 7/9: SuperH trace support

PATCH New Karim Yaghmour 1 participant 1 message Sep 22, 2002 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 LTT for 2.5.38 7/9: SuperH trace support

This patch adds SuperH trace support.

Here are the file modifications:

 arch/sh/config.in        |    3 +
 arch/sh/kernel/entry.S   |   43 ++++++++++++++++++++++++
 arch/sh/kernel/irq.c     |   14 ++++++++
 arch/sh/kernel/process.c |   13 ++++++-
 arch/sh/kernel/sys_sh.c  |    4 ++
 arch/sh/kernel/traps.c   |   82 +++++++++++++++++++++++++++++++++++++++++++++--
 arch/sh/mm/fault.c       |   15 ++++++++
 include/asm-sh/trace.h   |   15 ++++++++
 8 files changed, 186 insertions, 3 deletions  
arch/sh/config.in +3 -0
diff -urpN linux-2.5.38/arch/sh/config.in linux-2.5.38-ltt/arch/sh/config.in
@@ -358,6 +358,8 @@ if [ "$CONFIG_SOUND" != "n" ]; then
 fi
 endmenu
 
+source drivers/trace/Config.in
+
 mainmenu_option next_comment
 comment 'Kernel hacking'
 
@@ -366,6 +368,7 @@ bool 'Use LinuxSH standard BIOS' CONFIG_
 if [ "$CONFIG_SH_STANDARD_BIOS" = "y" ]; then
    bool 'Early printk support' CONFIG_SH_EARLY_PRINTK
 fi
+
 endmenu
 
 source security/Config.in
arch/sh/kernel/entry.S +43 -0

73 lines not on this page · raw message

arch/sh/kernel/irq.c +14 -0
diff -urpN linux-2.5.38/arch/sh/kernel/irq.c linux-2.5.38-ltt/arch/sh/kernel/irq.c
@@ -30,6 +30,8 @@
 #include <linux/init.h>
 #include <linux/seq_file.h>
 
+#include <linux/trace.h>
+
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/bitops.h>
@@ -127,6 +129,12 @@ int handle_IRQ_event(unsigned int irq, s
 
 	irq_enter(cpu, irq);
 
+#if (CONFIG_TRACE || CONFIG_TRACE_MODULE)
+    	if (irq != TIMER_IRQ) { /* avoid double-reporting the timer IRQ */
+		TRACE_IRQ_ENTRY(irq, !(user_mode(regs)));
+	}
+#endif
+
 	status = 1;	/* Force the "do bottom halves" bit */
 
 	if (!(action->flags & SA_INTERRUPT))
@@ -142,6 +150,12 @@ int handle_IRQ_event(unsigned int irq, s
 	local_irq_disable();
 
 	irq_exit(cpu, irq);
+
+#if (CONFIG_TRACE || CONFIG_TRACE_MODULE)
+    	if (irq != TIMER_IRQ) { /* avoid double-reporting the timer IRQ */
+		TRACE_IRQ_EXIT();
+	}
+#endif
 
 	return status;
 }
arch/sh/kernel/process.c +12 -1
diff -urpN linux-2.5.38/arch/sh/kernel/process.c linux-2.5.38-ltt/arch/sh/kernel/process.c
@@ -16,6 +16,8 @@
 #include <linux/slab.h>
 #include <linux/a.out.h>
 
+#include <linux/trace.h>
+
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
@@ -138,7 +140,16 @@ int kernel_thread(int (*fn)(void *), voi
 		: "i" (__NR_exit), "r" (__sc3), "r" (__sc4), "r" (__sc5), 
 		  "r" (__sc8), "r" (__sc9)
 		: "memory", "t");
-	return __sc0;
+#if (CONFIG_TRACE || CONFIG_TRACE_MODULE)
+	{
+		volatile unsigned long retval = __sc0;
+		if (retval > 0)
+			TRACE_PROCESS(TRACE_EV_PROCESS_KTHREAD, retval, (int) fn);
+		return retval;
+	}
+#else
+ 	return __sc0;
+#endif
 }
 
 /*
arch/sh/kernel/sys_sh.c +4 -0
diff -urpN linux-2.5.38/arch/sh/kernel/sys_sh.c linux-2.5.38-ltt/arch/sh/kernel/sys_sh.c
@@ -21,6 +21,8 @@
 #include <linux/file.h>
 #include <linux/utsname.h>
 
+#include <linux/trace.h>
+
 #include <asm/uaccess.h>
 #include <asm/ipc.h>
 
@@ -138,6 +140,8 @@ asmlinkage int sys_ipc(uint call, int fi
 
 	version = call >> 16; /* hack for backward compatibility */
 	call &= 0xffff;
+
+	TRACE_IPC(TRACE_EV_IPC_CALL, call, first);
 
 	if (call <= SEMCTL)
 		switch (call) {
arch/sh/kernel/traps.c +80 -2

116 lines not on this page · raw message

arch/sh/mm/fault.c +15 -0
diff -urpN linux-2.5.38/arch/sh/mm/fault.c linux-2.5.38-ltt/arch/sh/mm/fault.c
@@ -20,6 +20,8 @@
 #include <linux/smp_lock.h>
 #include <linux/interrupt.h>
 
+#include <linux/trace.h>
+
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -98,6 +100,14 @@ asmlinkage void do_page_fault(struct pt_
 	tsk = current;
 	mm = tsk->mm;
 
+#if (CONFIG_TRACE || CONFIG_TRACE_MODULE)
+	{
+		unsigned long trapnr;
+		asm volatile("stc       r2_bank,%0": "=r" (trapnr));
+		TRACE_TRAP_ENTRY(trapnr >> 5, regs->pc);  /* trap 4,5 or 6 */
+	}
+#endif
+
 	/*
 	 * If we're in an interrupt or have no user
 	 * context, we must not take the fault..
@@ -149,6 +159,7 @@ survive:
 	}
 
 	up_read(&mm->mmap_sem);
+	TRACE_TRAP_EXIT();
 	return;
 
 /*
@@ -162,6 +173,7 @@ bad_area:
 		tsk->thread.address = address;
 		tsk->thread.error_code = writeaccess;
 		force_sig(SIGSEGV, tsk);
+		TRACE_TRAP_EXIT();
 		return;
 	}
 
@@ -170,6 +182,7 @@ no_context:
 	fixup = search_exception_table(regs->pc);
 	if (fixup != 0) {
 		regs->pc = fixup;
+		TRACE_TRAP_EXIT();
 		return;
 	}
 
@@ -231,6 +244,8 @@ do_sigbus:
 	/* Kernel mode? Handle exceptions or die */
 	if (!user_mode(regs))
 		goto no_context;
+
+	TRACE_TRAP_EXIT();
 }
 
 /*
include/asm-sh/trace.h +15 -0
diff -urpN linux-2.5.38/include/asm-sh/trace.h linux-2.5.38-ltt/include/asm-sh/trace.h
@@ -0,0 +1,15 @@
+/*
+ * linux/include/asm-sh/trace.h
+ *
+ * Copyright (C) 2002, Karim Yaghmour
+ *
+ * SuperH definitions for tracing system
+ */
+
+#include <linux/trace.h>
+
+/* Current arch type */
+#define TRACE_ARCH_TYPE TRACE_ARCH_TYPE_SH
+
+/* Current variant type */
+#define TRACE_ARCH_VARIANT TRACE_ARCH_VARIANT_NONE