linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Milian Wolff <milian.wolff@kdab.com>,
	Linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Namhyung Kim <namhyung@kernel.org>,
	acme@kernel.org, Jan Kratochvil <jkratoch@redhat.com>
Subject: Re: [PATCH 2/2] perf report: report module before querying isactivation in dwfl unwind
Date: Mon, 5 Jun 2017 12:47:20 +0200	[thread overview]
Message-ID: <20170605104720.GC28871@krava> (raw)
In-Reply-To: <20170602152508.GC7901@redhat.com>

On Fri, Jun 02, 2017 at 12:25:08PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Jun 02, 2017 at 04:37:53PM +0200, Milian Wolff escreveu:
> > The PC returned by dwfl_frame_pc may map into a not-yet-reported
> > module. We have to report it before we continue unwinding. But when
> > we query for the isactivation flag in dwfl_frame_pc, libdw will
> > actually do one more unwinding step internally which can then break
> > and lead to missed frames or broken stacks.
> > 
> > With libunwind we get e.g.:

sounds like a libdw design issue.. Jan is there a specific way
to handle the case that Milian described?

thanks,
jirka

> 
> Thanks,
> 
> - Arnaldo
>  
> > ~~~~~
> > heaptrack_gui  2228 135073.400474:     613969 cycles:
> > 	          108c8e [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1093bc [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          109e7b QLocale::QLocale (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1470ff [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          147f67 QSystemLocale::query (/usr/lib/libQt5Core.so.5.8.0)
> > 	          109fbf QLocalePrivate::updateSystemPrivate (/usr/lib/libQt5Core.so.5.8.0)
> > 	          10aa27 QLocale::QLocale (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1e02c3 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          2113bb [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          211505 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1b5df0 QFileInfo::exists (/usr/lib/libQt5Core.so.5.8.0)
> > 	           92eb2 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	           93423 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	           93d2a QLibraryInfo::location (/usr/lib/libQt5Core.so.5.8.0)
> > 	          2170af [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          297c53 QCoreApplicationPrivate::init (/usr/lib/libQt5Core.so.5.8.0)
> > 	           f7cde QGuiApplicationPrivate::init (/usr/lib/libQt5Gui.so.5.8.0)
> > 	          1589e8 QApplicationPrivate::init (/usr/lib/libQt5Widgets.so.5.8.0)
> > 	           78622 main (/home/milian/projects/compiled/other/bin/heaptrack_gui)
> > 	           20439 __libc_start_main (/usr/lib/libc-2.25.so)
> > 	           78299 _start (/home/milian/projects/compiled/other/bin/heaptrack_gui)
> > 
> > heaptrack_gui  2228 135073.401156:     569521 cycles:
> > 	          131633 QString::endsWith (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1a0701 QDir::cleanPath (/usr/lib/libQt5Core.so.5.8.0)
> > 	          21b82d [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1b3727 QFileInfo::canonicalFilePath (/usr/lib/libQt5Core.so.5.8.0)
> > 	          2780c7 QFactoryLoader::update (/usr/lib/libQt5Core.so.5.8.0)
> > 	          279525 QFactoryLoader::QFactoryLoader (/usr/lib/libQt5Core.so.5.8.0)
> > 	           e5bd0 QPlatformIntegrationFactory::create (/usr/lib/libQt5Gui.so.5.8.0)
> > 	           f5a1c QGuiApplicationPrivate::createPlatformIntegration (/usr/lib/libQt5Gui.so.5.8.0)
> > 	           f650c QGuiApplicationPrivate::createEventDispatcher (/usr/lib/libQt5Gui.so.5.8.0)
> > 	          298524 QCoreApplicationPrivate::init (/usr/lib/libQt5Core.so.5.8.0)
> > 	           f7cde QGuiApplicationPrivate::init (/usr/lib/libQt5Gui.so.5.8.0)
> > 	          1589e8 QApplicationPrivate::init (/usr/lib/libQt5Widgets.so.5.8.0)
> > 	           78622 main (/home/milian/projects/compiled/other/bin/heaptrack_gui)
> > 	           20439 __libc_start_main (/usr/lib/libc-2.25.so)
> > 	           78299 _start (/home/milian/projects/compiled/other/bin/heaptrack_gui)
> > ~~~~~
> > 
> > Note the two frames 1589e8 and 78622 in the first sample. These are
> > missing when unwinding with libdw. The second sample's breakage is
> > more obvious:
> > 
> > ~~~~~
> > heaptrack_gui  2228 135073.400474:     613969 cycles:
> > 	          108c8e [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1093bc [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          109e7b QLocale::QLocale (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1470ff [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          147f67 QSystemLocale::query (/usr/lib/libQt5Core.so.5.8.0)
> > 	          109fbf QLocalePrivate::updateSystemPrivate (/usr/lib/libQt5Core.so.5.8.0)
> > 	          10aa27 QLocale::QLocale (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1e02c3 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          2113bb [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          211505 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1b5df0 QFileInfo::exists (/usr/lib/libQt5Core.so.5.8.0)
> > 	           92eb2 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	           93423 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	           93d2a QLibraryInfo::location (/usr/lib/libQt5Core.so.5.8.0)
> > 	          2170af [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          297c53 QCoreApplicationPrivate::init (/usr/lib/libQt5Core.so.5.8.0)
> > 	           f7cde QGuiApplicationPrivate::init (/usr/lib/libQt5Gui.so.5.8.0)
> > 	           20439 __libc_start_main (/usr/lib/libc-2.25.so)
> > 	           78299 _start (/home/milian/projects/compiled/other/bin/heaptrack_gui)
> > 
> > heaptrack_gui  2228 135073.401156:     569521 cycles:
> > 	          131633 QString::endsWith (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1a0701 QDir::cleanPath (/usr/lib/libQt5Core.so.5.8.0)
> > 	          21b82d [unknown] (/usr/lib/libQt5Core.so.5.8.0)
> > 	          1b3727 QFileInfo::canonicalFilePath (/usr/lib/libQt5Core.so.5.8.0)
> > 	          2780c7 QFactoryLoader::update (/usr/lib/libQt5Core.so.5.8.0)
> > 	          279525 QFactoryLoader::QFactoryLoader (/usr/lib/libQt5Core.so.5.8.0)
> > 	           e5bd0 QPlatformIntegrationFactory::create (/usr/lib/libQt5Gui.so.5.8.0)
> > 	          723dbf [unknown] ([unknown])
> > ~~~~~
> > 
> > This patch fixes this issue and the libdw unwinder mimicks the
> > libunwind behavior more closely.
> > 
> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Jiri Olsa <jolsa@redhat.com>
> > Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
> > ---
> >  tools/perf/util/unwind-libdw.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
> > index da45c4be5fb3..7755a5e0fe5e 100644
> > --- a/tools/perf/util/unwind-libdw.c
> > +++ b/tools/perf/util/unwind-libdw.c
> > @@ -178,6 +178,14 @@ frame_callback(Dwfl_Frame *state, void *arg)
> >  	Dwarf_Addr pc;
> >  	bool isactivation;
> >  
> > +	if (!dwfl_frame_pc(state, &pc, NULL)) {
> > +		pr_err("%s", dwfl_errmsg(-1));
> > +		return DWARF_CB_ABORT;
> > +	}
> > +
> > +	// report the module before we query for isactivation
> > +	report_module(pc, ui);
> > +
> >  	if (!dwfl_frame_pc(state, &pc, &isactivation)) {
> >  		pr_err("%s", dwfl_errmsg(-1));
> >  		return DWARF_CB_ABORT;
> > -- 
> > 2.13.0

  reply	other threads:[~2017-06-05 10:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 14:37 [PATCH 1/2] perf report: ensure the perf DSO mapping matches what libdw sees Milian Wolff
2017-06-02 14:37 ` [PATCH 2/2] perf report: report module before querying isactivation in dwfl unwind Milian Wolff
2017-06-02 15:25   ` Arnaldo Carvalho de Melo
2017-06-05 10:47     ` Jiri Olsa [this message]
2017-06-15 19:20       ` Jan Kratochvil
2017-06-16 16:06     ` Arnaldo Carvalho de Melo
2017-06-16 17:36       ` Arnaldo Carvalho de Melo
2017-06-02 15:23 ` [PATCH 1/2] perf report: ensure the perf DSO mapping matches what libdw sees Arnaldo Carvalho de Melo
2017-06-02 16:21   ` Milian Wolff
2017-06-02 19:49     ` Arnaldo Carvalho de Melo
2017-06-03 11:36       ` Milian Wolff
2017-06-05 10:41 ` Jiri Olsa
2017-06-15 20:38   ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170605104720.GC28871@krava \
    --to=jolsa@redhat.com \
    --cc=Linux-kernel@vger.kernel.org \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jkratoch@redhat.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=milian.wolff@kdab.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).