lkml.org 
[lkml]   [2022]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 3/9] LoongArch/ftrace: Add dynamic function tracer support
From
Date


On 2022/9/1 上午10:59, Jeff Xie wrote:
> On Fri, Aug 26, 2022 at 4:24 PM Qing Zhang <zhangqing@loongson.cn> wrote:
>>
>> The compiler has inserted 2 NOPs before the regular function prologue.
>> T series registers are available and safe because of LoongArch psABI.
>>
>> At runtime, replace nop with bl to enable ftrace call and replace bl with
>> nop to disable ftrace call. The bl requires us to save the original RA value,
>> so here it saves RA at t0.
>> details are:
>>
>> | Compiled | Disabled | Enabled |
>> +------------+------------------------+------------------------+
>> | nop | move t0, ra | move t0, ra |
>> | nop | nop | bl ftrace_caller |
>> | func_body | func_body | func_body |
>>
>> The RA value will be recovered by ftrace_regs_entry, and restored into RA
>> before returning to the regular function prologue. When a function is not
>> being traced, the move t0, ra is not harmful.
>>
>> 1) ftrace_make_call, ftrace_make_nop (in kernel/ftrace.c)
>> The two functions turn each recorded call site of filtered functions
>> into a call to ftrace_caller or nops.
>>
>> 2) ftracce_update_ftrace_func (in kernel/ftrace.c)
>> turns the nops at ftrace_call into a call to a generic entry for
>> function tracers.
>>
>> 3) ftrace_caller (in kernel/mcount-dyn.S)
>> The entry where each _mcount call sites calls to once they are
>> filtered to be traced.
>>
[...]
>>
>
> When use the option func_stack_trace for the function tracer, I found a issue:
>
> Steps:
> 1. Enable the function tracer and the option func_stack_trace:
>
> /sys/kernel/tracing # echo blk_update_request > ./set_ftrace_filter
> /sys/kernel/tracing # echo 1 > ./options/func_stack_trace
> /sys/kernel/tracing # echo function > ./current_tracer
>
> 2. Let the blk_update_request() be called.
>
> # mount /dev/vda /tmp
>
>
> 3. cat ./trace
> <idle>-0 [000] ..s1. 126.016445: blk_update_request
> <-blk_mq_end_request
> <idle>-0 [000] ..s1. 126.017937: <stack trace>
> => blk_mq_end_request
>
> We can see only one stack trace.
>
>
> I found the default unwinder(for loongson3_defconfig) is
> CONFIG_UNWINDER_PROLOGUE, if switch it to CONFIG_UNWINDER_GUESS
> it works well:
>
[...]
>
> Maybe the issue happened on the CONFIG_UNWINDER_PROLOGUE, but I
> haven't dug deep into it ;)

Hi, Jeff

Thanks a lot for your feedback!

I fixed it in v3, which was caused by the ftrace_regs_entry assembly not
being considered by the prologue analyze method. :)

regards
-Qing

>

\
 
 \ /
  Last update: 2022-09-03 02:40    [W:0.475 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site