lkml.org 
[lkml]   [2017]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2] perf report: fix off-by-one for non-activation frames
Date
On Dienstag, 16. Mai 2017 18:17:26 CEST Milian Wolff wrote:
> On Dienstag, 16. Mai 2017 16:38:29 CEST Namhyung Kim wrote:
> > On Tue, May 16, 2017 at 10:59:51AM +0200, Milian Wolff wrote:
> > > As the documentation for dwfl_frame_pc says, frames that
> > > are no activation frames need to have their program counter
> > > decremented by one to properly find the function of the caller.
> > >
> > > This fixes many cases where perf report currently attributes
> > > the cost to the next line. I.e. I have code like this:
> > >
> > > ~~~~~~~~~~~~~~~
> > >
> > > #include <thread>
> > > #include <chrono>
> > >
> > > using namespace std;
> > >
> > > int main()
> > > {
> > >
> > > this_thread::sleep_for(chrono::milliseconds(1000));
> > > this_thread::sleep_for(chrono::milliseconds(100));
> > > this_thread::sleep_for(chrono::milliseconds(10));
> > >
> > > return 0;
> > >
> > > }
> > >
> > > ~~~~~~~~~~~~~~~
> >
> > It'd be nice if the test program has a signal frame for verification.
>
> I have pretty much zero experience about signals. Would it be enough to add
> a signal handler for, say, SIGUSR1 to my test application and then trigger
> a sleep when that signal is delivered? If that should be enough, I'll write
> and test it out.

~~~~~~~~~~~~~~~
#include <thread>
#include <chrono>
#include <signal.h>

using namespace std;

volatile bool run_loop = true;

void my_handler(int signum)
{
this_thread::sleep_for(chrono::milliseconds(1000));
this_thread::sleep_for(chrono::milliseconds(100));
this_thread::sleep_for(chrono::milliseconds(10));
run_loop = false;
}

int main()
{
signal(SIGUSR1, my_handler);

while (run_loop) {}

return 0;
}
~~~~~~~~~~~~~~~

This does not properly unwind neither before nor after this patch. I only ever
get:

100.00% core.c:0
|
---__schedule core.c:0
schedule
do_nanosleep hrtimer.c:0
hrtimer_nanosleep
sys_nanosleep
entry_SYSCALL_64_fastpath .tmp_entry_64.o:0
__nanosleep_nocancel .:0
std::this_thread::sleep_for<long, std::ratio<1l, 1000l> >
thread:323

So... should this work? Please tell me how to test this properly.

Thanks
--
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts[unhandled content-type:application/pkcs7-signature]
\
 
 \ /
  Last update: 2017-05-16 18:27    [W:0.080 / U:0.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site