This is an archive of the discontinued LLVM Phabricator instance.

perf: Fix profile reading to correctly take segments into account.
ClosedPublic

Authored by tnfchris on Apr 20 2022, 6:11 AM.

Details

Reviewers
thopre
cmatthews
Summary
LNT's perf parsing implementation has a very subtle bug horrible bug:

It's assuming that the text segment starts at the same address that
the program was loaded at.  Or rather, it assumes the text segment is
at address 0.

This is usually not the case (and indeed LLD itself puts many non-exec
Segments before the first exec one)

Because of this no event is matched for certain binaries.  Also the
code can wrongly try to attribute an event to the wrong MMAP because
it only checks the starting address.  This means that the order of the
MMAPs matters and again as of a few days ago the order coming out of
LLD places the binary itself after most SOs including ld.so.

By checking only the start address we can attribute an event to an SO
instead of to the program since trivially shared libraries are
loaded before the program itself in the virtual memory space.  This
would later fail to resolve but we'd lose the event.

This patch changes it to also check for the ending position.

Diff Detail

Repository
rLNT LNT

Event Timeline

tnfchris created this revision.Apr 20 2022, 6:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 6:11 AM
tnfchris requested review of this revision.Apr 20 2022, 6:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 6:11 AM
thopre accepted this revision.Apr 20 2022, 6:32 AM

LGTM with the following description change: very subtle bug horrible bug -> very subtle *but* horrible bug

This revision is now accepted and ready to land.Apr 20 2022, 6:32 AM