diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-11-12 04:17:09 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-11-12 04:17:09 -0500 |
| commit | 60a011c736e7dd09a0b01ca6a051a416f3f52ffb (patch) | |
| tree | 20e91db58c3bbfa622d3ed8ec747e4974a807284 | |
| parent | d06bbd669539215405874d8fe32ab65105e6c4bb (diff) | |
| parent | 19b3e9671c5a219b8c34da2cc66e0ce7c3a501ae (diff) | |
Merge branch 'tracing/function-return-tracer' into tracing/fastboot
| -rw-r--r-- | arch/x86/Kconfig | 1 | ||||
| -rw-r--r-- | arch/x86/include/asm/ftrace.h | 26 | ||||
| -rw-r--r-- | arch/x86/include/asm/thread_info.h | 24 | ||||
| -rw-r--r-- | arch/x86/kernel/Makefile | 6 | ||||
| -rw-r--r-- | arch/x86/kernel/entry_32.S | 33 | ||||
| -rw-r--r-- | arch/x86/kernel/ftrace.c | 182 | ||||
| -rw-r--r-- | include/linux/ftrace.h | 20 | ||||
| -rw-r--r-- | include/linux/ftrace_irq.h | 2 | ||||
| -rw-r--r-- | include/linux/sched.h | 11 | ||||
| -rw-r--r-- | kernel/Makefile | 4 | ||||
| -rw-r--r-- | kernel/trace/Kconfig | 14 | ||||
| -rw-r--r-- | kernel/trace/Makefile | 1 | ||||
| -rw-r--r-- | kernel/trace/ftrace.c | 16 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 65 | ||||
| -rw-r--r-- | kernel/trace/trace.h | 35 | ||||
| -rw-r--r-- | kernel/trace/trace_functions_return.c | 82 |
16 files changed, 506 insertions, 16 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 6ab097fd5241..7780cc8b51d1 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -29,6 +29,7 @@ config X86 | |||
| 29 | select HAVE_FTRACE_MCOUNT_RECORD | 29 | select HAVE_FTRACE_MCOUNT_RECORD |
| 30 | select HAVE_DYNAMIC_FTRACE | 30 | select HAVE_DYNAMIC_FTRACE |
| 31 | select HAVE_FUNCTION_TRACER | 31 | select HAVE_FUNCTION_TRACER |
| 32 | select HAVE_FUNCTION_RET_TRACER if X86_32 | ||
| 32 | select HAVE_FUNCTION_TRACE_MCOUNT_TEST | 33 | select HAVE_FUNCTION_TRACE_MCOUNT_TEST |
| 33 | select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) | 34 | select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) |
| 34 | select HAVE_ARCH_KGDB if !X86_VOYAGER | 35 | select HAVE_ARCH_KGDB if !X86_VOYAGER |
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h index f8173ed1c970..9b6a1fa19e70 100644 --- a/arch/x86/include/asm/ftrace.h +++ b/arch/x86/include/asm/ftrace.h | |||
| @@ -20,4 +20,30 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) | |||
| 20 | #endif /* __ASSEMBLY__ */ | 20 | #endif /* __ASSEMBLY__ */ |
| 21 | #endif /* CONFIG_FUNCTION_TRACER */ | 21 | #endif /* CONFIG_FUNCTION_TRACER */ |
| 22 | 22 | ||
| 23 | #ifdef CONFIG_FUNCTION_RET_TRACER | ||
| 24 | #define FTRACE_RET_STACK_SIZE 20 | ||
| 25 | |||
| 26 | #ifndef __ASSEMBLY__ | ||
| 27 | |||
| 28 | /* | ||
| 29 | * Stack of return addresses for functions | ||
| 30 | * of a thread. | ||
| 31 | * Used in struct thread_info | ||
| 32 | */ | ||
| 33 | struct ftrace_ret_stack { | ||
| 34 | unsigned long ret; | ||
| 35 | unsigned long func; | ||
| 36 | unsigned long long calltime; | ||
| 37 | }; | ||
| 38 | |||
| 39 | /* | ||
| 40 | * Primary handler of a function return. | ||
| 41 | * It relays on ftrace_return_to_handler. | ||
| 42 | * Defined in entry32.S | ||
| 43 | */ | ||
| 44 | extern void return_to_handler(void); | ||
| 45 | |||
| 46 | #endif /* __ASSEMBLY__ */ | ||
| 47 | #endif /* CONFIG_FUNCTION_RET_TRACER */ | ||
| 48 | |||
| 23 | #endif /* _ASM_X86_FTRACE_H */ | 49 | #endif /* _ASM_X86_FTRACE_H */ |
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index e44d379faad2..a71158369fd4 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | struct task_struct; | 20 | struct task_struct; |
| 21 | struct exec_domain; | 21 | struct exec_domain; |
| 22 | #include <asm/processor.h> | 22 | #include <asm/processor.h> |
| 23 | #include <asm/ftrace.h> | ||
| 23 | 24 | ||
| 24 | struct thread_info { | 25 | struct thread_info { |
| 25 | struct task_struct *task; /* main task structure */ | 26 | struct task_struct *task; /* main task structure */ |
| @@ -38,8 +39,30 @@ struct thread_info { | |||
| 38 | */ | 39 | */ |
| 39 | __u8 supervisor_stack[0]; | 40 | __u8 supervisor_stack[0]; |
| 40 | #endif | 41 | #endif |
| 42 | |||
| 43 | #ifdef CONFIG_FUNCTION_RET_TRACER | ||
| 44 | /* Index of current stored adress in ret_stack */ | ||
| 45 | int curr_ret_stack; | ||
| 46 | /* Stack of return addresses for return function tracing */ | ||
| 47 | struct ftrace_ret_stack ret_stack[FTRACE_RET_STACK_SIZE]; | ||
| 48 | #endif | ||
| 41 | }; | 49 | }; |
| 42 | 50 | ||
| 51 | #ifdef CONFIG_FUNCTION_RET_TRACER | ||
| 52 | #define INIT_THREAD_INFO(tsk) \ | ||
| 53 | { \ | ||
| 54 | .task = &tsk, \ | ||
| 55 | .exec_domain = &default_exec_domain, \ | ||
| 56 | .flags = 0, \ | ||
| 57 | .cpu = 0, \ | ||
| 58 | .preempt_count = 1, \ | ||
| 59 | .addr_limit = KERNEL_DS, \ | ||
| 60 | .restart_block = { \ | ||
| 61 | .fn = do_no_restart_syscall, \ | ||
| 62 | }, \ | ||
| 63 | .curr_ret_stack = -1,\ | ||
| 64 | } | ||
| 65 | #else | ||
| 43 | #define INIT_THREAD_INFO(tsk) \ | 66 | #define INIT_THREAD_INFO(tsk) \ |
| 44 | { \ | 67 | { \ |
| 45 | .task = &tsk, \ | 68 | .task = &tsk, \ |
| @@ -52,6 +75,7 @@ struct thread_info { | |||
| 52 | .fn = do_no_restart_syscall, \ | 75 | .fn = do_no_restart_syscall, \ |
| 53 | }, \ | 76 | }, \ |
| 54 | } | 77 | } |
| 78 | #endif | ||
| 55 | 79 | ||
| 56 | #define init_thread_info (init_thread_union.thread_info) | 80 | #define init_thread_info (init_thread_union.thread_info) |
| 57 | #define init_stack (init_thread_union.stack) | 81 | #define init_stack (init_thread_union.stack) |
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index e489ff9cb3e2..1d8ed95da846 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
| @@ -14,6 +14,11 @@ CFLAGS_REMOVE_paravirt-spinlocks.o = -pg | |||
| 14 | CFLAGS_REMOVE_ftrace.o = -pg | 14 | CFLAGS_REMOVE_ftrace.o = -pg |
| 15 | endif | 15 | endif |
| 16 | 16 | ||
| 17 | ifdef CONFIG_FUNCTION_RET_TRACER | ||
| 18 | # Don't trace __switch_to() but let it for function tracer | ||
| 19 | CFLAGS_REMOVE_process_32.o = -pg | ||
| 20 | endif | ||
| 21 | |||
| 17 | # | 22 | # |
| 18 | # vsyscalls (which work on the user stack) should have | 23 | # vsyscalls (which work on the user stack) should have |
| 19 | # no stack-protector checks: | 24 | # no stack-protector checks: |
| @@ -65,6 +70,7 @@ obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o | |||
| 65 | obj-$(CONFIG_X86_IO_APIC) += io_apic.o | 70 | obj-$(CONFIG_X86_IO_APIC) += io_apic.o |
| 66 | obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o | 71 | obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o |
| 67 | obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o | 72 | obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o |
| 73 | obj-$(CONFIG_FUNCTION_RET_TRACER) += ftrace.o | ||
| 68 | obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o | 74 | obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o |
| 69 | obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o | 75 | obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o |
| 70 | obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o | 76 | obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o |
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S index 9134de814c97..9a0ac85946db 100644 --- a/arch/x86/kernel/entry_32.S +++ b/arch/x86/kernel/entry_32.S | |||
| @@ -1188,6 +1188,10 @@ ENTRY(mcount) | |||
| 1188 | 1188 | ||
| 1189 | cmpl $ftrace_stub, ftrace_trace_function | 1189 | cmpl $ftrace_stub, ftrace_trace_function |
| 1190 | jnz trace | 1190 | jnz trace |
| 1191 | #ifdef CONFIG_FUNCTION_RET_TRACER | ||
| 1192 | cmpl $ftrace_stub, ftrace_function_return | ||
| 1193 | jnz trace_return | ||
| 1194 | #endif | ||
| 1191 | .globl ftrace_stub | 1195 | .globl ftrace_stub |
| 1192 | ftrace_stub: | 1196 | ftrace_stub: |
| 1193 | ret | 1197 | ret |
| @@ -1206,8 +1210,37 @@ trace: | |||
| 1206 | popl %edx | 1210 | popl %edx |
| 1207 | popl %ecx | 1211 | popl %ecx |
| 1208 | popl %eax | 1212 | popl %eax |
| 1213 | jmp ftrace_stub | ||
| 1209 | 1214 | ||
| 1215 | #ifdef CONFIG_FUNCTION_RET_TRACER | ||
| 1216 | trace_return: | ||
| 1217 | pushl %eax | ||
| 1218 | pushl %ecx | ||
| 1219 | pushl %edx | ||
| 1220 | movl 0xc(%esp), %eax | ||
| 1221 | pushl %eax | ||
| 1222 | lea 0x4(%ebp), %eax | ||
| 1223 | pushl %eax | ||
| 1224 | call prepare_ftrace_return | ||
| 1225 | addl $8, %esp | ||
| 1226 | popl %edx | ||
| 1227 | popl %ecx | ||
| 1228 | popl %eax | ||
| 1210 | jmp ftrace_stub | 1229 | jmp ftrace_stub |
| 1230 | |||
| 1231 | .globl return_to_handler | ||
| 1232 | return_to_handler: | ||
