All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: akpm@linux-foundation.org, Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Subject: [patch-early-RFC 06/10] LTTng - instrumentation SH
Date: Wed, 05 Dec 2007 21:56:56 -0500	[thread overview]
Message-ID: <20071206025947.168583114@polymtl.ca> (raw)
In-Reply-To: 20071206025650.451824066@polymtl.ca

[-- Attachment #1: lttng-instrumentation-sh.patch --]
[-- Type: text/plain, Size: 6444 bytes --]

Changelog:
- fix do_fork instrumentation

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
 arch/sh/kernel/entry-common.S |   10 ++++++----
 arch/sh/kernel/process.c      |    5 ++++-
 arch/sh/kernel/ptrace.c       |    8 +++++++-
 arch/sh/kernel/sys_sh.c       |    2 ++
 arch/sh/kernel/traps.c        |   10 ++++++++--
 arch/sh/mm/fault.c            |   12 ++++++++++++
 6 files changed, 39 insertions(+), 8 deletions(-)

Index: linux-2.6-lttng/arch/sh/kernel/entry-common.S
===================================================================
--- linux-2.6-lttng.orig/arch/sh/kernel/entry-common.S	2007-11-26 13:36:40.000000000 -0500
+++ linux-2.6-lttng/arch/sh/kernel/entry-common.S	2007-11-26 13:37:12.000000000 -0500
@@ -224,7 +224,7 @@ work_resched:
 syscall_exit_work:
 	! r0: current_thread_info->flags
 	! r8: current_thread_info
-	tst	#_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP, r0
+	tst	#_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | _TIF_KERNEL_TRACE, r0
 	bt/s	work_pending
 	 tst	#_TIF_NEED_RESCHED, r0
 #ifdef CONFIG_TRACE_IRQFLAGS
@@ -233,7 +233,8 @@ syscall_exit_work:
 	 nop
 #endif
 	sti
-	! XXX setup arguments...
+	mov	r15,r4			! pass stacked regs as arg
+	mov	#0, r5			! trace entry [0]
 	mov.l	4f, r0			! do_syscall_trace
 	jsr	@r0
 	 nop
@@ -243,7 +244,8 @@ syscall_exit_work:
 	.align	2
 syscall_trace_entry:
 	!                     	Yes it is traced.
-	! XXX setup arguments...
+	mov	r15,r4		! pass stacked regs as arg
+	mov	#1, r5		! trace entry [1]
 	mov.l	4f, r11		! Call do_syscall_trace which notifies
 	jsr	@r11	    	! superior (will chomp R[0-7])
 	 nop
@@ -366,7 +368,7 @@ ENTRY(system_call)
 	!
 	get_current_thread_info r8, r10
 	mov.l	@(TI_FLAGS,r8), r8
-	mov	#_TIF_SYSCALL_TRACE, r10
+	mov	#(_TIF_SYSCALL_TRACE | _TIF_KERNEL_TRACE), r10
 	tst	r10, r8
 	bf	syscall_trace_entry
 	!
Index: linux-2.6-lttng/arch/sh/kernel/process.c
===================================================================
--- linux-2.6-lttng.orig/arch/sh/kernel/process.c	2007-11-26 13:36:40.000000000 -0500
+++ linux-2.6-lttng/arch/sh/kernel/process.c	2007-11-28 08:29:11.000000000 -0500
@@ -172,6 +172,7 @@ __asm__(".align 5\n"
 /* Don't use this in BL=1(cli).  Or else, CPU resets! */
 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
 {
+	unsigned long pid;
 	struct pt_regs regs;
 
 	memset(&regs, 0, sizeof(regs));
@@ -182,8 +183,10 @@ int kernel_thread(int (*fn)(void *), voi
 	regs.sr = (1 << 30);
 
 	/* Ok, create the new process.. */
-	return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
+	pid =  do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
 		       &regs, 0, NULL, NULL);
+	trace_mark(kernel_arch_kthread_create, "pid %ld fn %p", pid, fn);
+	return pid;
 }
 
 /*
Index: linux-2.6-lttng/arch/sh/kernel/sys_sh.c
===================================================================
--- linux-2.6-lttng.orig/arch/sh/kernel/sys_sh.c	2007-11-26 13:36:40.000000000 -0500
+++ linux-2.6-lttng/arch/sh/kernel/sys_sh.c	2007-11-26 13:37:12.000000000 -0500
@@ -192,6 +192,8 @@ asmlinkage int sys_ipc(uint call, int fi
 	version = call >> 16; /* hack for backward compatibility */
 	call &= 0xffff;
 
+	trace_mark(kernel_arch_ipc_call, "call %u first %d", call, first);
+
 	if (call <= SEMCTL)
 		switch (call) {
 		case SEMOP:
Index: linux-2.6-lttng/arch/sh/kernel/traps.c
===================================================================
--- linux-2.6-lttng.orig/arch/sh/kernel/traps.c	2007-11-26 13:36:40.000000000 -0500
+++ linux-2.6-lttng/arch/sh/kernel/traps.c	2007-11-26 13:37:12.000000000 -0500
@@ -548,6 +548,9 @@ asmlinkage void do_address_error(struct 
 	lookup_exception_vector(error_code);
 #endif
 
+	trace_mark(kernel_arch_trap_entry, "trap_id %lu ip #p%ld",
+		(error_code >> 5), instruction_pointer(regs));
+
 	oldfs = get_fs();
 
 	if (user_mode(regs)) {
@@ -574,8 +577,10 @@ asmlinkage void do_address_error(struct 
 		tmp = handle_unaligned_access(instruction, regs);
 		set_fs(oldfs);
 
-		if (tmp==0)
-			return; /* sorted */
+		if (tmp==0) {
+			trace_mark(kernel_arch_trap_exit, MARK_NOARGS);
+ 			return; /* sorted */
+		}
 #endif
 
 uspace_segv:
@@ -611,6 +616,7 @@ uspace_segv:
 		force_sig(SIGSEGV, current);
 #endif
 	}
+	trace_mark(kernel_arch_trap_exit, MARK_NOARGS);
 }
 
 #ifdef CONFIG_SH_DSP
Index: linux-2.6-lttng/arch/sh/mm/fault.c
===================================================================
--- linux-2.6-lttng.orig/arch/sh/mm/fault.c	2007-11-26 13:36:40.000000000 -0500
+++ linux-2.6-lttng/arch/sh/mm/fault.c	2007-11-26 13:37:12.000000000 -0500
@@ -87,6 +87,14 @@ asmlinkage void __kprobes do_page_fault(
 		return;
 	}
 
+	trace_mark(kernel_arch_trap_entry, "trap_id %ld ip #p%ld",
+		({
+			unsigned long trapnr;
+			asm volatile("stc	r2_bank,%0": "=r" (trapnr));
+			trapnr;
+		}) >> 5,
+		instruction_pointer(regs));
+
 	/*
 	 * If we're in an interrupt or have no user
 	 * context, we must not take the fault..
@@ -139,6 +147,7 @@ survive:
 		tsk->min_flt++;
 
 	up_read(&mm->mmap_sem);
+	trace_mark(kernel_arch_trap_exit, MARK_NOARGS);
 	return;
 
 /*
@@ -155,6 +164,7 @@ bad_area_nosemaphore:
 		info.si_code = si_code;
 		info.si_addr = (void *) address;
 		force_sig_info(SIGSEGV, &info, tsk);
+		trace_mark(kernel_arch_trap_exit, MARK_NOARGS);
 		return;
 	}
 
@@ -233,6 +243,8 @@ do_sigbus:
 	/* Kernel mode? Handle exceptions or die */
 	if (!user_mode(regs))
 		goto no_context;
+
+	trace_mark(kernel_arch_trap_exit, MARK_NOARGS);
 }
 
 #ifdef CONFIG_SH_STORE_QUEUES
Index: linux-2.6-lttng/arch/sh/kernel/ptrace.c
===================================================================
--- linux-2.6-lttng.orig/arch/sh/kernel/ptrace.c	2007-11-26 13:36:40.000000000 -0500
+++ linux-2.6-lttng/arch/sh/kernel/ptrace.c	2007-11-26 13:37:12.000000000 -0500
@@ -248,10 +248,16 @@ long arch_ptrace(struct task_struct *chi
 	return ret;
 }
 
-asmlinkage void do_syscall_trace(void)
+asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
 {
 	struct task_struct *tsk = current;
 
+	if (entryexit)
+		trace_mark(kernel_arch_syscall_entry, "syscall_id %d ip #p%ld",
+			regs->regs[3], instruction_pointer(regs));
+	else
+		trace_mark(kernel_arch_syscall_exit, MARK_NOARGS);
+
 	if (!test_thread_flag(TIF_SYSCALL_TRACE) &&
 	    !test_thread_flag(TIF_SINGLESTEP))
 		return;

-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

  parent reply	other threads:[~2007-12-06  3:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-06  2:56 [patch-early-RFC 00/10] LTTng architecture dependent instrumentation Mathieu Desnoyers
2007-12-06  2:56 ` [patch-early-RFC 01/10] LTTng - ARM instrumentation Mathieu Desnoyers
2007-12-06  2:56 ` [patch-early-RFC 02/10] LTTng - x86_32 instrumentation Mathieu Desnoyers
2007-12-06  2:56 ` [patch-early-RFC 03/10] LTTng - MIPS instrumentation Mathieu Desnoyers
2007-12-06  2:56 ` [patch-early-RFC 04/10] LTTng instrumentation Powerpc Mathieu Desnoyers
2007-12-06  2:56 ` [patch-early-RFC 05/10] LTTng instrumentation PPC Mathieu Desnoyers
2007-12-06  2:56 ` Mathieu Desnoyers [this message]
2007-12-06  2:56 ` [patch-early-RFC 07/10] LTTng instrumentation SH64 Mathieu Desnoyers
2007-12-06  2:56 ` [patch-early-RFC 08/10] LTTng Sparc instrumentation Mathieu Desnoyers
2007-12-06  2:56 ` [patch-early-RFC 09/10] LTTng - x86_64 instrumentation Mathieu Desnoyers
2007-12-06  2:57 ` [patch-early-RFC 10/10] LTTng - s390 instrumentation Mathieu Desnoyers
2007-12-06 10:11 ` [patch-early-RFC 00/10] LTTng architecture dependent instrumentation Ingo Molnar
2007-12-06 14:19   ` Mathieu Desnoyers
2007-12-08 19:05   ` Mathieu Desnoyers
2007-12-10  0:28     ` Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071206025947.168583114@polymtl.ca \
    --to=mathieu.desnoyers@polymtl.ca \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.