Skip to content

Commit 281b371

Browse files
author
Ingo Molnar
committed
Merge branch 'tip/tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/core
2 parents 64b9fb5 + 7b60997 commit 281b371

9 files changed

Lines changed: 38 additions & 20 deletions

File tree

‎arch/x86/kernel/ftrace.c‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,32 @@
3030

3131
#ifdef CONFIG_DYNAMIC_FTRACE
3232

33+
/*
34+
* modifying_code is set to notify NMIs that they need to use
35+
* memory barriers when entering or exiting. But we don't want
36+
* to burden NMIs with unnecessary memory barriers when code
37+
* modification is not being done (which is most of the time).
38+
*
39+
* A mutex is already held when ftrace_arch_code_modify_prepare
40+
* and post_process are called. No locks need to be taken here.
41+
*
42+
* Stop machine will make sure currently running NMIs are done
43+
* and new NMIs will see the updated variable before we need
44+
* to worry about NMIs doing memory barriers.
45+
*/
46+
static int modifying_code __read_mostly;
47+
static DEFINE_PER_CPU(int, save_modifying_code);
48+
3349
int ftrace_arch_code_modify_prepare(void)
3450
{
3551
set_kernel_text_rw();
52+
modifying_code = 1;
3653
return 0;
3754
}
3855

3956
int ftrace_arch_code_modify_post_process(void)
4057
{
58+
modifying_code = 0;
4159
set_kernel_text_ro();
4260
return 0;
4361
}
@@ -149,6 +167,11 @@ static void ftrace_mod_code(void)
149167

150168
void ftrace_nmi_enter(void)
151169
{
170+
__get_cpu_var(save_modifying_code) = modifying_code;
171+
172+
if (!__get_cpu_var(save_modifying_code))
173+
return;
174+
152175
if (atomic_inc_return(&nmi_running) & MOD_CODE_WRITE_FLAG) {
153176
smp_rmb();
154177
ftrace_mod_code();
@@ -160,6 +183,9 @@ void ftrace_nmi_enter(void)
160183

161184
void ftrace_nmi_exit(void)
162185
{
186+
if (!__get_cpu_var(save_modifying_code))
187+
return;
188+
163189
/* Finish all executions before clearing nmi_running */
164190
smp_mb();
165191
atomic_dec(&nmi_running);

‎include/linux/syscalls.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ struct perf_event_attr;
132132

133133
#define SYSCALL_TRACE_ENTER_EVENT(sname) \
134134
static const struct syscall_metadata __syscall_meta_##sname; \
135-
static struct ftrace_event_call event_enter_##sname; \
135+
static struct ftrace_event_call \
136+
__attribute__((__aligned__(4))) event_enter_##sname; \
136137
static struct trace_event enter_syscall_print_##sname = { \
137138
.trace = print_syscall_enter, \
138139
}; \
@@ -153,7 +154,8 @@ struct perf_event_attr;
153154

154155
#define SYSCALL_TRACE_EXIT_EVENT(sname) \
155156
static const struct syscall_metadata __syscall_meta_##sname; \
156-
static struct ftrace_event_call event_exit_##sname; \
157+
static struct ftrace_event_call \
158+
__attribute__((__aligned__(4))) event_exit_##sname; \
157159
static struct trace_event exit_syscall_print_##sname = { \
158160
.trace = print_syscall_exit, \
159161
}; \

‎include/trace/ftrace.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
};
6666
#undef DEFINE_EVENT
6767
#define DEFINE_EVENT(template, name, proto, args) \
68-
static struct ftrace_event_call event_##name
68+
static struct ftrace_event_call \
69+
__attribute__((__aligned__(4))) event_##name
6970

7071
#undef DEFINE_EVENT_PRINT
7172
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \

‎kernel/trace/Kconfig‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,6 @@ config BRANCH_TRACER
328328

329329
Say N if unsure.
330330

331-
config POWER_TRACER
332-
bool "Trace power consumption behavior"
333-
depends on X86
334-
select GENERIC_TRACER
335-
help
336-
This tracer helps developers to analyze and optimize the kernel's
337-
power management decisions, specifically the C-state and P-state
338-
behavior.
339-
340331
config KSYM_TRACER
341332
bool "Trace read and write access on kernel memory locations"
342333
depends on HAVE_HW_BREAKPOINT

‎kernel/trace/trace.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,8 @@ extern const char *__stop___trace_bprintk_fmt[];
792792

793793
#undef FTRACE_ENTRY
794794
#define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \
795-
extern struct ftrace_event_call event_##call;
795+
extern struct ftrace_event_call \
796+
__attribute__((__aligned__(4))) event_##call;
796797
#undef FTRACE_ENTRY_DUP
797798
#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \
798799
FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))

‎kernel/trace/trace_events.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ int trace_define_field(struct ftrace_event_call *call, const char *type,
6060
return 0;
6161

6262
err:
63-
if (field) {
63+
if (field)
6464
kfree(field->name);
65-
kfree(field->type);
66-
}
6765
kfree(field);
6866

6967
return -ENOMEM;

‎kernel/trace/trace_functions_graph.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
855855
int i;
856856

857857
if (data) {
858-
int cpu = iter->cpu;
859858
int *depth = &(per_cpu_ptr(data->cpu_data, cpu)->depth);
860859

861860
/*

‎kernel/trace/trace_kprobe.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,12 +651,12 @@ static int create_trace_probe(int argc, char **argv)
651651
event = strchr(group, '/') + 1;
652652
event[-1] = '\0';
653653
if (strlen(group) == 0) {
654-
pr_info("Group name is not specifiled\n");
654+
pr_info("Group name is not specified\n");
655655
return -EINVAL;
656656
}
657657
}
658658
if (strlen(event) == 0) {
659-
pr_info("Event name is not specifiled\n");
659+
pr_info("Event name is not specified\n");
660660
return -EINVAL;
661661
}
662662
}

‎kernel/trace/trace_syscalls.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ int prof_sysexit_enable(struct ftrace_event_call *call)
603603
ret = register_trace_sys_exit(prof_syscall_exit);
604604
if (ret) {
605605
pr_info("event trace: Could not activate"
606-
"syscall entry trace point");
606+
"syscall exit trace point");
607607
} else {
608608
set_bit(num, enabled_prof_exit_syscalls);
609609
sys_prof_refcount_exit++;

0 commit comments

Comments
 (0)