4/8 LTT for 2.5.33: i386 trace support
PATCH 1/1 4/8 LTT for 2.5.33: i386 trace support
This patch adds the trace support for the i386. Here are the files modified:arch/i386/config.inarch/i386/kernel/entry.Sarch/i386/kernel/irq.carch/i386/kernel/process.carch/i386/kernel/sys_i386.carch/i386/kernel/traps.carch/i386/mm/fault.cinclude/asm-i386/trace.h
Contrary to previous versions, this patch does not make unconditional calls to the tracing functions in entry.S. Instead, the system call/exit tracing functions are called only when these events are traced. The cost for fast-path system calls becomes negligeable with this addition.
arch/i386/config.in +2 -0
@@ -399,6 +399,8 @@ source net/bluetooth/Config.in +source drivers/trace/Config.in + mainmenu_option next_comment comment 'Kernel hacking' if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
arch/i386/kernel/entry.S +18 -0
@@ -233,9 +233,27 @@ testb $_TIF_SYSCALL_TRACE,TI_FLAGS(%ebx) jnz syscall_trace_entry syscall_call: +#if (CONFIG_TRACE || CONFIG_TRACE_MODULE) + 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 || CONFIG_TRACE_MODULE) + 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
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 status =1 ;/* Force the "do bottom halves" bit */ +TRACE_IRQ_ENTRY (irq, !(user_mode (regs))); +if (!(action->flags &SA_INTERRUPT ))local_irq_enable ();
@@ -213,6 +217,8 @@if (status &SA_SAMPLE_RANDOM )add_interrupt_randomness (irq);local_irq_disable (); + +TRACE_IRQ_EXIT ();return status; }
arch/i386/kernel/process.c +6 -0
@@ -34,6 +34,8 @@#include <linux/init.h> #include <linux/mc146818rtc.h> +#include <linux/trace.h> +#include <asm/uaccess.h> #include <asm/pgtable.h> #include <asm/system.h>
@@ -505,6 +507,10 @@/* Ok, create the new process.. */ p =do_fork (flags |CLONE_VM ,0 , ®s,0 ,NULL ); +#if (CONFIG_TRACE ||CONFIG_TRACE_MODULE ) +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>
@@ -136,6 +138,8 @@ version = call >>16 ;/* hack for backward compatibility */ call &=0xffff ; + +TRACE_IPC (TRACE_EV_IPC_CALL , call, first);switch (call) {case SEMOP :
arch/i386/kernel/traps.c +105 -1
215 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>
@@ -180,6 +182,8 @@ 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..
@@ -264,6 +268,7 @@ tsk->thread.screen_bitmap |=1 << bit; }up_read (&mm->mmap_sem); +TRACE_TRAP_EXIT ();return ;/*
@@ -283,6 +288,7 @@/* info.si_code has been set above */ info.si_addr = (void *)address;force_sig_info (SIGSEGV , &info, tsk); +TRACE_TRAP_EXIT ();return ; }
@@ -297,6 +303,7 @@if (nr ==6 ) {do_invalid_op (regs,0 ); +TRACE_TRAP_EXIT ();return ; } }
@@ -306,6 +313,7 @@/* Are we prepared to handle this kernel fault? */ if ((fixup =search_exception_table (regs->eip)) !=0 ) { regs->eip = fixup; +TRACE_TRAP_EXIT ();return ; }
@@ -379,6 +387,7 @@/* Kernel mode? Handle exceptions or die */ if (!(error_code &4 )) goto no_context; +TRACE_TRAP_EXIT ();return ; vmalloc_fault:
@@ -412,6 +421,8 @@ 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 +15 -0
@@ -0,0 +1,15 @@ +/* +* linux/include/asm-i386/trace.h +* +* Copyright (C) 2002, Karim Yaghmour +* +* i386 definitions for tracing system +*/ + +#include <linux/trace.h> + +/* Current arch type */ +#define TRACE_ARCH_TYPE TRACE_ARCH_TYPE_I386 + +/* Current variant type */ +#define TRACE_ARCH_VARIANT TRACE_ARCH_VARIANT_NONE