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

From: Namhyung Kim
Date: Mon May 14 2012 - 03:12:46 EST


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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/