public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] perf report: fails to symbolize when vaddr is non zero for shared objects
@ 2015-06-16  7:03 Stephane Eranian
  2015-06-16 14:34 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 4+ messages in thread
From: Stephane Eranian @ 2015-06-16  7:03 UTC (permalink / raw)
  To: LKML
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim, David Ahern,
	Peter Zijlstra, mingo@elte.hu

Hi,

It has been brought to my attention that on systems where the text
of shared libs is not loaded with a zero virtual address, perf report
fails to symbolize
correctly samples. This is true of older versions of perf and also the latest
in tip.git.

I looked at symbol-elf.c and I did not see a place where the vaddr was taken
into account from the program headers in the case of ET_DYN. I see it for
ET_EXE, though.

$ readelf -e lib.so
  Type:                              DYN (Shared object file)
  ....
  Type          Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
 LOAD           0x000000 0x0000d000 0x0000d000 0x73657c 0x73657c R E 0x1000

If you get samples in the shared lib, they will be off, possibly
attributed to the wrong
functions.

Could this be fixed quickly?
Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] perf report: fails to symbolize when vaddr is non zero for shared objects
  2015-06-16  7:03 [BUG] perf report: fails to symbolize when vaddr is non zero for shared objects Stephane Eranian
@ 2015-06-16 14:34 ` Arnaldo Carvalho de Melo
  2015-06-17 18:54   ` Stephane Eranian
  0 siblings, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-06-16 14:34 UTC (permalink / raw)
  To: Stephane Eranian
  Cc: LKML, Jiri Olsa, Namhyung Kim, David Ahern, Peter Zijlstra,
	mingo@elte.hu

Em Tue, Jun 16, 2015 at 12:03:01AM -0700, Stephane Eranian escreveu:
> Hi,
> 
> It has been brought to my attention that on systems where the text
> of shared libs is not loaded with a zero virtual address, perf report
> fails to symbolize
> correctly samples. This is true of older versions of perf and also the latest
> in tip.git.
> 
> I looked at symbol-elf.c and I did not see a place where the vaddr was taken
> into account from the program headers in the case of ET_DYN. I see it for
> ET_EXE, though.
> 
> $ readelf -e lib.so
>   Type:                              DYN (Shared object file)
>   ....
>   Type          Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>  LOAD           0x000000 0x0000d000 0x0000d000 0x73657c 0x73657c R E 0x1000
> 
> If you get samples in the shared lib, they will be off, possibly
> attributed to the wrong
> functions.
> 
> Could this be fixed quickly?

You tell me, do you have a patch to propose? :-)

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] perf report: fails to symbolize when vaddr is non zero for shared objects
  2015-06-16 14:34 ` Arnaldo Carvalho de Melo
@ 2015-06-17 18:54   ` Stephane Eranian
  2015-06-17 19:24     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 4+ messages in thread
From: Stephane Eranian @ 2015-06-17 18:54 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: LKML, Jiri Olsa, Namhyung Kim, David Ahern, Peter Zijlstra,
	mingo@elte.hu

On Tue, Jun 16, 2015 at 7:34 AM, Arnaldo Carvalho de Melo
<acme@redhat.com> wrote:
> Em Tue, Jun 16, 2015 at 12:03:01AM -0700, Stephane Eranian escreveu:
>> Hi,
>>
>> It has been brought to my attention that on systems where the text
>> of shared libs is not loaded with a zero virtual address, perf report
>> fails to symbolize
>> correctly samples. This is true of older versions of perf and also the latest
>> in tip.git.
>>
>> I looked at symbol-elf.c and I did not see a place where the vaddr was taken
>> into account from the program headers in the case of ET_DYN. I see it for
>> ET_EXE, though.
>>
>> $ readelf -e lib.so
>>   Type:                              DYN (Shared object file)
>>   ....
>>   Type          Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>>  LOAD           0x000000 0x0000d000 0x0000d000 0x73657c 0x73657c R E 0x1000
>>
>> If you get samples in the shared lib, they will be off, possibly
>> attributed to the wrong
>> functions.
>>
>> Could this be fixed quickly?
>
> You tell me, do you have a patch to propose? :-)
>
Well, need to make sure I understand the code flow in dso__load_sym()
and callers.
You have elf_read_maps() which seems to be reading the phdr but, it would need
to be called systematically for ET_DYN. I will experiment with this.
Worst case, we
need to add another function to read the phdr and use the p_vaddr.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] perf report: fails to symbolize when vaddr is non zero for shared objects
  2015-06-17 18:54   ` Stephane Eranian
@ 2015-06-17 19:24     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-06-17 19:24 UTC (permalink / raw)
  To: Stephane Eranian
  Cc: LKML, Jiri Olsa, Namhyung Kim, David Ahern, Peter Zijlstra,
	mingo@elte.hu

Em Wed, Jun 17, 2015 at 11:54:12AM -0700, Stephane Eranian escreveu:
> On Tue, Jun 16, 2015 at 7:34 AM, Arnaldo Carvalho de Melo <acme@redhat.com> wrote:
> > Em Tue, Jun 16, 2015 at 12:03:01AM -0700, Stephane Eranian escreveu:
> >> If you get samples in the shared lib, they will be off, possibly
> >> attributed to the wrong
> >> functions.
> >>
> >> Could this be fixed quickly?
> >
> > You tell me, do you have a patch to propose? :-)

> Well, need to make sure I understand the code flow in dso__load_sym()
> and callers.

> You have elf_read_maps() which seems to be reading the phdr but, it
> would need to be called systematically for ET_DYN. I will experiment
> with this.

> Worst case, we need to add another function to read the phdr and use
> the p_vaddr.

Ok, that symbols* code grew unwieldly complex, need to give it some love and
refactoring care at some point...

Thanks!

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-17 19:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-16  7:03 [BUG] perf report: fails to symbolize when vaddr is non zero for shared objects Stephane Eranian
2015-06-16 14:34 ` Arnaldo Carvalho de Melo
2015-06-17 18:54   ` Stephane Eranian
2015-06-17 19:24     ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox