LTT for 2.5.44-bk2 5/10: i386 trace support
PATCH 1/1 LTT for 2.5.44-bk2 5/10: i386 trace support
D: This patch adds the bare-minimum i386-specific low-level trace
D: statements.
diffstat:
arch/i386/kernel/entry.S | 23 +++++++ arch/i386/kernel/irq.c | 6 ++ arch/i386/kernel/process.c | 5 + arch/i386/kernel/sys_i386.c | 4 + arch/i386/kernel/traps.c | 104 ++++++++++++++++++++++++++++++++++ arch/i386/mm/fault.c | 11 +++ include/asm-i386/trace.h | 131 ++++++++++++++++++++++++++++++++++++++++++++ include/asm-i386/unistd.h | 1 8 files changed, 284 insertions(+), 1 deletion(-)
arch/i386/kernel/entry.S +23 -0
@@ -233,9 +233,27 @@ ENTRY(system_call) testb $_TIF_SYSCALL_TRACE,TI_FLAGS(%ebx) jnz syscall_trace_entry syscall_call: +#if (CONFIG_TRACE) + movl syscall_entry_trace_active, %eax + cmpl $1, %eax # are we tracing system call entries + jne no_syscall_entry_trace + movl %esp, %eax # copy the stack pointer + pushl %eax # pass the stack pointer copy + call trace_real_syscall_entry + addl $4,%esp # return stack to state before pass +no_syscall_entry_trace: + movl ORIG_EAX(%esp),%eax # restore eax to it's original content +#endif call *sys_call_table(,%eax,4) movl %eax,EAX(%esp) # store the return value syscall_exit: +#if (CONFIG_TRACE) + movl syscall_exit_trace_active, %eax + cmpl $1, %eax # are we tracing system call exits + jne no_syscall_exit_trace + call trace_real_syscall_exit +no_syscall_exit_trace: +#endif cli # make sure we don't miss an interrupt # setting need_resched or sigpending # between sampling and the iret
@@ -737,6 +755,11 @@ ENTRY(sys_call_table) .long sys_free_hugepages .long sys_exit_group .long sys_lookup_dcookie +#if CONFIG_TRACE + .long sys_trace +#else + .long sys_ni_syscall +#endif .rept NR_syscalls-(.-sys_call_table)/4 .long sys_ni_syscall
arch/i386/kernel/irq.c +6 -0
@@ -33,6 +33,8 @@#include <linux/proc_fs.h> #include <linux/seq_file.h> +#include <linux/trace.h> +#include <asm/atomic.h> #include <asm/io.h> #include <asm/smp.h>
@@ -202,6 +204,8 @@ int handle_IRQ_event(unsigned int irq, s {int status =1 ;/* Force the "do bottom halves" bit */ +TRACE_IRQ_ENTRY (irq, !(user_mode (regs))); +if (!(action->flags &SA_INTERRUPT ))local_irq_enable ();
@@ -214,6 +218,8 @@ int handle_IRQ_event(unsigned int irq, sadd_interrupt_randomness (irq);local_irq_disable (); +TRACE_IRQ_EXIT (); +return status; }
arch/i386/kernel/process.c +5 -0
@@ -34,6 +34,7 @@#include <linux/init.h> #include <linux/mc146818rtc.h> #include <linux/module.h> +#include <linux/trace.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
@@ -225,6 +226,10 @@ int kernel_thread(int (*fn)(void *), voi/* Ok, create the new process.. */ p =do_fork (flags |CLONE_VM ,0 , ®s,0 ,NULL ); +#if (CONFIG_TRACE ) +if (!IS_ERR (p)) +TRACE_PROCESS (TRACE_EV_PROCESS_KTHREAD , p->pid, (int ) fn); +#endif return IS_ERR (p) ?PTR_ERR (p) : p->pid; }
arch/i386/kernel/sys_i386.c +4 -0
@@ -19,6 +19,8 @@#include <linux/file.h> #include <linux/utsname.h> +#include <linux/trace.h> +#include <asm/uaccess.h> #include <asm/ipc.h>
@@ -137,6 +139,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/i386/kernel/traps.c +103 -1
209 lines not on this page · raw message
arch/i386/mm/fault.c +11 -0
@@ -20,6 +20,8 @@#include <linux/tty.h> #include <linux/vt_kern.h> /* For unblank_screen() */ +#include <linux/trace.h> +#include <asm/system.h> #include <asm/uaccess.h> #include <asm/pgalloc.h>
@@ -176,6 +178,8 @@ asmlinkage void do_page_fault(struct pt_ mm = tsk->mm; info.si_code =SEGV_MAPERR ; +TRACE_TRAP_ENTRY (14 , regs->eip); +/* * If we're in an interrupt, have no user context or are running in an * atomic region then we must not take the fault..
@@ -260,6 +264,7 @@ good_area: tsk->thread.screen_bitmap |=1 << bit; }up_read (&mm->mmap_sem); +TRACE_TRAP_EXIT ();return ;/*
@@ -279,6 +284,7 @@ bad_area:/* info.si_code has been set above */ info.si_addr = (void *)address;force_sig_info (SIGSEGV , &info, tsk); +TRACE_TRAP_EXIT ();return ; }
@@ -293,6 +299,7 @@ bad_area:if (nr ==6 ) {do_invalid_op (regs,0 ); +TRACE_TRAP_EXIT ();return ; } }
@@ -302,6 +309,7 @@ no_context:/* Are we prepared to handle this kernel fault? */ if ((fixup =search_exception_table (regs->eip)) !=0 ) { regs->eip = fixup; +TRACE_TRAP_EXIT ();return ; }
@@ -375,6 +383,7 @@ do_sigbus:/* Kernel mode? Handle exceptions or die */ if (!(error_code &4 )) goto no_context; +TRACE_TRAP_EXIT ();return ; vmalloc_fault:
@@ -408,6 +417,8 @@ vmalloc_fault: pte_k =pte_offset_kernel (pmd_k, address);if (!pte_present (*pte_k)) goto no_context; +TRACE_TRAP_EXIT ();return ; } +TRACE_TRAP_EXIT (); }
include/asm-i386/trace.h +131 -0
131 lines not on this page · raw message
include/asm-i386/unistd.h +1 -0
@@ -258,6 +258,7 @@#define __NR_free_hugepages 251#define __NR_exit_group 252#define __NR_lookup_dcookie 253 +#define __NR_trace 254/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */