Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[RFC 0/5] perf tools: Minimalistic build without libelf dependency

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


namhyung.kim at lge

May 14, 2012, 12:10 AM

Post #1 of 6 (172 views)
Permalink
[RFC 0/5] perf tools: Minimalistic build without libelf dependency

Hi,

NOTE: This is a RFC patchset and it contains a lot of rough edges
and ugly codes.

Current build procedure of perf tools requires a couple of external
libraries. Although most of them are optional, elfutils' libelf is
mandatory for resolving symbols and build-id of the binaries being
profiled. For some reason, it makes embedded guys' life harder who
want to build and run perf tools on their boards.

This patch set tries to fix the problem by letting the perf could
be built without libelf. The initial intent was just providing
perf record command to gather performance events interested on the
system and copies the data to development box to be used by perf
report for analysis.

However it's changed to have most of perf commands as is because
perf can resolve kernel symbols without libelf and many of perf
commands deal (mostly) with kernel events - so no need to restrict
capability of perf tools. Therefore, the end result is not so
minimalistic in fact and only thing it cannot do is "perf probe".

And then I realized that the perf record needs to know about the
build-id's anyway :(. So I implemented a poor man's version of elf
parser only for parsing the build-id info.

To build a minimal perf tools, pass MINIMAL=1 to make. The perf
report will not display symbol names:

# Samples: 988 of event 'cycles'
# Event count (approx.): 3726465542
#
# Overhead Command Shared Object Symbol
# ........ ....... ................. .........................
#
98.40% noploop noploop [.] 0x000000000000066d
1.35% noploop ld-2.15.so [.] 0x000000000000bab1
0.10% noploop [kernel.kallsyms] [k] native_write_msr_safe
0.10% noploop [kernel.kallsyms] [k] scheduler_tick
0.03% noploop [kernel.kallsyms] [k] bad_range
0.01% noploop [kernel.kallsyms] [k] pipe_read

But perf buildid-list can show you the build-id's:

$ ./perf buildid-list
ebfc1bdb98999c64d36ddfe394c58df3de6cbcfb [kernel.kallsyms]
52f0c5f25b95075e6fd7682763f7c3a779a4e889 /usr/lib64/ld-2.15.so
43a7a2b399b6ee2ff29c6bdadbda6bff88712ed4 /home/namhyung/bin/noploop

So it can be packed using perf archive so copied and analized
with full-fledged perf tools on a development machine.

