aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/ftrace.h29
-rw-r--r--arch/x86/kernel/entry_64.S57
-rw-r--r--kernel/trace/ring_buffer.c2
-rw-r--r--kernel/trace/trace.c25
-rw-r--r--kernel/trace/trace.h3
5 files changed, 63 insertions, 53 deletions
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index 7e61b4ceb9a4..b55b4a7fbefd 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -1,6 +1,33 @@
1#ifndef _ASM_X86_FTRACE_H 1#ifndef _ASM_X86_FTRACE_H
2#define _ASM_X86_FTRACE_H 2#define _ASM_X86_FTRACE_H
3 3
4#ifdef __ASSEMBLY__
5
6 .macro MCOUNT_SAVE_FRAME
7 /* taken from glibc */
8 subq $0x38, %rsp
9 movq %rax, (%rsp)
10 movq %rcx, 8(%rsp)
11 movq %rdx, 16(%rsp)
12 movq %rsi, 24(%rsp)
13 movq %rdi, 32(%rsp)
14 movq %r8, 40(%rsp)
15 movq %r9, 48(%rsp)
16 .endm
17
18 .macro MCOUNT_RESTORE_FRAME
19 movq 48(%rsp), %r9
20 movq 40(%rsp), %r8
21 movq 32(%rsp), %rdi
22 movq 24(%rsp), %rsi
23 movq 16(%rsp), %rdx
24 movq 8(%rsp), %rcx
25 movq (%rsp), %rax
26 addq $0x38, %rsp
27 .endm
28
29#endif
30
4#ifdef CONFIG_FUNCTION_TRACER 31#ifdef CONFIG_FUNCTION_TRACER
5#define MCOUNT_ADDR ((long)(mcount)) 32#define MCOUNT_ADDR ((long)(mcount))
6#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ 33#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
@@ -46,7 +73,7 @@ struct ftrace_ret_stack {
46/* 73/*
47 * Primary handler of a function return. 74 * Primary handler of a function return.
48 * It relays on ftrace_return_to_handler. 75 * It relays on ftrace_return_to_handler.
49 * Defined in entry32.S 76 * Defined in entry_32/64.S
50 */ 77 */
51extern void return_to_handler(void); 78extern void return_to_handler(void);
52 79
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 54e0bbdccb99..303dd84d2a98 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -71,15 +71,7 @@ ENTRY(ftrace_caller)
71 cmpl $0, function_trace_stop 71 cmpl $0, function_trace_stop
72 jne ftrace_stub 72 jne ftrace_stub
73 73
74 /* taken from glibc */ 74 MCOUNT_SAVE_FRAME
75 subq $0x38, %rsp
76 movq %rax, (%rsp)
77 movq %rcx, 8(%rsp)
78 movq %rdx, 16(%rsp)
79 movq %rsi, 24(%rsp)
80 movq %rdi, 32(%rsp)
81 movq %r8, 40(%rsp)
82 movq %r9, 48(%rsp)
83 75
84 movq 0x38(%rsp), %rdi 76 movq 0x38(%rsp), %rdi
85 movq 8(%rbp), %rsi 77 movq 8(%rbp), %rsi
@@ -89,14 +81,7 @@ ENTRY(ftrace_caller)
89ftrace_call: 81ftrace_call:
90 call ftrace_stub 82 call ftrace_stub
91 83
92 movq 48(%rsp), %r9 84 MCOUNT_RESTORE_FRAME
93 movq 40(%rsp), %r8
94 movq 32(%rsp), %rdi
95 movq 24(%rsp), %rsi
96 movq 16(%rsp), %rdx
97 movq 8(%rsp), %rcx
98 movq (%rsp), %rax
99 addq $0x38, %rsp
100 85
101#ifdef CONFIG_FUNCTION_GRAPH_TRACER 86#ifdef CONFIG_FUNCTION_GRAPH_TRACER
102.globl ftrace_graph_call 87.globl ftrace_graph_call
@@ -130,15 +115,7 @@ ftrace_stub:
130 retq 115 retq
131 116
132trace: 117trace:
133 /* taken from glibc */ 118 MCOUNT_SAVE_FRAME
134 subq $0x38, %rsp
135 movq %rax, (%rsp)
136 movq %rcx, 8(%rsp)
137 movq %rdx, 16(%rsp)
138 movq %rsi, 24(%rsp)
139 movq %rdi, 32(%rsp)
140 movq %r8, 40(%rsp)
141 movq %r9, 48(%rsp)
142 119
143 movq 0x38(%rsp), %rdi 120 movq 0x38(%rsp), %rdi
144 movq 8(%rbp), %rsi 121 movq 8(%rbp), %rsi
@@ -146,14 +123,7 @@ trace:
146 123
147 call *ftrace_trace_function 124 call *ftrace_trace_function
148 125
149 movq 48(%rsp), %r9 126 MCOUNT_RESTORE_FRAME
150 movq 40(%rsp), %r8
151 movq 32(%rsp), %rdi
152 movq 24(%rsp), %rsi
153 movq 16(%rsp), %rdx
154 movq 8(%rsp), %rcx
155 movq (%rsp), %rax
156 addq $0x38, %rsp
157 127
158 jmp ftrace_stub 128 jmp ftrace_stub
159END(mcount) 129END(mcount)
@@ -165,14 +135,7 @@ ENTRY(ftrace_graph_caller)
165 cmpl $0, function_trace_stop 135 cmpl $0, function_trace_stop
166 jne ftrace_stub 136 jne ftrace_stub
167 137
168 subq $0x38, %rsp 138 MCOUNT_SAVE_FRAME
169 movq %rax, (%rsp)
170 movq %rcx, 8(%rsp)
171 movq %rdx, 16(%rsp)
172 movq %rsi, 24(%rsp)
173 movq %rdi, 32(%rsp)
174 movq %r8, 40(%rsp)
175 movq %r9, 48(%rsp)
176 139
177 leaq 8(%rbp), %rdi 140 leaq 8(%rbp), %rdi
178 movq 0x38(%rsp), %rsi 141 movq 0x38(%rsp), %rsi
@@ -180,14 +143,8 @@ ENTRY(ftrace_graph_caller)
180 143
181 call prepare_ftrace_return 144 call prepare_ftrace_return
182 145
183 movq 48(%rsp), %r9 146 MCOUNT_RESTORE_FRAME
184 movq 40(%rsp), %r8 147
185 movq 32(%rsp), %rdi
186 movq 24(%rsp), %rsi
187 movq 16(%rsp), %rdx
188 movq 8(%rsp), %rcx
189 movq (%rsp), %rax
190 addq $0x38, %rsp
191 retq 148 retq
192END(ftrace_graph_caller) 149END(ftrace_graph_caller)
193 150
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 7f69cfeaadf7..eab81f918f6a 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -107,7 +107,7 @@ u64 ring_buffer_time_stamp(int cpu)
107 preempt_disable_notrace(); 107 preempt_disable_notrace();
108 /* shift to debug/test normalization and TIME_EXTENTS */ 108 /* shift to debug/test normalization and TIME_EXTENTS */
109 time = sched_clock() << DEBUG_SHIFT; 109 time = sched_clock() << DEBUG_SHIFT;
110 preempt_enable_notrace(); 110 preempt_enable_no_resched_notrace();
111 111
112 return time; 112 return time;
113} 113}
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 639344a4d3a2..1a3d6b329782 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -287,6 +287,7 @@ static const char *trace_options[] = {
287 "annotate", 287 "annotate",
288 "userstacktrace", 288 "userstacktrace",
289 "sym-userobj", 289 "sym-userobj",
290 "printk-msg-only",
290 NULL 291 NULL
291}; 292};
292 293
@@ -2265,6 +2266,25 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
2265 return TRACE_TYPE_HANDLED; 2266 return TRACE_TYPE_HANDLED;
2266} 2267}
2267 2268
2269static enum print_line_t print_printk_msg_only(struct trace_iterator *iter)
2270{
2271 struct trace_seq *s = &iter->seq;
2272 struct trace_entry *entry = iter->ent;
2273 struct print_entry *field;
2274 int ret;
2275
2276 trace_assign_type(field, entry);
2277
2278 ret = trace_seq_printf(s, field->buf);
2279 if (!ret)
2280 return TRACE_TYPE_PARTIAL_LINE;
2281
2282 if (entry->flags & TRACE_FLAG_CONT)
2283 trace_seq_print_cont(s, iter);
2284
2285 return TRACE_TYPE_HANDLED;
2286}
2287
2268static enum print_line_t print_bin_fmt(struct trace_iterator *iter) 2288static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
2269{ 2289{
2270 struct trace_seq *s = &iter->seq; 2290 struct trace_seq *s = &iter->seq;
@@ -2345,6 +2365,11 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
2345 return ret; 2365 return ret;
2346 } 2366 }
2347 2367
2368 if (iter->ent->type == TRACE_PRINT &&
2369 trace_flags & TRACE_ITER_PRINTK &&
2370 trace_flags & TRACE_ITER_PRINTK_MSGONLY)
2371 return print_printk_msg_only(iter);
2372
2348 if (trace_flags & TRACE_ITER_BIN) 2373 if (trace_flags & TRACE_ITER_BIN)
2349 return print_bin_fmt(iter); 2374 return print_bin_fmt(iter);
2350 2375
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index f07c246dd73d..fc75dce7a664 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -578,7 +578,8 @@ enum trace_iterator_flags {
578 TRACE_ITER_BRANCH = 0x1000, 578 TRACE_ITER_BRANCH = 0x1000,
579 TRACE_ITER_ANNOTATE = 0x2000, 579 TRACE_ITER_ANNOTATE = 0x2000,
580 TRACE_ITER_USERSTACKTRACE = 0x4000, 580 TRACE_ITER_USERSTACKTRACE = 0x4000,
581 TRACE_ITER_SYM_USEROBJ = 0x8000 581 TRACE_ITER_SYM_USEROBJ = 0x8000,
582 TRACE_ITER_PRINTK_MSGONLY = 0x10000
582}; 583};
583 584
584/* 585/*