diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/hw_breakpoint.c | 10 | ||||
| -rw-r--r-- | kernel/kprobes.c | 2 | ||||
| -rw-r--r-- | kernel/module.c | 17 | ||||
| -rw-r--r-- | kernel/perf_event.c | 5 | ||||
| -rw-r--r-- | kernel/trace/Kconfig | 112 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 2 | ||||
| -rw-r--r-- | kernel/trace/trace_export.c | 7 | ||||
| -rw-r--r-- | kernel/trace/trace_kprobe.c | 7 | ||||
| -rw-r--r-- | kernel/trace/trace_ksym.c | 140 |
9 files changed, 142 insertions, 160 deletions
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c index dbcbf6a33a08..50dbd5999588 100644 --- a/kernel/hw_breakpoint.c +++ b/kernel/hw_breakpoint.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <linux/percpu.h> | 40 | #include <linux/percpu.h> |
| 41 | #include <linux/sched.h> | 41 | #include <linux/sched.h> |
| 42 | #include <linux/init.h> | 42 | #include <linux/init.h> |
| 43 | #include <linux/cpu.h> | ||
| 43 | #include <linux/smp.h> | 44 | #include <linux/smp.h> |
| 44 | 45 | ||
| 45 | #include <linux/hw_breakpoint.h> | 46 | #include <linux/hw_breakpoint.h> |
| @@ -388,7 +389,8 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, | |||
| 388 | if (!cpu_events) | 389 | if (!cpu_events) |
| 389 | return ERR_PTR(-ENOMEM); | 390 | return ERR_PTR(-ENOMEM); |
| 390 | 391 | ||
| 391 | for_each_possible_cpu(cpu) { | 392 | get_online_cpus(); |
| 393 | for_each_online_cpu(cpu) { | ||
| 392 | pevent = per_cpu_ptr(cpu_events, cpu); | 394 | pevent = per_cpu_ptr(cpu_events, cpu); |
| 393 | bp = perf_event_create_kernel_counter(attr, cpu, -1, triggered); | 395 | bp = perf_event_create_kernel_counter(attr, cpu, -1, triggered); |
| 394 | 396 | ||
| @@ -399,18 +401,20 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, | |||
| 399 | goto fail; | 401 | goto fail; |
| 400 | } | 402 | } |
| 401 | } | 403 | } |
| 404 | put_online_cpus(); | ||
| 402 | 405 | ||
| 403 | return cpu_events; | 406 | return cpu_events; |
| 404 | 407 | ||
| 405 | fail: | 408 | fail: |
| 406 | for_each_possible_cpu(cpu) { | 409 | for_each_online_cpu(cpu) { |
| 407 | pevent = per_cpu_ptr(cpu_events, cpu); | 410 | pevent = per_cpu_ptr(cpu_events, cpu); |
| 408 | if (IS_ERR(*pevent)) | 411 | if (IS_ERR(*pevent)) |
| 409 | break; | 412 | break; |
| 410 | unregister_hw_breakpoint(*pevent); | 413 | unregister_hw_breakpoint(*pevent); |
| 411 | } | 414 | } |
| 415 | put_online_cpus(); | ||
| 416 | |||
| 412 | free_percpu(cpu_events); | 417 | free_percpu(cpu_events); |
| 413 | /* return the error if any */ | ||
| 414 | return ERR_PTR(err); | 418 | return ERR_PTR(err); |
| 415 | } | 419 | } |
| 416 | EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint); | 420 | EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint); |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index e5342a344c43..b7df302a0204 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
| @@ -1035,7 +1035,7 @@ int __kprobes register_kretprobe(struct kretprobe *rp) | |||
| 1035 | /* Pre-allocate memory for max kretprobe instances */ | 1035 | /* Pre-allocate memory for max kretprobe instances */ |
| 1036 | if (rp->maxactive <= 0) { | 1036 | if (rp->maxactive <= 0) { |
| 1037 | #ifdef CONFIG_PREEMPT | 1037 | #ifdef CONFIG_PREEMPT |
| 1038 | rp->maxactive = max(10, 2 * num_possible_cpus()); | 1038 | rp->maxactive = max_t(unsigned int, 10, 2*num_possible_cpus()); |
| 1039 | #else | 1039 | #else |
| 1040 | rp->maxactive = num_possible_cpus(); | 1040 | rp->maxactive = num_possible_cpus(); |
| 1041 | #endif | 1041 | #endif |
diff --git a/kernel/module.c b/kernel/module.c index e96b8ed1cb6a..f82386bd9ee9 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -1010,6 +1010,12 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs, | |||
| 1010 | * J. Corbet <corbet@lwn.net> | 1010 | * J. Corbet <corbet@lwn.net> |
| 1011 | */ | 1011 | */ |
| 1012 | #if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS) | 1012 | #if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS) |
| 1013 | |||
| 1014 | static inline bool sect_empty(const Elf_Shdr *sect) | ||
| 1015 | { | ||
| 1016 | return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0; | ||
| 1017 | } | ||
| 1018 | |||
| 1013 | struct module_sect_attr | 1019 | struct module_sect_attr |
| 1014 | { | 1020 | { |
| 1015 | struct module_attribute mattr; | 1021 | struct module_attribute mattr; |
| @@ -1051,8 +1057,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect, | |||
| 1051 | 1057 | ||
| 1052 | /* Count loaded sections and allocate structures */ | 1058 | /* Count loaded sections and allocate structures */ |
| 1053 | for (i = 0; i < nsect; i++) | 1059 | for (i = 0; i < nsect; i++) |
| 1054 | if (sechdrs[i].sh_flags & SHF_ALLOC | 1060 | if (!sect_empty(&sechdrs[i])) |
| 1055 | && sechdrs[i].sh_size) | ||
| 1056 | nloaded++; | 1061 | nloaded++; |
| 1057 | size[0] = ALIGN(sizeof(*sect_attrs) | 1062 | size[0] = ALIGN(sizeof(*sect_attrs) |
| 1058 | + nloaded * sizeof(sect_attrs->attrs[0]), | 1063 | + nloaded * sizeof(sect_attrs->attrs[0]), |
| @@ -1070,9 +1075,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect, | |||
| 1070 | sattr = §_attrs->attrs[0]; | 1075 | sattr = §_attrs->attrs[0]; |
| 1071 | gattr = §_attrs->grp.attrs[0]; | 1076 | gattr = §_attrs->grp.attrs[0]; |
| 1072 | for (i = 0; i < nsect; i++) { | 1077 | for (i = 0; i < nsect; i++) { |
| 1073 | if (! (sechdrs[i].sh_flags & SHF_ALLOC)) | 1078 | if (sect_empty(&sechdrs[i])) |
| 1074 | continue; | ||
| 1075 | if (!sechdrs[i].sh_size) | ||
| 1076 | continue; | 1079 | continue; |
| 1077 | sattr->address = sechdrs[i].sh_addr; | 1080 | sattr->address = sechdrs[i].sh_addr; |
| 1078 | sattr->name = kstrdup(secstrings + sechdrs[i].sh_name, | 1081 | sattr->name = kstrdup(secstrings + sechdrs[i].sh_name, |
| @@ -1156,7 +1159,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect, | |||
| 1156 | /* Count notes sections and allocate structures. */ | 1159 | /* Count notes sections and allocate structures. */ |
| 1157 | notes = 0; | 1160 | notes = 0; |
| 1158 | for (i = 0; i < nsect; i++) | 1161 | for (i = 0; i < nsect; i++) |
| 1159 | if ((sechdrs[i].sh_flags & SHF_ALLOC) && | 1162 | if (!sect_empty(&sechdrs[i]) && |
| 1160 | (sechdrs[i].sh_type == SHT_NOTE)) | 1163 | (sechdrs[i].sh_type == SHT_NOTE)) |
| 1161 | ++notes; | 1164 | ++notes; |
| 1162 | 1165 | ||
| @@ -1172,7 +1175,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect, | |||
| 1172 | notes_attrs->notes = notes; | 1175 | notes_attrs->notes = notes; |
| 1173 | nattr = ¬es_attrs->attrs[0]; | 1176 | nattr = ¬es_attrs->attrs[0]; |
| 1174 | for (loaded = i = 0; i < nsect; ++i) { | 1177 | for (loaded = i = 0; i < nsect; ++i) { |
| 1175 | if (!(sechdrs[i].sh_flags & SHF_ALLOC)) | 1178 | if (sect_empty(&sechdrs[i])) |
| 1176 | continue; | 1179 | continue; |
| 1177 | if (sechdrs[i].sh_type == SHT_NOTE) { | 1180 | if (sechdrs[i].sh_type == SHT_NOTE) { |
| 1178 | nattr->attr.name = mod->sect_attrs->attrs[loaded].name; | 1181 | nattr->attr.name = mod->sect_attrs->attrs[loaded].name; |
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 1f38270f08c7..603c0d8b5df1 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
| @@ -5148,7 +5148,7 @@ int perf_event_init_task(struct task_struct *child) | |||
| 5148 | GFP_KERNEL); | 5148 | GFP_KERNEL); |
| 5149 | if (!child_ctx) { | 5149 | if (!child_ctx) { |
| 5150 | ret = -ENOMEM; | 5150 | ret = -ENOMEM; |
| 5151 | goto exit; | 5151 | break; |
| 5152 | } | 5152 | } |
| 5153 | 5153 | ||
| 5154 | __perf_event_init_context(child_ctx, child); | 5154 | __perf_event_init_context(child_ctx, child); |
| @@ -5164,7 +5164,7 @@ int perf_event_init_task(struct task_struct *child) | |||
| 5164 | } | 5164 | } |
| 5165 | } | 5165 | } |
| 5166 | 5166 | ||
| 5167 | if (inherited_all) { | 5167 | if (child_ctx && inherited_all) { |
| 5168 | /* | 5168 | /* |
| 5169 | * Mark the child context as a clone of the parent | 5169 | * Mark the child context as a clone of the parent |
| 5170 | * context, or of whatever the parent is a clone of. | 5170 | * context, or of whatever the parent is a clone of. |
| @@ -5184,7 +5184,6 @@ int perf_event_init_task(struct task_struct *child) | |||
| 5184 | get_ctx(child_ctx->parent_ctx); | 5184 | get_ctx(child_ctx->parent_ctx); |
| 5185 | } | 5185 | } |
| 5186 | 5186 | ||
| 5187 | exit: | ||
| 5188 | mutex_unlock(&parent_ctx->mutex); | 5187 | mutex_unlock(&parent_ctx->mutex); |
| 5189 | 5188 | ||
| 5190 | perf_unpin_context(parent_ctx); | 5189 | perf_unpin_context(parent_ctx); |
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index d006554888dc..6c22d8a2f289 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig | |||
| @@ -12,17 +12,17 @@ config NOP_TRACER | |||
| 12 | config HAVE_FTRACE_NMI_ENTER | 12 | config HAVE_FTRACE_NMI_ENTER |
| 13 | bool | 13 | bool |
| 14 | help | 14 | help |
| 15 | See Documentation/trace/ftrace-implementation.txt | 15 | See Documentation/trace/ftrace-design.txt |
| 16 | 16 | ||
| 17 | config HAVE_FUNCTION_TRACER | 17 | config HAVE_FUNCTION_TRACER |
| 18 | bool | 18 | bool |
| 19 | help | 19 | help |
| 20 | See Documentation/trace/ftrace-implementation.txt | 20 | See Documentation/trace/ftrace-design.txt |
| 21 | 21 | ||
| 22 | config HAVE_FUNCTION_GRAPH_TRACER | 22 | config HAVE_FUNCTION_GRAPH_TRACER |
| 23 | bool | 23 | bool |
| 24 | help | 24 | help |
| 25 | See Documentation/trace/ftrace-implementation.txt | 25 | See Documentation/trace/ftrace-design.txt |
| 26 | 26 | ||
| 27 | config HAVE_FUNCTION_GRAPH_FP_TEST | 27 | config HAVE_FUNCTION_GRAPH_FP_TEST |
| 28 | bool | 28 | bool |
| @@ -34,17 +34,17 @@ config HAVE_FUNCTION_GRAPH_FP_TEST | |||
| 34 | config HAVE_FUNCTION_TRACE_MCOUNT_TEST | 34 | config HAVE_FUNCTION_TRACE_MCOUNT_TEST |
| 35 | bool | 35 | bool |
| 36 | help | 36 | help |
| 37 | See Documentation/trace/ftrace-implementation.txt | 37 | See Documentation/trace/ftrace-design.txt |
| 38 | 38 | ||
| 39 | config HAVE_DYNAMIC_FTRACE | 39 | config HAVE_DYNAMIC_FTRACE |
| 40 | bool | 40 | bool |
| 41 | help | 41 | help |
| 42 | See Documentation/trace/ftrace-implementation.txt | 42 | See Documentation/trace/ftrace-design.txt |
| 43 | 43 | ||
| 44 | config HAVE_FTRACE_MCOUNT_RECORD | 44 | config HAVE_FTRACE_MCOUNT_RECORD |
| 45 | bool | 45 | bool |
| 46 | help | 46 | help |
| 47 | See Documentation/trace/ftrace-implementation.txt | 47 | See Documentation/trace/ftrace-design.txt |
| 48 | 48 | ||
| 49 | config HAVE_HW_BRANCH_TRACER | 49 | config HAVE_HW_BRANCH_TRACER |
| 50 | bool | 50 | bool |
| @@ -52,7 +52,7 @@ config HAVE_HW_BRANCH_TRACER | |||
| 52 | config HAVE_SYSCALL_TRACEPOINTS | 52 | config HAVE_SYSCALL_TRACEPOINTS |
| 53 | bool | 53 | bool |
| 54 | help | 54 | help |
| 55 | See Documentation/trace/ftrace-implementation.txt | 55 | See Documentation/trace/ftrace-design.txt |
| 56 | 56 | ||
| 57 | config TRACER_MAX_TRACE | 57 | config TRACER_MAX_TRACE |
| 58 | bool | 58 | bool |
| @@ -83,7 +83,7 @@ config RING_BUFFER_ALLOW_SWAP | |||
| 83 | # This allows those options to appear when no other tracer is selected. But the | 83 | # This allows those options to appear when no other tracer is selected. But the |
| 84 | # options do not appear when something else selects it. We need the two options | 84 | # options do not appear when something else selects it. We need the two options |
| 85 | # GENERIC_TRACER and TRACING to avoid circular dependencies to accomplish the | 85 | # GENERIC_TRACER and TRACING to avoid circular dependencies to accomplish the |
| 86 | # hidding of the automatic options. | 86 | # hiding of the automatic options. |
| 87 | 87 | ||
| 88 | config TRACING | 88 | config TRACING |
| 89 | bool | 89 | bool |
| @@ -119,7 +119,7 @@ menuconfig FTRACE | |||
| 119 | bool "Tracers" | 119 | bool "Tracers" |
| 120 | default y if DEBUG_KERNEL | 120 | default y if DEBUG_KERNEL |
| 121 | help | 121 | help |
| 122 | Enable the kernel tracing infrastructure. | 122 | Enable the kernel tracing infrastructure. |
| 123 | 123 | ||
| 124 | if FTRACE | 124 | if FTRACE |
| 125 | 125 | ||
| @@ -133,7 +133,7 @@ config FUNCTION_TRACER | |||
| 133 | help | 133 | help |
| 134 | Enable the kernel to trace every kernel function. This is done | 134 | Enable the kernel to trace every kernel function. This is done |
| 135 | by using a compiler feature to insert a small, 5-byte No-Operation | 135 | by using a compiler feature to insert a small, 5-byte No-Operation |
| 136 | instruction to the beginning of every kernel function, which NOP | 136 | instruction at the beginning of every kernel function, which NOP |
| 137 | sequence is then dynamically patched into a tracer call when | 137 | sequence is then dynamically patched into a tracer call when |
| 138 | tracing is enabled by the administrator. If it's runtime disabled | 138 | tracing is enabled by the administrator. If it's runtime disabled |
| 139 | (the bootup default), then the overhead of the instructions is very | 139 | (the bootup default), then the overhead of the instructions is very |
| @@ -150,7 +150,7 @@ config FUNCTION_GRAPH_TRACER | |||
| 150 | and its entry. | 150 | and its entry. |
| 151 | Its first purpose is to trace the duration of functions and | 151 | Its first purpose is to trace the duration of functions and |
| 152 | draw a call graph for each thread with some information like | 152 | draw a call graph for each thread with some information like |
| 153 | the return value. This is done by setting the current return | 153 | the return value. This is done by setting the current return |
| 154 | address on the current task structure into a stack of calls. | 154 | address on the current task structure into a stack of calls. |
| 155 | 155 | ||
| 156 | 156 | ||
| @@ -173,7 +173,7 @@ config IRQSOFF_TRACER | |||
| 173 | 173 | ||
| 174 | echo 0 > /sys/kernel/debug/tracing/tracing_max_latency | 174 | echo 0 > /sys/kernel/debug/tracing/tracing_max_latency |
| 175 | 175 | ||
| 176 | (Note that kernel size and overhead increases with this option | 176 | (Note that kernel size and overhead increase with this option |
| 177 | enabled. This option and the preempt-off timing option can be | 177 | enabled. This option and the preempt-off timing option can be |
| 178 | used together or separately.) | 178 | used together or separately.) |
| 179 | 179 | ||
| @@ -186,7 +186,7 @@ config PREEMPT_TRACER | |||
| 186 | select TRACER_MAX_TRACE | 186 | select TRACER_MAX_TRACE |
| 187 | select RING_BUFFER_ALLOW_SWAP | 187 | select RING_BUFFER_ALLOW_SWAP |
| 188 | help | 188 | help |
| 189 | This option measures the time spent in preemption off critical | 189 | This option measures the time spent in preemption-off critical |
| 190 | sections, with microsecond accuracy. | 190 | sections, with microsecond accuracy. |
| 191 | 191 | ||
| 192 | The default measurement method is a maximum search, which is | 192 | The default measurement method is a maximum search, which is |
| @@ -195,7 +195,7 @@ config PREEMPT_TRACER | |||
| 195 | 195 | ||
| 196 | echo 0 > /sys/kernel/debug/tracing/tracing_max_latency | 196 | echo 0 > /sys/kernel/debug/tracing/tracing_max_latency |
| 197 | 197 | ||
| 198 | (Note that kernel size and overhead increases with this option | 198 | (Note that kernel size and overhead increase with this option |
| 199 | enabled. This option and the irqs-off timing option can be | 199 | enabled. This option and the irqs-off timing option can be |
| 200 | used together or separately.) | 200 | used together or separately.) |
| 201 | 201 | ||
| @@ -222,7 +222,7 @@ config ENABLE_DEFAULT_TRACERS | |||
| 222 | depends on !GENERIC_TRACER | 222 | depends on !GENERIC_TRACER |
| 223 | select TRACING | 223 | select TRACING |
| 224 | help | 224 | help |
| 225 | This tracer hooks to various trace points in the kernel | 225 | This tracer hooks to various trace points in the kernel, |
| 226 | allowing the user to pick and choose which trace point they | 226 | allowing the user to pick and choose which trace point they |
| 227 | want to trace. It also includes the sched_switch tracer plugin. | 227 | want to trace. It also includes the sched_switch tracer plugin. |
| 228 | 228 | ||
| @@ -265,19 +265,19 @@ choice | |||
| 265 | The likely/unlikely profiler only looks at the conditions that | 265 | The likely/unlikely profiler only looks at the conditions that |
| 266 | are annotated with a likely or unlikely macro. | 266 | are annotated with a likely or unlikely macro. |
| 267 | 267 | ||
| 268 | The "all branch" profiler will profile every if statement in the | 268 | The "all branch" profiler will profile every if-statement in the |
| 269 | kernel. This profiler will also enable the likely/unlikely | 269 | kernel. This profiler will also enable the likely/unlikely |
| 270 | profiler as well. | 270 | profiler. |
| 271 | 271 | ||
| 272 | Either of the above profilers add a bit of overhead to the system. | 272 | Either of the above profilers adds a bit of overhead to the system. |
| 273 | If unsure choose "No branch profiling". | 273 | If unsure, choose "No branch profiling". |
| 274 | 274 | ||
| 275 | config BRANCH_PROFILE_NONE | 275 | config BRANCH_PROFILE_NONE |
| 276 | bool "No branch profiling" | 276 | bool "No branch profiling" |
| 277 | help | 277 | help |
| 278 | No branch profiling. Branch profiling adds a bit of overhead. | 278 | No branch profiling. Branch profiling adds a bit of overhead. |
| 279 | Only enable it if you want to analyse the branching behavior. | 279 | Only enable it if you want to analyse the branching behavior. |
| 280 | Otherwise keep it disabled. | 280 | Otherwise keep it disabled. |
| 281 | 281 | ||
| 282 | config PROFILE_ANNOTATED_BRANCHES | 282 | config PROFILE_ANNOTATED_BRANCHES |
| 283 | bool "Trace likely/unlikely profiler" | 283 | bool "Trace likely/unlikely profiler" |
| @@ -288,7 +288,7 @@ config PROFILE_ANNOTATED_BRANCHES | |||
| 288 | 288 | ||
| 289 | /sys/kernel/debug/tracing/profile_annotated_branch | 289 | /sys/kernel/debug/tracing/profile_annotated_branch |
| 290 | 290 | ||
| 291 | Note: this will add a significant overhead, only turn this | 291 | Note: this will add a significant overhead; only turn this |
| 292 | on if you need to profile the system's use of these macros. | 292 | on if you need to profile the system's use of these macros. |
| 293 | 293 | ||
| 294 | config PROFILE_ALL_BRANCHES | 294 | config PROFILE_ALL_BRANCHES |
| @@ -305,7 +305,7 @@ config PROFILE_ALL_BRANCHES | |||
| 305 | 305 | ||
| 306 | This configuration, when enabled, will impose a great overhead | 306 | This configuration, when enabled, will impose a great overhead |
| 307 | on the system. This should only be enabled when the system | 307 | on the system. This should only be enabled when the system |
| 308 | is to be analyzed | 308 | is to be analyzed in much detail. |
| 309 | endchoice | 309 | endchoice |
| 310 | 310 | ||
| 311 | config TRACING_BRANCHES | 311 | config TRACING_BRANCHES |
| @@ -335,7 +335,7 @@ config POWER_TRACER | |||
| 335 | depends on X86 | 335 | depends on X86 |
| 336 | select GENERIC_TRACER | 336 | select GENERIC_TRACER |
| 337 | help | 337 | help |
| 338 | This tracer helps developers to analyze and optimize the kernels | 338 | This tracer helps developers to analyze and optimize the kernel's |
| 339 | power management decisions, specifically the C-state and P-state | 339 | power management decisions, specifically the C-state and P-state |
| 340 | behavior. | 340 | behavior. |
| 341 | 341 | ||
| @@ -391,14 +391,14 @@ config HW_BRANCH_TRACER | |||
| 391 | select GENERIC_TRACER | 391 | select GENERIC_TRACER |
| 392 | help | 392 | help |
| 393 | This tracer records all branches on the system in a circular | 393 | This tracer records all branches on the system in a circular |
| 394 | buffer giving access to the last N branches for each cpu. | 394 | buffer, giving access to the last N branches for each cpu. |
| 395 | 395 | ||
| 396 | config KMEMTRACE | 396 | config KMEMTRACE |
| 397 | bool "Trace SLAB allocations" | 397 | bool "Trace SLAB allocations" |
| 398 | select GENERIC_TRACER | 398 | select GENERIC_TRACER |
| 399 | help | 399 | help |
| 400 | kmemtrace provides tracing for slab allocator functions, such as | 400 | kmemtrace provides tracing for slab allocator functions, such as |
| 401 | kmalloc, kfree, kmem_cache_alloc, kmem_cache_free etc.. Collected | 401 | kmalloc, kfree, kmem_cache_alloc, kmem_cache_free, etc. Collected |
| 402 | data is then fed to the userspace application in order to analyse | 402 | data is then fed to the userspace application in order to analyse |
| 403 | allocation hotspots, internal fragmentation and so on, making it | 403 | allocation hotspots, internal fragmentation and so on, making it |
| 404 | possible to see how well an allocator performs, as well as debug | 404 | possible to see how well an allocator performs, as well as debug |
| @@ -417,15 +417,15 @@ config WORKQUEUE_TRACER | |||
| 417 | bool "Trace workqueues" | 417 | bool "Trace workqueues" |
| 418 | select GENERIC_TRACER | 418 | select GENERIC_TRACER |
| 419 | help | 419 | help |
| 420 | The workqueue tracer provides some statistical informations | 420 | The workqueue tracer provides some statistical information |
| 421 | about each cpu workqueue thread such as the number of the | 421 | about each cpu workqueue thread such as the number of the |
| 422 | works inserted and executed since their creation. It can help | 422 | works inserted and executed since their creation. It can help |
| 423 | to evaluate the amount of work each of them have to perform. | 423 | to evaluate the amount of work each of them has to perform. |
| 424 | For example it can help a developer to decide whether he should | 424 | For example it can help a developer to decide whether he should |
| 425 | choose a per cpu workqueue instead of a singlethreaded one. | 425 | choose a per-cpu workqueue instead of a singlethreaded one. |
| 426 | 426 | ||
| 427 | config BLK_DEV_IO_TRACE | 427 | config BLK_DEV_IO_TRACE |
| 428 | bool "Support for tracing block io actions" | 428 | bool "Support for tracing block IO actions" |
| 429 | depends on SYSFS | 429 | depends on SYSFS |
| 430 | depends on BLOCK | 430 | depends on BLOCK |
| 431 | select RELAY | 431 | select RELAY |
| @@ -456,15 +456,15 @@ config KPROBE_EVENT | |||
| 456 | select TRACING | 456 | select TRACING |
| 457 | default y | 457 | default y |
| 458 | help | 458 | help |
| 459 | This allows the user to add tracing events (similar to tracepoints) on the fly | 459 | This allows the user to add tracing events (similar to tracepoints) |
| 460 | via the ftrace interface. See Documentation/trace/kprobetrace.txt | 460 | on the fly via the ftrace interface. See |
| 461 | for more details. | 461 | Documentation/trace/kprobetrace.txt for more details. |
| 462 | 462 | ||
| 463 | Those events can be inserted wherever kprobes can probe, and record | 463 | Those events can be inserted wherever kprobes can probe, and record |
| 464 | various register and memory values. | 464 | various register and memory values. |
| 465 | 465 | ||
| 466 | This option is also required by perf-probe subcommand of perf tools. If | 466 | This option is also required by perf-probe subcommand of perf tools. |
| 467 | you want to use perf tools, this option is strongly recommended. | 467 | If you want to use perf tools, this option is strongly recommended. |
| 468 | 468 | ||
| 469 | config DYNAMIC_FTRACE | 469 | config DYNAMIC_FTRACE |
| 470 | bool "enable/disable ftrace tracepoints dynamically" | 470 | bool "enable/disable ftrace tracepoints dynamically" |
| @@ -472,32 +472,32 @@ config DYNAMIC_FTRACE | |||
| 472 | depends on HAVE_DYNAMIC_FTRACE | 472 | depends on HAVE_DYNAMIC_FTRACE |
| 473 | default y | 473 | default y |
| 474 | help | 474 | help |
| 475 | This option will modify all the calls to ftrace dynamically | 475 | This option will modify all the calls to ftrace dynamically |
| 476 | (will patch them out of the binary image and replaces them | 476 | (will patch them out of the binary image and replace them |
| 477 | with a No-Op instruction) as they are called. A table is | 477 | with a No-Op instruction) as they are called. A table is |
| 478 | created to dynamically enable them again. | 478 | created to dynamically enable them again. |
| 479 | 479 | ||
| 480 | This way a CONFIG_FUNCTION_TRACER kernel is slightly larger, but otherwise | 480 | This way a CONFIG_FUNCTION_TRACER kernel is slightly larger, but |
| 481 | has native performance as long as no tracing is active. | 481 | otherwise has native performance as long as no tracing is active. |
| 482 | 482 | ||
| 483 | The changes to the code are done by a kernel thread that | 483 | The changes to the code are done by a kernel thread that |
| 484 | wakes up once a second and checks to see if any ftrace calls | 484 | wakes up once a second and checks to see if any ftrace calls |
| 485 | were made. If so, it runs stop_machine (stops all CPUS) | 485 | were made. If so, it runs stop_machine (stops all CPUS) |
| 486 | and modifies the code to jump over the call to ftrace. | 486 | and modifies the code to jump over the call to ftrace. |
| 487 | 487 | ||
| 488 | config FUNCTION_PROFILER | 488 | config FUNCTION_PROFILER |
| 489 | bool "Kernel function profiler" | 489 | bool "Kernel function profiler" |
| 490 | depends on FUNCTION_TRACER | 490 | depends on FUNCTION_TRACER |
| 491 | default n | 491 | default n |
| 492 | help | 492 | help |
| 493 | This option enables the kernel function profiler. A file is created | 493 | This option enables the kernel function profiler. A file is created |
| 494 | in debugfs called function_profile_enabled which defaults to zero. | 494 | in debugfs called function_profile_enabled which defaults to zero. |
| 495 | When a 1 is echoed into this file profiling begins, and when a | 495 | When a 1 is echoed into this file profiling begins, and when a |
| 496 | zero is entered, profiling stops. A file in the trace_stats | 496 | zero is entered, profiling stops. A "functions" file is created in |
| 497 | directory called functions, that show the list of functions that | 497 | the trace_stats directory; this file shows the list of functions that |
| 498 | have been hit and their counters. | 498 | have been hit and their counters. |
| 499 | 499 | ||
| 500 | If in doubt, say N | 500 | If in doubt, say N. |
| 501 | 501 | ||
| 502 | config FTRACE_MCOUNT_RECORD | 502 | config FTRACE_MCOUNT_RECORD |
| 503 | def_bool y | 503 | def_bool y |
| @@ -556,8 +556,8 @@ config RING_BUFFER_BENCHMARK | |||
| 556 | tristate "Ring buffer benchmark stress tester" | 556 | tristate "Ring buffer benchmark stress tester" |
| 557 | depends on RING_BUFFER | 557 | depends on RING_BUFFER |
| 558 | help | 558 | help |
| 559 | This option creates a test to stress the ring buffer and bench mark it. | 559 | This option creates a test to stress the ring buffer and benchmark it. |
| 560 | It creates its own ring buffer such that it will not interfer with | 560 | It creates its own ring buffer such that it will not interfere with |
| 561 | any other users of the ring buffer (such as ftrace). It then creates | 561 | any other users of the ring buffer (such as ftrace). It then creates |
| 562 | a producer and consumer that will run for 10 seconds and sleep for | 562 | a producer and consumer that will run for 10 seconds and sleep for |
| 563 | 10 seconds. Each interval it will print out the number of events | 563 | 10 seconds. Each interval it will print out the number of events |
| @@ -566,7 +566,7 @@ config RING_BUFFER_BENCHMARK | |||
| 566 | It does not disable interrupts or raise its priority, so it may be | 566 | It does not disable interrupts or raise its priority, so it may be |
| 567 | affected by processes that are running. | 567 | affected by processes that are running. |
| 568 | 568 | ||
| 569 | If unsure, say N | 569 | If unsure, say N. |
| 570 | 570 | ||
| 571 | endif # FTRACE | 571 | endif # FTRACE |
| 572 | 572 | ||
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8b9f20ab8eed..0df1b0f2cb9e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -3949,7 +3949,7 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
| 3949 | if (!!(topt->flags->val & topt->opt->bit) != val) { | 3949 | if (!!(topt->flags->val & topt->opt->bit) != val) { |
| 3950 | mutex_lock(&trace_types_lock); | 3950 | mutex_lock(&trace_types_lock); |
| 3951 | ret = __set_tracer_option(current_trace, topt->flags, | 3951 | ret = __set_tracer_option(current_trace, topt->flags, |
| 3952 | topt->opt, val); | 3952 | topt->opt, !val); |
| 3953 | mutex_unlock(&trace_types_lock); | 3953 | mutex_unlock(&trace_types_lock); |
| 3954 | if (ret) | 3954 | if (ret) |
| 3955 | return ret; | 3955 | return ret; |
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index 458e5bfe26d0..d4fa5dc1ee4e 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
| @@ -158,7 +158,8 @@ ftrace_format_##name(struct ftrace_event_call *unused, \ | |||
| 158 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | 158 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ |
| 159 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 159 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
| 160 | offsetof(typeof(field), item), \ | 160 | offsetof(typeof(field), item), \ |
| 161 | sizeof(field.item), 0, FILTER_OTHER); \ | 161 | sizeof(field.item), \ |
| 162 | is_signed_type(type), FILTER_OTHER); \ | ||
| 162 | if (ret) \ | 163 | if (ret) \ |
| 163 | return ret; | 164 | return ret; |
| 164 | 165 | ||
| @@ -168,8 +169,8 @@ ftrace_format_##name(struct ftrace_event_call *unused, \ | |||
| 168 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 169 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
| 169 | offsetof(typeof(field), \ | 170 | offsetof(typeof(field), \ |
| 170 | container.item), \ | 171 | container.item), \ |
| 171 | sizeof(field.container.item), 0, \ | 172 | sizeof(field.container.item), \ |
| 172 | FILTER_OTHER); \ | 173 | is_signed_type(type), FILTER_OTHER); \ |
| 173 | if (ret) \ | 174 | if (ret) \ |
| 174 | return ret; | 175 | return ret; |
| 175 | 176 | ||
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 375f81a568dc..6ea90c0e2c96 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
| @@ -1201,10 +1201,11 @@ static int __probe_event_show_format(struct trace_seq *s, | |||
| 1201 | #undef SHOW_FIELD | 1201 | #undef SHOW_FIELD |
| 1202 | #define SHOW_FIELD(type, item, name) \ | 1202 | #define SHOW_FIELD(type, item, name) \ |
| 1203 | do { \ | 1203 | do { \ |
| 1204 | ret = trace_seq_printf(s, "\tfield: " #type " %s;\t" \ | 1204 | ret = trace_seq_printf(s, "\tfield:" #type " %s;\t" \ |
| 1205 | "offset:%u;\tsize:%u;\n", name, \ | 1205 | "offset:%u;\tsize:%u;\tsigned:%d;\n", name,\ |
| 1206 | (unsigned int)offsetof(typeof(field), item),\ | 1206 | (unsigned int)offsetof(typeof(field), item),\ |
| 1207 | (unsigned int)sizeof(type)); \ | 1207 | (unsigned int)sizeof(type), \ |
| 1208 | is_signed_type(type)); \ | ||
| 1208 | if (!ret) \ | 1209 | if (!ret) \ |
| 1209 | return 0; \ | 1210 | return 0; \ |
| 1210 | } while (0) | 1211 | } while (0) |
diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c index faf37fa4408c..94103cdcf9d8 100644 --- a/kernel/trace/trace_ksym.c +++ b/kernel/trace/trace_ksym.c | |||
| @@ -26,12 +26,13 @@ | |||
| 26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
| 27 | 27 | ||
| 28 | #include "trace_output.h" | 28 | #include "trace_output.h" |
| 29 | #include "trace_stat.h" | ||
| 30 | #include "trace.h" | 29 | #include "trace.h" |
| 31 | 30 | ||
| 32 | #include <linux/hw_breakpoint.h> | 31 | #include <linux/hw_breakpoint.h> |
| 33 | #include <asm/hw_breakpoint.h> | 32 | #include <asm/hw_breakpoint.h> |
| 34 | 33 | ||
| 34 | #include <asm/atomic.h> | ||
| 35 | |||
| 35 | /* | 36 | /* |
| 36 | * For now, let us restrict the no. of symbols traced simultaneously to number | 37 | * For now, let us restrict the no. of symbols traced simultaneously to number |
| 37 | * of available hardware breakpoint registers. | 38 | * of available hardware breakpoint registers. |
| @@ -44,7 +45,7 @@ struct trace_ksym { | |||
| 44 | struct perf_event **ksym_hbp; | 45 | struct perf_event **ksym_hbp; |
| 45 | struct perf_event_attr attr; | 46 | struct perf_event_attr attr; |
| 46 | #ifdef CONFIG_PROFILE_KSYM_TRACER | 47 | #ifdef CONFIG_PROFILE_KSYM_TRACER |
| 47 | unsigned long counter; | 48 | atomic64_t counter; |
| 48 | #endif | 49 | #endif |
| 49 | struct hlist_node ksym_hlist; | 50 | struct hlist_node ksym_hlist; |
| 50 | }; | 51 | }; |
| @@ -69,9 +70,8 @@ void ksym_collect_stats(unsigned long hbp_hit_addr) | |||
| 69 | 70 | ||
| 70 | rcu_read_lock(); | 71 | rcu_read_lock(); |
| 71 | hlist_for_each_entry_rcu(entry, node, &ksym_filter_head, ksym_hlist) { | 72 | hlist_for_each_entry_rcu(entry, node, &ksym_filter_head, ksym_hlist) { |
| 72 | if ((entry->attr.bp_addr == hbp_hit_addr) && | 73 | if (entry->attr.bp_addr == hbp_hit_addr) { |
| 73 | (entry->counter <= MAX_UL_INT)) { | 74 | atomic64_inc(&entry->counter); |
| 74 | entry->counter++; | ||
| 75 | break; | 75 | break; |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| @@ -197,7 +197,6 @@ int process_new_ksym_entry(char *ksymname, int op, unsigned long addr) | |||
| 197 | entry->attr.bp_addr = addr; | 197 | entry->attr.bp_addr = addr; |
| 198 | entry->attr.bp_len = HW_BREAKPOINT_LEN_4; | 198 | entry->attr.bp_len = HW_BREAKPOINT_LEN_4; |
| 199 | 199 | ||
| 200 | ret = -EAGAIN; | ||
| 201 | entry->ksym_hbp = register_wide_hw_breakpoint(&entry->attr, | 200 | entry->ksym_hbp = register_wide_hw_breakpoint(&entry->attr, |
| 202 | ksym_hbp_handler); | 201 | ksym_hbp_handler); |
| 203 | 202 | ||
| @@ -300,8 +299,8 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
| 300 | * 2: echo 0 > ksym_trace_filter | 299 | * 2: echo 0 > ksym_trace_filter |
| 301 | * 3: echo "*:---" > ksym_trace_filter | 300 | * 3: echo "*:---" > ksym_trace_filter |
| 302 | */ | 301 | */ |
| 303 | if (!buf[0] || !strcmp(buf, "0") || | 302 | if (!input_string[0] || !strcmp(input_string, "0") || |
| 304 | !strcmp(buf, "*:---")) { | 303 | !strcmp(input_string, "*:---")) { |
| 305 | __ksym_trace_reset(); | 304 | __ksym_trace_reset(); |
| 306 | ret = 0; | 305 | ret = 0; |
| 307 | goto out; | 306 | goto out; |
| @@ -444,102 +443,77 @@ struct tracer ksym_tracer __read_mostly = | |||
| 444 | .print_line = ksym_trace_output | 443 | .print_line = ksym_trace_output |
| 445 | }; | 444 | }; |
| 446 | 445 | ||
| 447 | __init static int init_ksym_trace(void) | ||
| 448 | { | ||
| 449 | struct dentry *d_tracer; | ||
| 450 | struct dentry *entry; | ||
| 451 | |||
| 452 | d_tracer = tracing_init_dentry(); | ||
| 453 | ksym_filter_entry_count = 0; | ||
| 454 | |||
| 455 | entry = debugfs_create_file("ksym_trace_filter", 0644, d_tracer, | ||
| 456 | NULL, &ksym_tracing_fops); | ||
| 457 | if (!entry) | ||
| 458 | pr_warning("Could not create debugfs " | ||
| 459 | "'ksym_trace_filter' file\n"); | ||
| 460 | |||
| 461 | return register_tracer(&ksym_tracer); | ||
| 462 | } | ||
| 463 | device_initcall(init_ksym_trace); | ||
| 464 | |||
| 465 | |||
| 466 | #ifdef CONFIG_PROFILE_KSYM_TRACER | 446 | #ifdef CONFIG_PROFILE_KSYM_TRACER |
| 467 | static int ksym_tracer_stat_headers(struct seq_file *m) | 447 | static int ksym_profile_show(struct seq_file *m, void *v) |
| 468 | { | 448 | { |
| 449 | struct hlist_node *node; | ||
| 450 | struct trace_ksym *entry; | ||
| 451 | int access_type = 0; | ||
| 452 | char fn_name[KSYM_NAME_LEN]; | ||
| 453 | |||
| 469 | seq_puts(m, " Access Type "); | 454 | seq_puts(m, " Access Type "); |
| 470 | seq_puts(m, " Symbol Counter\n"); | 455 | seq_puts(m, " Symbol Counter\n"); |
| 471 | seq_puts(m, " ----------- "); | 456 | seq_puts(m, " ----------- "); |
| 472 | seq_puts(m, " ------ -------\n"); | 457 | seq_puts(m, " ------ -------\n"); |
| 473 | return 0; | ||
| 474 | } | ||
| 475 | 458 | ||
| 476 | static int ksym_tracer_stat_show(struct seq_file *m, void *v) | 459 | rcu_read_lock(); |
| 477 | { | 460 | hlist_for_each_entry_rcu(entry, node, &ksym_filter_head, ksym_hlist) { |
| 478 | struct hlist_node *stat = v; | ||
| 479 | struct trace_ksym *entry; | ||
| 480 | int access_type = 0; | ||
| 481 | char fn_name[KSYM_NAME_LEN]; | ||
| 482 | 461 | ||
| 483 | entry = hlist_entry(stat, struct trace_ksym, ksym_hlist); | 462 | access_type = entry->attr.bp_type; |
| 484 | 463 | ||
| 485 | access_type = entry->attr.bp_type; | 464 | switch (access_type) { |
| 465 | case HW_BREAKPOINT_R: | ||
| 466 | seq_puts(m, " R "); | ||
| 467 | break; | ||
| 468 | case HW_BREAKPOINT_W: | ||
| 469 | seq_puts(m, " W "); | ||
| 470 | break; | ||
| 471 | case HW_BREAKPOINT_R | HW_BREAKPOINT_W: | ||
| 472 | seq_puts(m, " RW "); | ||
| 473 | break; | ||
| 474 | default: | ||
| 475 | seq_puts(m, " NA "); | ||
| 476 | } | ||
| 486 | 477 | ||
| 487 | switch (access_type) { | 478 | if (lookup_symbol_name(entry->attr.bp_addr, fn_name) >= 0) |
| 488 | case HW_BREAKPOINT_R: | 479 | seq_printf(m, " %-36s", fn_name); |
| 489 | seq_puts(m, " R "); | 480 | else |
| 490 | break; | 481 | seq_printf(m, " %-36s", "<NA>"); |
| 491 | case HW_BREAKPOINT_W: | 482 | seq_printf(m, " %15llu\n", |
| 492 | seq_puts(m, " W "); | 483 | (unsigned long long)atomic64_read(&entry->counter)); |
| 493 | break; | ||
| 494 | case HW_BREAKPOINT_R | HW_BREAKPOINT_W: | ||
| 495 | seq_puts(m, " RW "); | ||
| 496 | break; | ||
| 497 | default: | ||
| 498 | seq_puts(m, " NA "); | ||
| 499 | } | 484 | } |
| 500 | 485 | rcu_read_unlock(); | |
| 501 | if (lookup_symbol_name(entry->attr.bp_addr, fn_name) >= 0) | ||
| 502 | seq_printf(m, " %-36s", fn_name); | ||
| 503 | else | ||
| 504 | seq_printf(m, " %-36s", "<NA>"); | ||
| 505 | seq_printf(m, " %15lu\n", entry->counter); | ||
| 506 | 486 | ||
| 507 | return 0; | 487 | return 0; |
| 508 | } | 488 | } |
| 509 | 489 | ||
| 510 | static void *ksym_tracer_stat_start(struct tracer_stat *trace) | 490 | static int ksym_profile_open(struct inode *node, struct file *file) |
| 511 | { | 491 | { |
| 512 | return ksym_filter_head.first; | 492 | return single_open(file, ksym_profile_show, NULL); |
| 513 | } | ||
| 514 | |||
| 515 | static void * | ||
| 516 | ksym_tracer_stat_next(void *v, int idx) | ||
| 517 | { | ||
| 518 | struct hlist_node *stat = v; | ||
| 519 | |||
| 520 | return stat->next; | ||
| 521 | } | 493 | } |
| 522 | 494 | ||
| 523 | static struct tracer_stat ksym_tracer_stats = { | 495 | static const struct file_operations ksym_profile_fops = { |
| 524 | .name = "ksym_tracer", | 496 | .open = ksym_profile_open, |
| 525 | .stat_start = ksym_tracer_stat_start, | 497 | .read = seq_read, |
| 526 | .stat_next = ksym_tracer_stat_next, | 498 | .llseek = seq_lseek, |
| 527 | .stat_headers = ksym_tracer_stat_headers, | 499 | .release = single_release, |
| 528 | .stat_show = ksym_tracer_stat_show | ||
| 529 | }; | 500 | }; |
| 501 | #endif /* CONFIG_PROFILE_KSYM_TRACER */ | ||
| 530 | 502 | ||
| 531 | __init static int ksym_tracer_stat_init(void) | 503 | __init static int init_ksym_trace(void) |
| 532 | { | 504 | { |
| 533 | int ret; | 505 | struct dentry *d_tracer; |
| 534 | 506 | ||
| 535 | ret = register_stat_tracer(&ksym_tracer_stats); | 507 | d_tracer = tracing_init_dentry(); |
| 536 | if (ret) { | ||
| 537 | printk(KERN_WARNING "Warning: could not register " | ||
| 538 | "ksym tracer stats\n"); | ||
| 539 | return 1; | ||
| 540 | } | ||
| 541 | 508 | ||
| 542 | return 0; | 509 | trace_create_file("ksym_trace_filter", 0644, d_tracer, |
| 510 | NULL, &ksym_tracing_fops); | ||
| 511 | |||
| 512 | #ifdef CONFIG_PROFILE_KSYM_TRACER | ||
| 513 | trace_create_file("ksym_profile", 0444, d_tracer, | ||
| 514 | NULL, &ksym_profile_fops); | ||
| 515 | #endif | ||
| 516 | |||
| 517 | return register_tracer(&ksym_tracer); | ||
| 543 | } | 518 | } |
| 544 | fs_initcall(ksym_tracer_stat_init); | 519 | device_initcall(init_ksym_trace); |
| 545 | #endif /* CONFIG_PROFILE_KSYM_TRACER */ | ||