This patchset is based on commit cb04ff9ac424 ("sched, perf: Use
a single callback into the scheduler") and tested on x86_64 and arm.

Any comments are welcome, thanks.
Namhyung


Namhyung Kim (5):
perf symbols: Introduce symbol__elf_init()
perf symbols: Do not use ELF's symbol binding constants
perf tools: Split out util/symbol-elf.c
perf tools: Support minimal build
perf symbols: Implement poor man's ELF parser

tools/perf/Makefile | 29 ++
tools/perf/builtin-buildid-list.c | 4 +-
tools/perf/builtin-top.c | 5 +-
tools/perf/command-list.txt | 2 +-
tools/perf/perf.c | 2 +
tools/perf/ui/browsers/map.c | 5 +-
tools/perf/util/elf-minimal.h | 153 ++++++++
tools/perf/util/generate-cmdlist.sh | 15 +
tools/perf/util/symbol-elf.c | 691 +++++++++++++++++++++++++++++++++
tools/perf/util/symbol-minimal.c | 258 +++++++++++++
tools/perf/util/symbol.c | 712 ++---------------------------------
tools/perf/util/symbol.h | 20 +
12 files changed, 1195 insertions(+), 701 deletions(-)
create mode 100644 tools/perf/util/elf-minimal.h
create mode 100644 tools/perf/util/symbol-elf.c
create mode 100644 tools/perf/util/symbol-minimal.c

--
1.7.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


mingo at kernel

May 14, 2012, 2:22 AM

Post #2 of 6 (164 views)
Permalink
Re: [RFC 0/5] perf tools: Minimalistic build without libelf dependency [In reply to]

* Namhyung Kim <namhyung.kim [at] lge> wrote:

> Hi,
>
> NOTE: This is a RFC patchset and it contains a lot of rough edges
> and ugly codes.
>
> Current build procedure of perf tools requires a couple of external
> libraries. Although most of them are optional, elfutils' libelf is
> mandatory for resolving symbols and build-id of the binaries being
> profiled. For some reason, it makes embedded guys' life harder who
> want to build and run perf tools on their boards.

Yeah, and this is a very useful patchset from that perspective.

> This patch set tries to fix the problem by letting the perf could
> be built without libelf. The initial intent was just providing
> perf record command to gather performance events interested on the
> system and copies the data to development box to be used by perf
> report for analysis.
>
> However it's changed to have most of perf commands as is because
> perf can resolve kernel symbols without libelf and many of perf
> commands deal (mostly) with kernel events - so no need to restrict
> capability of perf tools. Therefore, the end result is not so
> minimalistic in fact and only thing it cannot do is "perf probe".
>
> And then I realized that the perf record needs to know about the
> build-id's anyway :(. So I implemented a poor man's version of elf
> parser only for parsing the build-id info.
>
> To build a minimal perf tools, pass MINIMAL=1 to make. The perf
> report will not display symbol names:

Could we make this automatic when the required elf libraries are
not present?

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


namhyung.kim at lge

May 14, 2012, 5:40 PM

Post #3 of 6 (166 views)
Permalink
Re: [RFC 0/5] perf tools: Minimalistic build without libelf dependency [In reply to]

Hi,

On Mon, 14 May 2012 11:22:07 +0200, Ingo Molnar wrote:
> * Namhyung Kim <namhyung.kim [at] lge> wrote:
>
>> Hi,
>>
>> NOTE: This is a RFC patchset and it contains a lot of rough edges
>> and ugly codes.
>>
>> Current build procedure of perf tools requires a couple of external
>> libraries. Although most of them are optional, elfutils' libelf is
>> mandatory for resolving symbols and build-id of the binaries being
>> profiled. For some reason, it makes embedded guys' life harder who
>> want to build and run perf tools on their boards.
>
> Yeah, and this is a very useful patchset from that perspective.
>

Glad to hear that :).


>> This patch set tries to fix the problem by letting the perf could
>> be built without libelf. The initial intent was just providing
>> perf record command to gather performance events interested on the
>> system and copies the data to development box to be used by perf
>> report for analysis.
>>
>> However it's changed to have most of perf commands as is because
>> perf can resolve kernel symbols without libelf and many of perf
>> commands deal (mostly) with kernel events - so no need to restrict
>> capability of perf tools. Therefore, the end result is not so
>> minimalistic in fact and only thing it cannot do is "perf probe".
>>
>> And then I realized that the perf record needs to know about the
>> build-id's anyway :(. So I implemented a poor man's version of elf
>> parser only for parsing the build-id info.
>>
>> To build a minimal perf tools, pass MINIMAL=1 to make. The perf
>> report will not display symbol names:
>
> Could we make this automatic when the required elf libraries are
> not present?
>

Yes, I think it's doable.

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


namhyung.kim at lge

May 20, 2012, 11:00 PM

Post #4 of 6 (162 views)
Permalink
Re: [RFC 0/5] perf tools: Minimalistic build without libelf dependency [In reply to]

Hi, all

Any other comments for this?


Thanks,
Namhyung


