Re: LTTng for ST40 kernel 2.6.23.1
"Giuseppe Cavallaro" <[email protected]> Wed, 31 Oct 2007 10:40:32 +0100
| Newsgroups | gmane.linux.kernel.tracing |
|---|---|
| Message-ID | <[email protected]> |
I've also reviewed the ltt-instrumentation-sh.patch (attached) in order to fix the format mismatch for probe kernel_trap_entry. On 31/10/2007, Giuseppe Cavallaro <[email protected]> wrote: > > Mathieu, > I've seen the TSC within ltt-heartbeat.c has been removed. > So the build fails because the ltt_heartbeat_read_synthetic_tsc (used in > the asm/ltt.h:ltt_get_timestamp64) is undefined. > Is it voluntary or we need to restore missing functions? > I guess the same issue ought to be for mips as well. > If I well remember, we need to use Synthetic TSC in order to detect 32 > bits counter overflows and extend it to a 64 bits counter. > Let me know, > Thanks, > Giuseppe > > On 30/10/2007, Mathieu Desnoyers <[email protected]> wrote: > > > > * Giuseppe Cavallaro ([email protected]) wrote: > > > Hi Mathieu, > > > I've applied LTTng (0.10.0-pre7) against the STLinux kernel > > > 2.6.23.1<http://2.6.23.1>(for SH4 architecture). > > > I've had to add the ltt_add_timestamp function (patch attached) in > > order to > > > build kernel/timer.c. > > > I'm going to start testing LTTng on my target... so I'll let you know! > > > > > > > > > Forget about my last email.. all this is already in the LTTng patchset, > > except ltt_add_timestamp, as you explained. > > > > Thanks, > > > > Mathieu > > > > > Regards, > > > Giuseppe > > > > > This patch adds the timestamping mechanism in the ltt.h arch header > > file. > > > The new timestamp functions use the TMU channel 1. > > > > > > This code only works if the TMU channel 1 is initialized during the > > kernel boot > > > > > > From: Giuseppe Cavallaro < [email protected]> > > > Signed-off-by: Giuseppe Cavallaro <[email protected]> > > > Signed-off-by: Mathieu Desnoyers < [email protected]> > > > > > > --- /dev/null 2007-10-24 15:55:45.303163180 +0200 > > > +++ linux-2.6.23.1/include/asm-sh/ltt.h 2007-10-29 22:54: > > 22.000000000 +0100 > > > @@ -0,0 +1,48 @@ > > > +/* > > > + * Copyright (C) 2007, Giuseppe Cavallaro <[email protected]> > > > + * Mathieu Desnoyers < > > [email protected]> > > > + * > > > + * SuperH definitions for tracing system > > > + */ > > > + > > > +#ifndef _ASM_SH_LTT_H > > > +#define _ASM_SH_LTT_H > > > + > > > +#include <linux/ltt-core.h> > > > +#include <asm/timer.h> > > > +#include <asm/clock.h> > > > + > > > +#define LTT_HAS_TSC > > > + > > > +u64 ltt_heartbeat_read_synthetic_tsc(void); > > > + > > > +static inline u32 ltt_get_timestamp32(void) > > > +{ > > > + return get_cycles(); > > > +} > > > + > > > +static inline u64 ltt_get_timestamp64(void) > > > +{ > > > + return ltt_heartbeat_read_synthetic_tsc(); > > > +} > > > + > > > +static inline void ltt_add_timestamp(unsigned long ticks) > > > +{ } > > > + > > > +static inline unsigned int ltt_frequency(void) > > > +{ > > > + unsigned long rate; > > > + struct clk *tmu1_clk; > > > + > > > + tmu1_clk = clk_get(NULL, "tmu1_clk"); > > > + rate = (clk_get_rate(tmu1_clk)); > > > + > > > + return (unsigned int)(rate); > > > +} > > > + > > > +static inline u32 ltt_freq_scale(void) > > > +{ > > > + return 1; > > > +} > > > + > > > +#endif /* _ASM_SH_LTT_H */ > > > --- linux-2.6.23.1/include/asm-sh/timex.h.orig 2007-10-29 > > 22:53:50.000000000 +0100 > > > +++ linux-2.6.23.1/include/asm-sh/timex.h 2007-10-29 22:54: > > 14.000000000 +0100 > > > @@ -5,13 +5,20 @@ > > > */ > > > #ifndef __ASM_SH_TIMEX_H > > > #define __ASM_SH_TIMEX_H > > > +#ifdef CONFIG_LTT > > > +#include <asm/cpu/timer.h> > > > +#include <asm/io.h> > > > +#endif > > > > > > -#define CLOCK_TICK_RATE (CONFIG_SH_PCLK_FREQ / 4) /* > > Underlying HZ */ > > > +#define CLOCK_TICK_RATE (HZ * 100000UL) > > > > > > typedef unsigned long long cycles_t; > > > > > > static __inline__ cycles_t get_cycles (void) > > > { > > > +#ifdef CONFIG_LTT > > > + return (0xffffffff - ctrl_inl(TMU1_TCNT)); > > > +#endif > > > return 0; > > > } > > > > > > > > _______________________________________________ > > > Ltt-dev mailing list > > > [email protected] > > > http://listserv.shafik.org/mailman/listinfo/ltt-dev > > > > > > -- > > Mathieu Desnoyers > > Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal > > OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE > > 9A68 > > > > _______________________________________________ Ltt-dev mailing list [email protected] http://listserv.shafik.org/mailman/listinfo/ltt-dev
lttng-instrumentation-sh.patch
(text/x-diff, 6 KB)
---
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, 40 insertions(+), 7 deletions(-)
Index: linux-2.6-lttng/arch/sh/kernel/entry-common.S
===================================================================
--- linux-2.6-lttng.orig/arch/sh/kernel/entry-common.S 2007-10-11 14:46:08.000000000 -0400
+++ linux-2.6-lttng/arch/sh/kernel/entry-common.S 2007-10-11 15:02:15.000000000 -0400
@@ -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-10-11 14:46:08.000000000 -0400
+++ linux-2.6-lttng/arch/sh/kernel/process.c 2007-10-11 15:02:32.000000000 -0400
@@ -171,6 +171,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(®s, 0, sizeof(regs));
@@ -183,6 +184,10 @@ int kernel_thread(int (*fn)(void *), voi
/* Ok, create the new process.. */
return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
®s, 0, NULL, NULL);
+ pid = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
+ ®s, 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-10-11 14:46:08.000000000 -0400
+++ linux-2.6-lttng/arch/sh/kernel/sys_sh.c 2007-10-11 15:03:15.000000000 -0400
@@ -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-10-11 14:46:08.000000000 -0400
+++ linux-2.6-lttng/arch/sh/kernel/traps.c 2007-10-11 15:03:42.000000000 -0400
@@ -544,6 +544,9 @@ asmlinkage void do_address_error(struct
lookup_exception_vector(error_code);
#endif
+ trace_mark(kernel_trap_entry, "trap_id %ld ip #p%ld",
+ (error_code >> 5), instruction_pointer(regs));
+
oldfs = get_fs();
if (user_mode(regs)) {
@@ -570,8 +573,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_trap_exit, MARK_NOARGS);
+ return; /* sorted */
+ }
#endif
uspace_segv:
@@ -607,6 +612,7 @@ uspace_segv:
force_sig(SIGSEGV, current);
#endif
}
+ trace_mark(kernel_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-10-11 14:46:08.000000000 -0400
+++ linux-2.6-lttng/arch/sh/mm/fault.c 2007-10-11 15:04:52.000000000 -0400
@@ -81,6 +81,14 @@ asmlinkage void __kprobes do_page_fault(
return;
}
+ trace_mark(kernel_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..
@@ -133,6 +141,7 @@ survive:
tsk->min_flt++;
up_read(&mm->mmap_sem);
+ trace_mark(kernel_trap_exit, MARK_NOARGS);
return;
/*
@@ -149,6 +158,7 @@ bad_area_nosemaphore:
info.si_code = si_code;
info.si_addr = (void *) address;
force_sig_info(SIGSEGV, &info, tsk);
+ trace_mark(kernel_trap_exit, MARK_NOARGS);
return;
}
@@ -228,6 +238,8 @@ do_sigbus:
/* Kernel mode? Handle exceptions or die */
if (!user_mode(regs))
goto no_context;
+
+ trace_mark(kernel_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-10-11 14:46:08.000000000 -0400
+++ linux-2.6-lttng/arch/sh/kernel/ptrace.c 2007-10-11 15:02:56.000000000 -0400
@@ -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;