@@ -176,6 +176,27 @@ static void function_trace_start(struct trace_array *tr)
176
176
tracing_reset_online_cpus (& tr -> array_buffer );
177
177
}
178
178
179
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
180
+ static __always_inline unsigned long
181
+ function_get_true_parent_ip (unsigned long parent_ip , struct ftrace_regs * fregs )
182
+ {
183
+ unsigned long true_parent_ip ;
184
+ int idx = 0 ;
185
+
186
+ true_parent_ip = parent_ip ;
187
+ if (unlikely (parent_ip == (unsigned long )& return_to_handler ) && fregs )
188
+ true_parent_ip = ftrace_graph_ret_addr (current , & idx , parent_ip ,
189
+ (unsigned long * )ftrace_regs_get_stack_pointer (fregs ));
190
+ return true_parent_ip ;
191
+ }
192
+ #else
193
+ static __always_inline unsigned long
194
+ function_get_true_parent_ip (unsigned long parent_ip , struct ftrace_regs * fregs )
195
+ {
196
+ return parent_ip ;
197
+ }
198
+ #endif
199
+
179
200
static void
180
201
function_trace_call (unsigned long ip , unsigned long parent_ip ,
181
202
struct ftrace_ops * op , struct ftrace_regs * fregs )
@@ -192,6 +213,8 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
192
213
if (bit < 0 )
193
214
return ;
194
215
216
+ parent_ip = function_get_true_parent_ip (parent_ip , fregs );
217
+
195
218
trace_ctx = tracing_gen_ctx ();
196
219
197
220
data = this_cpu_ptr (tr -> array_buffer .data );
@@ -239,6 +262,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
239
262
* recursive protection is performed.
240
263
*/
241
264
local_irq_save (flags );
265
+ parent_ip = function_get_true_parent_ip (parent_ip , fregs );
242
266
cpu = raw_smp_processor_id ();
243
267
data = per_cpu_ptr (tr -> array_buffer .data , cpu );
244
268
disabled = atomic_inc_return (& data -> disabled );
@@ -306,6 +330,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
306
330
if (bit < 0 )
307
331
return ;
308
332
333
+ parent_ip = function_get_true_parent_ip (parent_ip , fregs );
309
334
data = this_cpu_ptr (tr -> array_buffer .data );
310
335
if (atomic_read (& data -> disabled ))
311
336
goto out ;
@@ -352,6 +377,7 @@ function_stack_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
352
377
* recursive protection is performed.
353
378
*/
354
379
local_irq_save (flags );
380
+ parent_ip = function_get_true_parent_ip (parent_ip , fregs );
355
381
cpu = raw_smp_processor_id ();
356
382
data = per_cpu_ptr (tr -> array_buffer .data , cpu );
357
383
disabled = atomic_inc_return (& data -> disabled );
0 commit comments