On Mon, 14 May 2012 16:10:19 +0900, Namhyung Kim wrote:
> NOTE: This is a RFC patchset and it contains a lot of rough edges
> and ugly codes.
>
> Current build procedure of perf tools requires a couple of external
> libraries. Although most of them are optional, elfutils' libelf is
> mandatory for resolving symbols and build-id of the binaries being
> profiled. For some reason, it makes embedded guys' life harder who
> want to build and run perf tools on their boards.
>
> This patch set tries to fix the problem by letting the perf could
> be built without libelf. The initial intent was just providing
> perf record command to gather performance events interested on the
> system and copies the data to development box to be used by perf
> report for analysis.
>
> However it's changed to have most of perf commands as is because
> perf can resolve kernel symbols without libelf and many of perf
> commands deal (mostly) with kernel events - so no need to restrict
> capability of perf tools. Therefore, the end result is not so
> minimalistic in fact and only thing it cannot do is "perf probe".
>
> And then I realized that the perf record needs to know about the
> build-id's anyway :(. So I implemented a poor man's version of elf
> parser only for parsing the build-id info.
>
> To build a minimal perf tools, pass MINIMAL=1 to make. The perf
> report will not display symbol names:
>
> # Samples: 988 of event 'cycles'
> # Event count (approx.): 3726465542
> #
> # Overhead Command Shared Object Symbol
> # ........ ....... ................. .........................
> #
> 98.40% noploop noploop [.] 0x000000000000066d
> 1.35% noploop ld-2.15.so [.] 0x000000000000bab1
> 0.10% noploop [kernel.kallsyms] [k] native_write_msr_safe
> 0.10% noploop [kernel.kallsyms] [k] scheduler_tick
> 0.03% noploop [kernel.kallsyms] [k] bad_range
> 0.01% noploop [kernel.kallsyms] [k] pipe_read
>
> But perf buildid-list can show you the build-id's:
>
> $ ./perf buildid-list
> ebfc1bdb98999c64d36ddfe394c58df3de6cbcfb [kernel.kallsyms]
> 52f0c5f25b95075e6fd7682763f7c3a779a4e889 /usr/lib64/ld-2.15.so
> 43a7a2b399b6ee2ff29c6bdadbda6bff88712ed4 /home/namhyung/bin/noploop
>
> So it can be packed using perf archive so copied and analized
> with full-fledged perf tools on a development machine.
>
> This patchset is based on commit cb04ff9ac424 ("sched, perf: Use
> a single callback into the scheduler") and tested on x86_64 and arm.
>
> Any comments are welcome, thanks.
> Namhyung
>
>
> Namhyung Kim (5):
> perf symbols: Introduce symbol__elf_init()
> perf symbols: Do not use ELF's symbol binding constants
> perf tools: Split out util/symbol-elf.c
> perf tools: Support minimal build
> perf symbols: Implement poor man's ELF parser
>
> tools/perf/Makefile | 29 ++
> tools/perf/builtin-buildid-list.c | 4 +-
> tools/perf/builtin-top.c | 5 +-
> tools/perf/command-list.txt | 2 +-
> tools/perf/perf.c | 2 +
> tools/perf/ui/browsers/map.c | 5 +-
> tools/perf/util/elf-minimal.h | 153 ++++++++
> tools/perf/util/generate-cmdlist.sh | 15 +
> tools/perf/util/symbol-elf.c | 691 +++++++++++++++++++++++++++++++++
> tools/perf/util/symbol-minimal.c | 258 +++++++++++++
> tools/perf/util/symbol.c | 712 ++---------------------------------
> tools/perf/util/symbol.h | 20 +
> 12 files changed, 1195 insertions(+), 701 deletions(-)
> create mode 100644 tools/perf/util/elf-minimal.h
> create mode 100644 tools/perf/util/symbol-elf.c
> create mode 100644 tools/perf/util/symbol-minimal.c
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


dsahern at gmail

May 21, 2012, 8:03 AM

Post #5 of 6 (161 views)
Permalink
Re: [RFC 0/5] perf tools: Minimalistic build without libelf dependency [In reply to]

On 5/21/12 12:00 AM, Namhyung Kim wrote:
> Hi, all
>
> Any other comments for this?

One idea that has been proposed is to make perf configurable - to pick
and choose which pieces you want built-in. For example for target
systems only compile in record command. It seems like that part should
be done first and would potentially handle a lot of these changes.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


namhyung.kim at lge

May 21, 2012, 5:20 PM

Post #6 of 6 (158 views)
Permalink
Re: [RFC 0/5] perf tools: Minimalistic build without libelf dependency [In reply to]

Hi, David

On Mon, 21 May 2012 09:03:19 -0600, David Ahern wrote:
> One idea that has been proposed is to make perf configurable - to pick
> and choose which pieces you want built-in. For example for target
> systems only compile in record command. It seems like that part should
> be done first and would potentially handle a lot of these changes.
>

Yeah, I remember Arnaldo said about the menuconfig-like configuration
interface. But I'd like to finish this minimal build patchset first
since the configuration change can require much work on where I'm not
familiar with and I doubt the users care about it much.

Anyway, thanks for the comment.
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.