Re: [BUG?] tracing/function_graph: set_graph_function was broken from 2.6.36-rc2

From: wu zhangjin
Date: Fri Jan 21 2011 - 04:27:36 EST


On Fri, Jan 21, 2011 at 1:30 AM, Steven Rostedt <srostedt@xxxxxxxxxx> wrote:
> On Thu, 2011-01-20 at 02:55 +0800, wu zhangjin wrote:
>> Hi, Steve
>>
>> Zhiping Zhong reported a problem about set_graph_function: whenever
>> users configure the entries through the tracing/set_graph_function
>> interface, the tracing result always include the other functions which
>> are not configured through the interfaces, and most of the tracing
>> result we can see are the irq related functions, which means
>> set_graph_function doesn't work as expects.
>
> It does, but you need to disable irq tracing:
>
> echo 0 > /debug/tracing/options/funcgraph-irqs
>
> Perhaps I'll make this the default :-/
>

Yeah, only If we put 0 to /debug/tracing/options/funcgraph-irqs,
otherwise, every function will be traced whenever we set the entries
through the tracing/set_graph_function interface, this may be not that
we expected ;-) set_graph_function interface should work as-is
whenever /debug/tracing/options/funcgraph-irqs is set, the cause may
be the following "if" statement:

>> trace_graph_entry():
>>
>>         [snip]
>>         /* trace it when it is-nested-in or is a function enabled. */
>>         if (!(trace->depth || ftrace_graph_addr(trace->func)) ||
>>               ftrace_graph_ignore_irqs())
>>                 return 0;
>>         [snip]
>>

By default, ftrace_graph_ignore_irqs() is false, then, if we don't put
0 to /debug/tracing/options/funcgraph-irqs, it will not return even if
we have specified some entries through the tracing/set_graph_function
interface, as a result, every function will be traced and it doesn't
work as we expected, the expected result is only the specified
functions are reserved in the tracing result.

>> A quick fix looks like this:
>>
>>         /* trace it when it is-nested-in or is a function enabled. */
>> -       if (!(trace->depth || ftrace_graph_addr(trace->func)) ||
>> -             ftrace_graph_ignore_irqs())
>> +       if (!(trace->depth || ftrace_graph_addr(trace->func) ||
>> +             !ftrace_graph_ignore_irqs()))
>>                 return 0;
>>
>> And as the git log shows, the ftrace_graph_ignore_irqs() function was
>> added from the following commit:
>>
>>           tracing: Do not trace in irq when funcgraph-irq option is zero

Regards,
Wu Zhangjin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/