Re: [PATCH] tracing/fgraph: support recording function return values
From: Will Deacon
Date: Mon Jul 15 2019 - 04:29:39 EST
On Sat, Jul 13, 2019 at 08:10:26PM +0800, Changbin Du wrote:
> This patch adds a new trace option 'funcgraph-retval' and is disabled by
> default. When this option is enabled, fgraph tracer will show the return
> value of each function. This is useful to find/analyze a original error
> source in a call graph.
>
> One limitation is that the kernel doesn't know the prototype of functions.
> So fgraph assumes all functions have a retvalue of type int. You must ignore
> the value of *void* function. And if the retvalue looks like an error code
> then both hexadecimal and decimal number are displayed.
This seems like quite a significant drawback and I think it could be pretty
confusing if you have to filter out bogus return values from the trace.
For example, in your snippet:
> 3) | kvm_vm_ioctl() {
> 3) | mutex_lock() {
> 3) | _cond_resched() {
> 3) 0.234 us | rcu_all_qs(); /* ret=0x80000000 */
> 3) 0.704 us | } /* ret=0x0 */
> 3) 1.226 us | } /* ret=0x0 */
> 3) 0.247 us | mutex_unlock(); /* ret=0xffff8880738ed040 */
mutex_unlock() is wrongly listed as returning something.
How much of this could be achieved from userspace by placing kretprobes on
non-void functions instead?
Will