2014-02-24 19:58:08

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [GIT PULL 00/12] perf/core improvements and fixes

From: Arnaldo Carvalho de Melo <[email protected]>

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit 7e74efcf76c16f851df5c838c143c4a1865ea9fa:

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2014-02-22 17:26:24 +0100)

are available in the git repository at:


git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo

for you to fetch changes up to 1029f9fedf87fa6f52096991588fa54ffd159584:

perf symbols: Check compatible symtab type before loading dso (2014-02-24 16:25:01 -0300)

----------------------------------------------------------------
perf/core improvements and fixes

. Add support for the new DWARF unwinder library in elfutils (Jiri Olsa)

. Fix build race in the generation of bison files (Jiri Olsa)

. Further streamline the feature detection display, trimming it a bit to
show just the libraries detected, using VF=1 gets a more verbose output,
showing the less interesting feature checks as well (Jiri Olsa).

. Check compatible symtab type before loading dso (Namhyung Kim)

. Check return value of filename__read_debuglink() (Stephane Eranian)

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
perf tools: Warn the user about how to enable libunwind support

Jiri Olsa (9):
perf tests: Fix *.o make tests
perf tests: Add pmu-bison.o make test
perf tools: Fix bison OUTPUT directories dependency
perf tools: Factor features display code
perf tools: Add variable display for VF make output
perf tools: Add feature check for libdw dwarf unwind
perf tools: Add libdw DWARF post unwind support
perf tools: Setup default dwarf post unwinder
perf tests: Add NO_LIBDW_DWARF_UNWIND make test

Namhyung Kim (1):
perf symbols: Check compatible symtab type before loading dso

Stephane Eranian (1):
perf symbols: Check return value of filename__read_debuglink()

tools/perf/Makefile.perf | 24 ++-
tools/perf/arch/x86/Makefile | 5 +
tools/perf/arch/x86/util/unwind-libdw.c | 51 +++++
tools/perf/config/Makefile | 232 +++++++++++++++------
tools/perf/config/feature-checks/Makefile | 6 +-
tools/perf/config/feature-checks/test-all.c | 5 +
.../feature-checks/test-libdw-dwarf-unwind.c | 13 ++
tools/perf/tests/make | 25 ++-
tools/perf/util/dso.c | 4 +-
tools/perf/util/symbol-elf.c | 2 +
tools/perf/util/symbol.c | 61 +++++-
tools/perf/util/unwind-libdw.c | 210 +++++++++++++++++++
tools/perf/util/unwind-libdw.h | 21 ++
13 files changed, 569 insertions(+), 90 deletions(-)
create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
create mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
create mode 100644 tools/perf/util/unwind-libdw.c
create mode 100644 tools/perf/util/unwind-libdw.h


2014-02-24 19:56:58

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 08/12] perf tools: Add libdw DWARF post unwind support

From: Jiri Olsa <[email protected]>

Adding libdw DWARF post unwind support, which is part of
elfutils-devel/libdw-dev package from version 0.158.

The new code is contained in unwin-libdw.c object, and implements
unwind__get_entries unwind interface function.

New Makefile variable NO_LIBDW_DWARF_UNWIND was added to control its
compilation, and is marked as disabled now. It's factored with the rest
of the Makefile unwind build code in the next patch.

Arch specific code was added for x86.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/Makefile.perf | 11 ++
tools/perf/arch/x86/Makefile | 3 +
tools/perf/arch/x86/util/unwind-libdw.c | 51 ++++++++
tools/perf/config/Makefile | 1 +
tools/perf/util/unwind-libdw.c | 210 ++++++++++++++++++++++++++++++++
tools/perf/util/unwind-libdw.h | 21 ++++
6 files changed, 297 insertions(+)
create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
create mode 100644 tools/perf/util/unwind-libdw.c
create mode 100644 tools/perf/util/unwind-libdw.h

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index bde91f8307ff..2dff0b8ed611 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -57,6 +57,12 @@ include config/utilities.mak
# Define NO_LIBAUDIT if you do not want libaudit support
#
# Define NO_LIBBIONIC if you do not want bionic support
+#
+# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
+# for dwarf backtrace post unwind.
+
+# temporarily disabled
+NO_LIBDW_DWARF_UNWIND := 1

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
@@ -478,6 +484,11 @@ ifndef NO_DWARF
endif # NO_DWARF
endif # NO_LIBELF

+ifndef NO_LIBDW_DWARF_UNWIND
+ LIB_OBJS += $(OUTPUT)util/unwind-libdw.o
+ LIB_H += util/unwind-libdw.h
+endif
+
ifndef NO_LIBUNWIND
LIB_OBJS += $(OUTPUT)util/unwind-libunwind.o
endif
diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 4fa9be983ad1..37c4652cc48a 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -7,6 +7,9 @@ LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/dwarf-unwind.o
endif
+ifndef NO_LIBDW_DWARF_UNWIND
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libdw.o
+endif
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o
LIB_H += arch/$(ARCH)/util/tsc.h
diff --git a/tools/perf/arch/x86/util/unwind-libdw.c b/tools/perf/arch/x86/util/unwind-libdw.c
new file mode 100644
index 000000000000..c4b72176ca83
--- /dev/null
+++ b/tools/perf/arch/x86/util/unwind-libdw.c
@@ -0,0 +1,51 @@
+#include <elfutils/libdwfl.h>
+#include "../../util/unwind-libdw.h"
+#include "../../util/perf_regs.h"
+
+bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
+{
+ struct unwind_info *ui = arg;
+ struct regs_dump *user_regs = &ui->sample->user_regs;
+ Dwarf_Word dwarf_regs[17];
+ unsigned nregs;
+
+#define REG(r) ({ \
+ Dwarf_Word val = 0; \
+ perf_reg_value(&val, user_regs, PERF_REG_X86_##r); \
+ val; \
+})
+
+ if (user_regs->abi == PERF_SAMPLE_REGS_ABI_32) {
+ dwarf_regs[0] = REG(AX);
+ dwarf_regs[1] = REG(CX);
+ dwarf_regs[2] = REG(DX);
+ dwarf_regs[3] = REG(BX);
+ dwarf_regs[4] = REG(SP);
+ dwarf_regs[5] = REG(BP);
+ dwarf_regs[6] = REG(SI);
+ dwarf_regs[7] = REG(DI);
+ dwarf_regs[8] = REG(IP);
+ nregs = 9;
+ } else {
+ dwarf_regs[0] = REG(AX);
+ dwarf_regs[1] = REG(DX);
+ dwarf_regs[2] = REG(CX);
+ dwarf_regs[3] = REG(BX);
+ dwarf_regs[4] = REG(SI);
+ dwarf_regs[5] = REG(DI);
+ dwarf_regs[6] = REG(BP);
+ dwarf_regs[7] = REG(SP);
+ dwarf_regs[8] = REG(R8);
+ dwarf_regs[9] = REG(R9);
+ dwarf_regs[10] = REG(R10);
+ dwarf_regs[11] = REG(R11);
+ dwarf_regs[12] = REG(R12);
+ dwarf_regs[13] = REG(R13);
+ dwarf_regs[14] = REG(R14);
+ dwarf_regs[15] = REG(R15);
+ dwarf_regs[16] = REG(IP);
+ nregs = 17;
+ }
+
+ return dwfl_thread_state_registers(thread, 0, nregs, dwarf_regs);
+}
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 074fa618cc7b..c040d8618793 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -261,6 +261,7 @@ ifdef NO_LIBELF
NO_DWARF := 1
NO_DEMANGLE := 1
NO_LIBUNWIND := 1
+ NO_LIBDW_DWARF_UNWIND := 1
else
ifeq ($(feature-libelf), 0)
ifeq ($(feature-glibc), 1)
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
new file mode 100644
index 000000000000..67db73ec3dab
--- /dev/null
+++ b/tools/perf/util/unwind-libdw.c
@@ -0,0 +1,210 @@
+#include <linux/compiler.h>
+#include <elfutils/libdw.h>
+#include <elfutils/libdwfl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include "unwind.h"
+#include "unwind-libdw.h"
+#include "machine.h"
+#include "thread.h"
+#include "types.h"
+#include "event.h"
+#include "perf_regs.h"
+
+static char *debuginfo_path;
+
+static const Dwfl_Callbacks offline_callbacks = {
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ .debuginfo_path = &debuginfo_path,
+ .section_address = dwfl_offline_section_address,
+};
+
+static int __report_module(struct addr_location *al, u64 ip,
+ struct unwind_info *ui)
+{
+ Dwfl_Module *mod;
+ struct dso *dso = NULL;
+
+ thread__find_addr_location(ui->thread, ui->machine,
+ PERF_RECORD_MISC_USER,
+ MAP__FUNCTION, ip, al);
+
+ if (al->map)
+ dso = al->map->dso;
+
+ if (!dso)
+ return 0;
+
+ mod = dwfl_addrmodule(ui->dwfl, ip);
+ if (!mod)
+ mod = dwfl_report_elf(ui->dwfl, dso->short_name,
+ dso->long_name, -1, al->map->start,
+ false);
+
+ return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1;
+}
+
+static int report_module(u64 ip, struct unwind_info *ui)
+{
+ struct addr_location al;
+
+ return __report_module(&al, ip, ui);
+}
+
+static int entry(u64 ip, struct unwind_info *ui)
+
+{
+ struct unwind_entry e;
+ struct addr_location al;
+
+ if (__report_module(&al, ip, ui))
+ return -1;
+
+ e.ip = ip;
+ e.map = al.map;
+ e.sym = al.sym;
+
+ pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n",
+ al.sym ? al.sym->name : "''",
+ ip,
+ al.map ? al.map->map_ip(al.map, ip) : (u64) 0);
+
+ return ui->cb(&e, ui->arg);
+}
+
+static pid_t next_thread(Dwfl *dwfl, void *arg, void **thread_argp)
+{
+ /* We want only single thread to be processed. */
+ if (*thread_argp != NULL)
+ return 0;
+
+ *thread_argp = arg;
+ return dwfl_pid(dwfl);
+}
+
+static int access_dso_mem(struct unwind_info *ui, Dwarf_Addr addr,
+ Dwarf_Word *data)
+{
+ struct addr_location al;
+ ssize_t size;
+
+ thread__find_addr_map(ui->thread, ui->machine, PERF_RECORD_MISC_USER,
+ MAP__FUNCTION, addr, &al);
+ if (!al.map) {
+ pr_debug("unwind: no map for %lx\n", (unsigned long)addr);
+ return -1;
+ }
+
+ if (!al.map->dso)
+ return -1;
+
+ size = dso__data_read_addr(al.map->dso, al.map, ui->machine,
+ addr, (u8 *) data, sizeof(*data));
+
+ return !(size == sizeof(*data));
+}
+
+static bool memory_read(Dwfl *dwfl __maybe_unused, Dwarf_Addr addr, Dwarf_Word *result,
+ void *arg)
+{
+ struct unwind_info *ui = arg;
+ struct stack_dump *stack = &ui->sample->user_stack;
+ u64 start, end;
+ int offset;
+ int ret;
+
+ ret = perf_reg_value(&start, &ui->sample->user_regs, PERF_REG_SP);
+ if (ret)
+ return false;
+
+ end = start + stack->size;
+
+ /* Check overflow. */
+ if (addr + sizeof(Dwarf_Word) < addr)
+ return false;
+
+ if (addr < start || addr + sizeof(Dwarf_Word) > end) {
+ ret = access_dso_mem(ui, addr, result);
+ if (ret) {
+ pr_debug("unwind: access_mem 0x%" PRIx64 " not inside range"
+ " 0x%" PRIx64 "-0x%" PRIx64 "\n",
+ addr, start, end);
+ return false;
+ }
+ return true;
+ }
+
+ offset = addr - start;
+ *result = *(Dwarf_Word *)&stack->data[offset];
+ pr_debug("unwind: access_mem addr 0x%" PRIx64 ", val %lx, offset %d\n",
+ addr, (unsigned long)*result, offset);
+ return true;
+}
+
+static const Dwfl_Thread_Callbacks callbacks = {
+ .next_thread = next_thread,
+ .memory_read = memory_read,
+ .set_initial_registers = libdw__arch_set_initial_registers,
+};
+
+static int
+frame_callback(Dwfl_Frame *state, void *arg)
+{
+ struct unwind_info *ui = arg;
+ Dwarf_Addr pc;
+
+ if (!dwfl_frame_pc(state, &pc, NULL)) {
+ pr_err("%s", dwfl_errmsg(-1));
+ return DWARF_CB_ABORT;
+ }
+
+ return entry(pc, ui) || !(--ui->max_stack) ?
+ DWARF_CB_ABORT : DWARF_CB_OK;
+}
+
+int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
+ struct machine *machine, struct thread *thread,
+ struct perf_sample *data,
+ int max_stack)
+{
+ struct unwind_info ui = {
+ .sample = data,
+ .thread = thread,
+ .machine = machine,
+ .cb = cb,
+ .arg = arg,
+ .max_stack = max_stack,
+ };
+ Dwarf_Word ip;
+ int err = -EINVAL;
+
+ if (!data->user_regs.regs)
+ return -EINVAL;
+
+ ui.dwfl = dwfl_begin(&offline_callbacks);
+ if (!ui.dwfl)
+ goto out;
+
+ err = perf_reg_value(&ip, &data->user_regs, PERF_REG_IP);
+ if (err)
+ goto out;
+
+ err = report_module(ip, &ui);
+ if (err)
+ goto out;
+
+ if (!dwfl_attach_state(ui.dwfl, EM_NONE, thread->tid, &callbacks, &ui))
+ goto out;
+
+ err = dwfl_getthread_frames(ui.dwfl, thread->tid, frame_callback, &ui);
+
+ if (err && !ui.max_stack)
+ err = 0;
+
+ out:
+ if (err)
+ pr_debug("unwind: failed with '%s'\n", dwfl_errmsg(-1));
+
+ dwfl_end(ui.dwfl);
+ return 0;
+}
diff --git a/tools/perf/util/unwind-libdw.h b/tools/perf/util/unwind-libdw.h
new file mode 100644
index 000000000000..417a1426f3ad
--- /dev/null
+++ b/tools/perf/util/unwind-libdw.h
@@ -0,0 +1,21 @@
+#ifndef __PERF_UNWIND_LIBDW_H
+#define __PERF_UNWIND_LIBDW_H
+
+#include <elfutils/libdwfl.h>
+#include "event.h"
+#include "thread.h"
+#include "unwind.h"
+
+bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg);
+
+struct unwind_info {
+ Dwfl *dwfl;
+ struct perf_sample *sample;
+ struct machine *machine;
+ struct thread *thread;
+ unwind_entry_cb_t cb;
+ void *arg;
+ int max_stack;
+};
+
+#endif /* __PERF_UNWIND_LIBDW_H */
--
1.8.1.4

2014-02-24 19:57:19

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 06/12] perf tools: Warn the user about how to enable libunwind support

From: Arnaldo Carvalho de Melo <[email protected]>

When one has libunwind installed somewhere the perf tools build process
doesn't expects it to be, this happens:

[acme@ssdandy linux]$ make O=/tmp/build/perf -C tools/perf/ install-bin
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j8' parallel build
config/Makefile:312: No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1

Auto-detecting system features:
<SNIP>
... libunwind: [ OFF ]

Change the message so that it tells how to use a non-standard libunwind
install directory:

config/Makefile:312: No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR

[acme@ssdandy linux]$ make LIBUNWIND_DIR=/opt/libunwind-git/ O=/tmp/build/perf -C tools/perf/ install-bin
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j8' parallel build

Auto-detecting system features:
<SNIP>
... libunwind: [ on ]

Acked-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/config/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 97a64c4631d3..9429805f395c 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -309,7 +309,7 @@ endif # NO_LIBELF

ifndef NO_LIBUNWIND
ifneq ($(feature-libunwind), 1)
- msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1);
+ msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
NO_LIBUNWIND := 1
else
ifeq ($(ARCH),arm)
--
1.8.1.4

2014-02-24 19:57:39

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 12/12] perf symbols: Check compatible symtab type before loading dso

From: Namhyung Kim <[email protected]>

When loading a dso it'll look for symbol tables of all possible types.
However it's just wasted of time to check incompatible types - like
trying kernel module when loading user library.

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Cody P Schafer <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/symbol.c | 61 +++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 52 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 46e2ede12c51..0ada68b3b096 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1251,6 +1251,46 @@ out_failure:
return -1;
}

+static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
+ enum dso_binary_type type)
+{
+ switch (type) {
+ case DSO_BINARY_TYPE__JAVA_JIT:
+ case DSO_BINARY_TYPE__DEBUGLINK:
+ case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
+ case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
+ case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
+ case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
+ case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
+ return !kmod && dso->kernel == DSO_TYPE_USER;
+
+ case DSO_BINARY_TYPE__KALLSYMS:
+ case DSO_BINARY_TYPE__VMLINUX:
+ case DSO_BINARY_TYPE__KCORE:
+ return dso->kernel == DSO_TYPE_KERNEL;
+
+ case DSO_BINARY_TYPE__GUEST_KALLSYMS:
+ case DSO_BINARY_TYPE__GUEST_VMLINUX:
+ case DSO_BINARY_TYPE__GUEST_KCORE:
+ return dso->kernel == DSO_TYPE_GUEST_KERNEL;
+
+ case DSO_BINARY_TYPE__GUEST_KMODULE:
+ case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE:
+ /*
+ * kernel modules know their symtab type - it's set when
+ * creating a module dso in machine__new_module().
+ */
+ return kmod && dso->symtab_type == type;
+
+ case DSO_BINARY_TYPE__BUILD_ID_CACHE:
+ return true;
+
+ case DSO_BINARY_TYPE__NOT_FOUND:
+ default:
+ return false;
+ }
+}
+
int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
{
char *name;
@@ -1261,6 +1301,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
int ss_pos = 0;
struct symsrc ss_[2];
struct symsrc *syms_ss = NULL, *runtime_ss = NULL;
+ bool kmod;

dso__set_loaded(dso, map->type);

@@ -1301,7 +1342,11 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
if (!name)
return -1;

- /* Iterate over candidate debug images.
+ kmod = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
+ dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE;
+
+ /*
+ * Iterate over candidate debug images.
* Keep track of "interesting" ones (those which have a symtab, dynsym,
* and/or opd section) for processing.
*/
@@ -1311,6 +1356,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)

enum dso_binary_type symtab_type = binary_type_symtab[i];

+ if (!dso__is_compatible_symtab_type(dso, kmod, symtab_type))
+ continue;
+
if (dso__read_binary_type_filename(dso, symtab_type,
root_dir, name, PATH_MAX))
continue;
@@ -1351,15 +1399,10 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
if (!runtime_ss && syms_ss)
runtime_ss = syms_ss;

- if (syms_ss) {
- int km;
-
- km = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
- dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE;
- ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, km);
- } else {
+ if (syms_ss)
+ ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, kmod);
+ else
ret = -1;
- }

if (ret > 0) {
int nr_plt;
--
1.8.1.4

2014-02-24 19:56:55

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 10/12] perf tests: Add NO_LIBDW_DWARF_UNWIND make test

From: Jiri Olsa <[email protected]>

Adding make test for NO_LIBDW_DWARF_UNWIND option, plus updating minimal
build test with it.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/tests/make | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 2d2495423be5..5daeae1cb4c0 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -27,6 +27,7 @@ make_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_demangle := NO_DEMANGLE=1
make_no_libelf := NO_LIBELF=1
make_no_libunwind := NO_LIBUNWIND=1
+make_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1
make_no_backtrace := NO_BACKTRACE=1
make_no_libnuma := NO_LIBNUMA=1
make_no_libaudit := NO_LIBAUDIT=1
@@ -50,6 +51,7 @@ make_install_pdf := install-pdf
make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
+make_minimal += NO_LIBDW_DWARF_UNWIND=1

# $(run) contains all available tests
run := make_pure
@@ -66,6 +68,7 @@ run += make_no_ui
run += make_no_demangle
run += make_no_libelf
run += make_no_libunwind
+run += make_no_libdw_dwarf_unwind
run += make_no_backtrace
run += make_no_libnuma
run += make_no_libaudit
--
1.8.1.4

2014-02-24 19:58:11

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 02/12] perf tests: Add pmu-bison.o make test

From: Jiri Olsa <[email protected]>

Adding pmu-bison.o make test:

$ make -f tests/make make_util_pmu_bison_o
- make_util_pmu_bison_o: cd . && make -f Makefile DESTDIR=/tmp/tmp.0u99hQn8Ga util/pmu-bison.o
$ make -f tests/make make_util_pmu_bison_o_O
- make_util_pmu_bison_o_O: cd . && make -f Makefile O=/tmp/tmp.sWKDLGS71O DESTDIR=/tmp/tmp.htQNJAfJ0d util/pmu-bison.o
make: *** [make_util_pmu_bison_o_O] Error 1

The 'O=' version of the test is failing at the moment, due to the OUTPUT
directory issue fixed in next patch.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/tests/make | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index eb3671be129c..2d2495423be5 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -35,8 +35,9 @@ make_tags := tags
make_cscope := cscope
make_help := help
make_doc := doc
-make_perf_o := perf.o
-make_util_map_o := util/map.o
+make_perf_o := perf.o
+make_util_map_o := util/map.o
+make_util_pmu_bison_o := util/pmu-bison.o
make_install := install
make_install_bin := install-bin
make_install_doc := install-doc
@@ -73,6 +74,7 @@ run += make_help
run += make_doc
run += make_perf_o
run += make_util_map_o
+run += make_util_pmu_bison_o
run += make_install
run += make_install_bin
# FIXME 'install-*' commented out till they're fixed
@@ -113,8 +115,9 @@ test_make_doc_O := $(test_ok)

test_make_python_perf_so := test -f $(PERF)/python/perf.so

-test_make_perf_o := test -f $(PERF)/perf.o
-test_make_util_map_o := test -f $(PERF)/util/map.o
+test_make_perf_o := test -f $(PERF)/perf.o
+test_make_util_map_o := test -f $(PERF)/util/map.o
+test_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o

define test_dest_files
for file in $(1); do \
@@ -170,6 +173,7 @@ test_make_install_pdf_O := $(test_ok)
test_make_python_perf_so_O := test -f $$TMP_O/python/perf.so
test_make_perf_o_O := test -f $$TMP_O/perf.o
test_make_util_map_o_O := test -f $$TMP_O/util/map.o
+test_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o

test_default = test -x $(PERF)/perf
test = $(if $(test_$1),$(test_$1),$(test_default))
--
1.8.1.4

2014-02-24 19:56:54

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 05/12] perf tools: Add variable display for VF make output

From: Jiri Olsa <[email protected]>

Adding dump of interesting build directories to the make VF=1 output.

$ make VF=1
BUILD: Doing 'make -j4' parallel build

Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libunwind: [ on ]
... backtrace: [ on ]
... fortify-source: [ on ]
... gtk2-infobar: [ on ]
... libelf-getphdrnum: [ on ]
... libelf-mmap: [ on ]
... libpython-version: [ on ]
... on-exit: [ on ]
... stackprotector-all: [ on ]
... timerfd: [ on ]
... libunwind-debug-frame: [ OFF ]
... bionic: [ OFF ]

... prefix: /home/jolsa
... bindir: /home/jolsa/bin
... libdir: /home/jolsa/lib64
... sysconfdir: /home/jolsa/etc

Adding functions to print variable/text in features display -
feature_print_var/feature_print_text (feature_print_text is used in next
patches).

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/config/Makefile | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 39e6e6cca8ed..97a64c4631d3 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -591,9 +591,9 @@ endif
#
# Print the result of the feature test:
#
-feature_print = $(eval $(feature_print_code)) $(info $(MSG))
+feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))

-define feature_print_code
+define feature_print_status_code
ifeq ($(feature-$(1)), 1)
MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
else
@@ -601,6 +601,16 @@ define feature_print_code
endif
endef

+feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
+define feature_print_var_code
+ MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
+endef
+
+feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
+define feature_print_text_code
+ MSG = $(shell printf '...%30s: %s' $(1) $(2))
+endef
+
PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)

@@ -633,11 +643,16 @@ endif
ifeq ($(display_lib),1)
$(info )
$(info Auto-detecting system features:)
- $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print,$(feat),))
+ $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
endif

ifeq ($(display_vf),1)
- $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print,$(feat),))
+ $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
+ $(info )
+ $(call feature_print_var,prefix)
+ $(call feature_print_var,bindir)
+ $(call feature_print_var,libdir)
+ $(call feature_print_var,sysconfdir)
endif

ifeq ($(display_lib),1)
--
1.8.1.4

2014-02-24 19:58:52

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 01/12] perf tests: Fix *.o make tests

From: Jiri Olsa <[email protected]>

Enable and fix *.o object make tests. Following tests are now available:

$ make -f tests/make make_perf_o_O
- make_perf_o_O: cd . && make -f Makefile O=/tmp/tmp.iF5vI5emGy DESTDIR=/tmp/tmp.epDPFVhH0s perf.o
$ make -f tests/make make_util_map_o_O
- make_util_map_o_O: cd . && make -f Makefile O=/tmp/tmp.BWuMf55ygC DESTDIR=/tmp/tmp.QbGBRF95oP util/map.o

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/tests/make | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 00544b8b644b..eb3671be129c 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -167,13 +167,9 @@ test_make_install_info_O := $(test_ok)
test_make_install_pdf := $(test_ok)
test_make_install_pdf_O := $(test_ok)

-# Kbuild tests only
-#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
-#test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o
-#test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o
-
-test_make_perf_o_O := true
-test_make_util_map_o_O := true
+test_make_python_perf_so_O := test -f $$TMP_O/python/perf.so
+test_make_perf_o_O := test -f $$TMP_O/perf.o
+test_make_util_map_o_O := test -f $$TMP_O/util/map.o

test_default = test -x $(PERF)/perf
test = $(if $(test_$1),$(test_$1),$(test_default))
--
1.8.1.4

2014-02-24 19:58:50

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 11/12] perf symbols: Check return value of filename__read_debuglink()

From: Stephane Eranian <[email protected]>

When dso__read_binary_type_filename() called, it doesn't check the
return value of filename__read_debuglink() so that it'll try to open the
debuglink file even if it doesn't exist.

Also fix return value of the filename__read_debuglink() as it always
return -1 regardless of the result.

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Cody P Schafer <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/dso.c | 4 ++--
tools/perf/util/symbol-elf.c | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 4045d086d9d9..64453d63b971 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -45,8 +45,8 @@ int dso__read_binary_type_filename(const struct dso *dso,
debuglink--;
if (*debuglink == '/')
debuglink++;
- filename__read_debuglink(dso->long_name, debuglink,
- size - (debuglink - filename));
+ ret = filename__read_debuglink(dso->long_name, debuglink,
+ size - (debuglink - filename));
}
break;
case DSO_BINARY_TYPE__BUILD_ID_CACHE:
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 3e9f336740fa..8ac4a4fe2abd 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -506,6 +506,8 @@ int filename__read_debuglink(const char *filename, char *debuglink,
/* the start of this section is a zero-terminated string */
strncpy(debuglink, data->d_buf, size);

+ err = 0;
+
out_elf_end:
elf_end(elf);
out_close:
--
1.8.1.4

2014-02-24 19:59:36

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 04/12] perf tools: Factor features display code

From: Jiri Olsa <[email protected]>

Currently the we display all detected features/libraries by following
rules:

- if one of the features is missing
- if it's build from clean tree

This patch changes changes this behavior in several ways.

- We no longer display all detected features, only detected libraries
are displayed by default:

$ make
BUILD: Doing 'make -j4' parallel build

Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libunwind: [ on ]

The assumption is, that above libraries are the most interesting part
of the detection, while we don't care much about detection of on-exit
support.

- If all above libraries are detected, the default is not shown on
subsequent builds.

- If one of the above libraries is missing, the detection output is
forced.

- The features status is stored in PERF-FEATURES file and the detection
output is forced in case the there's difference between the file
contents and currently detected features.

- If you want to see all detected features, you can use VF=1 make
variable, that forces the detected features output.

$ make VF=1
BUILD: Doing 'make -j4' parallel build

Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libunwind: [ on ]
... backtrace: [ on ]
... fortify-source: [ on ]
... gtk2-infobar: [ on ]
... libelf-getphdrnum: [ on ]
... libelf-mmap: [ on ]
... libpython-version: [ on ]
... on-exit: [ on ]
... stackprotector-all: [ on ]
... timerfd: [ on ]
... libunwind-debug-frame: [ OFF ]
... bionic: [ OFF ]

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/Makefile.perf | 4 +-
tools/perf/config/Makefile | 123 ++++++++++++++++++++++++++++++---------------
2 files changed, 85 insertions(+), 42 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 5fedd6946f32..bde91f8307ff 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -7,6 +7,8 @@ include config/utilities.mak

# Define V to have a more verbose compile.
#
+# Define VF to have a more verbose feature check output.
+#
# Define O to save output files in a separate directory.
#
# Define ARCH as name of target architecture if you want cross-builds.
@@ -897,7 +899,7 @@ config-clean:
clean: $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean config-clean
$(call QUIET_CLEAN, core-objs) $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS) $(GTK_OBJS)
$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf
- $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex*
+ $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)PERF-FEATURES $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex*
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
$(python-clean)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 1686583ff7fc..39e6e6cca8ed 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -149,6 +149,32 @@ CORE_FEATURE_TESTS = \
stackprotector-all \
timerfd

+LIB_FEATURE_TESTS = \
+ dwarf \
+ glibc \
+ gtk2 \
+ libaudit \
+ libbfd \
+ libelf \
+ libnuma \
+ libperl \
+ libpython \
+ libslang \
+ libunwind
+
+VF_FEATURE_TESTS = \
+ backtrace \
+ fortify-source \
+ gtk2-infobar \
+ libelf-getphdrnum \
+ libelf-mmap \
+ libpython-version \
+ on-exit \
+ stackprotector-all \
+ timerfd \
+ libunwind-debug-frame \
+ bionic
+
# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
# If in the future we need per-feature checks/flags for features not
# mentioned in this list we need to refactor this ;-).
@@ -161,17 +187,6 @@ endef
$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))

#
-# So here we detect whether test-all was rebuilt, to be able
-# to skip the print-out of the long features list if the file
-# existed before and after it was built:
-#
-ifeq ($(wildcard $(OUTPUT)config/feature-checks/test-all.bin),)
- test-all-failed := 1
-else
- test-all-failed := 0
-endif
-
-#
# Special fast-path for the 'all features are available' case:
#
$(call feature_check,all,$(MSG))
@@ -180,15 +195,6 @@ $(call feature_check,all,$(MSG))
# Just in case the build freshly failed, make sure we print the
# feature matrix:
#
-ifeq ($(feature-all), 0)
- test-all-failed := 1
-endif
-
-ifeq ($(test-all-failed),1)
- $(info )
- $(info Auto-detecting system features:)
-endif
-
ifeq ($(feature-all), 1)
#
# test-all.c passed - just set all the core feature flags to 1:
@@ -199,27 +205,6 @@ else
$(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
endif

-#
-# Print the result of the feature test:
-#
-feature_print = $(eval $(feature_print_code)) $(info $(MSG))
-
-define feature_print_code
- ifeq ($(feature-$(1)), 1)
- MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
- else
- MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
- endif
-endef
-
-#
-# Only print out our features if we rebuilt the testcases or if a test failed:
-#
-ifeq ($(test-all-failed), 1)
- $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_print,$(feat)))
- $(info )
-endif
-
ifeq ($(feature-stackprotector-all), 1)
CFLAGS += -fstack-protector-all
endif
@@ -602,3 +587,59 @@ ifdef DESTDIR
plugindir=$(libdir)/traceevent/plugins
plugindir_SQ= $(subst ','\'',$(plugindir))
endif
+
+#
+# Print the result of the feature test:
+#
+feature_print = $(eval $(feature_print_code)) $(info $(MSG))
+
+define feature_print_code
+ ifeq ($(feature-$(1)), 1)
+ MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
+ else
+ MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
+ endif
+endef
+
+PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
+PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
+
+# The $(display_lib) controls the default detection message
+# output. It's set if:
+# - detected features differes from stored features from
+# last build (in PERF-FEATURES file)
+# - one of the $(LIB_FEATURE_TESTS) is not detected
+# - VF is enabled
+
+ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
+ $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
+ display_lib := 1
+endif
+
+feature_check = $(eval $(feature_check_code))
+define feature_check_code
+ ifneq ($(feature-$(1)), 1)
+ display_lib := 1
+ endif
+endef
+
+$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
+
+ifeq ($(VF),1)
+ display_lib := 1
+ display_vf := 1
+endif
+
+ifeq ($(display_lib),1)
+ $(info )
+ $(info Auto-detecting system features:)
+ $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print,$(feat),))
+endif
+
+ifeq ($(display_vf),1)
+ $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print,$(feat),))
+endif
+
+ifeq ($(display_lib),1)
+ $(info )
+endif
--
1.8.1.4

2014-02-24 19:59:39

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 03/12] perf tools: Fix bison OUTPUT directories dependency

From: Jiri Olsa <[email protected]>

The bison and flex C objects don't have dependency for creating output
directories.

This could lead to build failure if the one of those objects is picked
up by make to be build as the first one (reported by Arnaldo).

Also following make fails:
$ rm -rf /tmp/krava; mkdir /tmp/krava; make O=/tmp/krava util/pmu-bison.o
BUILD: Doing 'make -j4' parallel build
[ SNIP ]
BISON /tmp/krava/util/pmu-bison.c
FLAGS: * new build flags or prefix
bison: /tmp/krava/util/pmu-bison.output: cannot open: No such file or directory
make[1]: *** [/tmp/krava/util/pmu-bison.c] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [util/pmu-bison.o] Error 2

Adding bison objects dependency for output directories (flex objects
depends on bisons').

This fixies the make_util_pmu_bison_o_O make test.

Reported-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/Makefile.perf | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 77b153fa23a5..5fedd6946f32 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -712,9 +712,15 @@ $(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
# we depend the various files onto their directories.
DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(GTK_OBJS)
DIRECTORY_DEPS += $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
-$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
+# no need to add flex objects, because they depend on bison ones
+DIRECTORY_DEPS += $(OUTPUT)util/parse-events-bison.c
+DIRECTORY_DEPS += $(OUTPUT)util/pmu-bison.c
+
+OUTPUT_DIRECTORIES := $(sort $(dir $(DIRECTORY_DEPS)))
+
+$(DIRECTORY_DEPS): | $(OUTPUT_DIRECTORIES)
# In the second step, we make a rule to actually create these directories
-$(sort $(dir $(DIRECTORY_DEPS))):
+$(OUTPUT_DIRECTORIES):
$(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null

$(LIB_FILE): $(LIB_OBJS)
--
1.8.1.4

2014-02-24 19:59:38

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 09/12] perf tools: Setup default dwarf post unwinder

From: Jiri Olsa <[email protected]>

Factor NO_LIBDW_DWARF_UNWIND makefile variable and code that selects
default DWARf post unwinder based on detected features (libdw and
libunwind support)

If both are detected the libunwind is selected as default. Simple
'make' will try to add:

- libunwind unwinder if present
- libdw unwinder if present
- disable dwarf unwind if non of libunwind and libdw
libraries are present

If one of the DWARF unwind libraries is detected, message is displayed
which one (libunwind/libdw) is compiled in.

Examples:
- compile in libdw unwinder if present:

$ make NO_LIBUNWIND=1

- compile in libdw (with libdw installation directory) unwinder if present:

$ make LIBDW_DIR=/opt/elfutils/ NO_LIBUNWIND=1
BUILD: Doing 'make -j4' parallel build

Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ on ]
... DWARF post unwind library: libdw

- disable post dwarf unwind completely:

$ make NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1
BUILD: Doing 'make -j4' parallel build

Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ on ]
... DWARF post unwind library: libunwind

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ Add suggestion about setting LIBDW_DIR when not finding libdw ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/Makefile.perf | 5 +--
tools/perf/arch/x86/Makefile | 6 ++--
tools/perf/config/Makefile | 78 ++++++++++++++++++++++++++++++++++----------
3 files changed, 66 insertions(+), 23 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 2dff0b8ed611..1f7ec48ac959 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -61,9 +61,6 @@ include config/utilities.mak
# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
# for dwarf backtrace post unwind.

-# temporarily disabled
-NO_LIBDW_DWARF_UNWIND := 1
-
ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
@@ -412,7 +409,7 @@ endif
LIB_OBJS += $(OUTPUT)tests/code-reading.o
LIB_OBJS += $(OUTPUT)tests/sample-parsing.o
LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o
-ifndef NO_LIBUNWIND
+ifndef NO_DWARF_UNWIND
ifeq ($(ARCH),x86)
LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o
endif
diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 37c4652cc48a..1641542e3636 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -4,12 +4,14 @@ LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
endif
ifndef NO_LIBUNWIND
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o
-LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o
-LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/dwarf-unwind.o
endif
ifndef NO_LIBDW_DWARF_UNWIND
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libdw.o
endif
+ifndef NO_DWARF_UNWIND
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/dwarf-unwind.o
+endif
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o
LIB_H += arch/$(ARCH)/util/tsc.h
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index c040d8618793..f7c81d3e2422 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -159,7 +159,8 @@ CORE_FEATURE_TESTS = \
libunwind \
on-exit \
stackprotector-all \
- timerfd
+ timerfd \
+ libdw-dwarf-unwind

LIB_FEATURE_TESTS = \
dwarf \
@@ -172,7 +173,8 @@ LIB_FEATURE_TESTS = \
libperl \
libpython \
libslang \
- libunwind
+ libunwind \
+ libdw-dwarf-unwind

VF_FEATURE_TESTS = \
backtrace \
@@ -280,6 +282,12 @@ else
msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
endif
else
+ ifndef NO_LIBDW_DWARF_UNWIND
+ ifneq ($(feature-libdw-dwarf-unwind),1)
+ NO_LIBDW_DWARF_UNWIND := 1
+ msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR);
+ endif
+ endif
ifneq ($(feature-dwarf), 1)
msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
NO_DWARF := 1
@@ -315,25 +323,51 @@ endif # NO_LIBELF

ifndef NO_LIBUNWIND
ifneq ($(feature-libunwind), 1)
- msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
+ msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
NO_LIBUNWIND := 1
+ endif
+endif
+
+dwarf-post-unwind := 1
+dwarf-post-unwind-text := BUG
+
+# setup DWARF post unwinder
+ifdef NO_LIBUNWIND
+ ifdef NO_LIBDW_DWARF_UNWIND
+ msg := $(warning Disabling post unwind, no support found.);
+ dwarf-post-unwind := 0
else
- ifeq ($(ARCH),arm)
- $(call feature_check,libunwind-debug-frame)
- ifneq ($(feature-libunwind-debug-frame), 1)
- msg := $(warning No debug_frame support found in libunwind);
- CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
- endif
- else
- # non-ARM has no dwarf_find_debug_frame() function:
+ dwarf-post-unwind-text := libdw
+ endif
+else
+ dwarf-post-unwind-text := libunwind
+ # Enable libunwind support by default.
+ ifndef NO_LIBDW_DWARF_UNWIND
+ NO_LIBDW_DWARF_UNWIND := 1
+ endif
+endif
+
+ifeq ($(dwarf-post-unwind),1)
+ CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT
+else
+ NO_DWARF_UNWIND := 1
+endif
+
+ifndef NO_LIBUNWIND
+ ifeq ($(ARCH),arm)
+ $(call feature_check,libunwind-debug-frame)
+ ifneq ($(feature-libunwind-debug-frame), 1)
+ msg := $(warning No debug_frame support found in libunwind);
CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
endif
-
- CFLAGS += -DHAVE_DWARF_UNWIND_SUPPORT -DHAVE_LIBUNWIND_SUPPORT
- EXTLIBS += $(LIBUNWIND_LIBS)
- CFLAGS += $(LIBUNWIND_CFLAGS)
- LDFLAGS += $(LIBUNWIND_LDFLAGS)
- endif # ifneq ($(feature-libunwind), 1)
+ else
+ # non-ARM has no dwarf_find_debug_frame() function:
+ CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
+ endif
+ CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
+ EXTLIBS += $(LIBUNWIND_LIBS)
+ CFLAGS += $(LIBUNWIND_CFLAGS)
+ LDFLAGS += $(LIBUNWIND_LDFLAGS)
endif

ifndef NO_LIBAUDIT
@@ -620,6 +654,10 @@ endef
PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)

+ifeq ($(dwarf-post-unwind),1)
+ PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
+endif
+
# The $(display_lib) controls the default detection message
# output. It's set if:
# - detected features differes from stored features from
@@ -650,6 +688,10 @@ ifeq ($(display_lib),1)
$(info )
$(info Auto-detecting system features:)
$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
+
+ ifeq ($(dwarf-post-unwind),1)
+ $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
+ endif
endif

ifeq ($(display_vf),1)
@@ -659,6 +701,8 @@ ifeq ($(display_vf),1)
$(call feature_print_var,bindir)
$(call feature_print_var,libdir)
$(call feature_print_var,sysconfdir)
+ $(call feature_print_var,LIBUNWIND_DIR)
+ $(call feature_print_var,LIBDW_DIR)
endif

ifeq ($(display_lib),1)
--
1.8.1.4

2014-02-24 20:00:47

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 07/12] perf tools: Add feature check for libdw dwarf unwind

From: Jiri Olsa <[email protected]>

Adding feature check test code for libdw dwarf unwind.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/config/Makefile | 19 ++++++++++++-------
tools/perf/config/feature-checks/Makefile | 6 +++++-
tools/perf/config/feature-checks/test-all.c | 5 +++++
.../config/feature-checks/test-libdw-dwarf-unwind.c | 13 +++++++++++++
4 files changed, 35 insertions(+), 8 deletions(-)
create mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 9429805f395c..074fa618cc7b 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -59,6 +59,18 @@ ifeq ($(NO_PERF_REGS),0)
CFLAGS += -DHAVE_PERF_REGS_SUPPORT
endif

+ifndef NO_LIBELF
+ # for linking with debug library, run like:
+ # make DEBUG=1 LIBDW_DIR=/opt/libdw/
+ ifdef LIBDW_DIR
+ LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
+ LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
+
+ FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
+ FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) -ldw
+ endif
+endif
+
# include ARCH specific config
-include $(src-perf)/arch/$(ARCH)/Makefile

@@ -267,13 +279,6 @@ else
msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
endif
else
- # for linking with debug library, run like:
- # make DEBUG=1 LIBDW_DIR=/opt/libdw/
- ifdef LIBDW_DIR
- LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
- LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
- endif
-
ifneq ($(feature-dwarf), 1)
msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
NO_DWARF := 1
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 12e551346fa6..2b492f5480e2 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -26,7 +26,8 @@ FILES= \
test-libunwind-debug-frame.bin \
test-on-exit.bin \
test-stackprotector-all.bin \
- test-timerfd.bin
+ test-timerfd.bin \
+ test-libdw-dwarf-unwind.bin

CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
@@ -141,6 +142,9 @@ test-backtrace.bin:
test-timerfd.bin:
$(BUILD)

+test-libdw-dwarf-unwind.bin:
+ $(BUILD)
+
-include *.d

###############################
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
index 9b8a544155bb..fc37eb3ca17b 100644
--- a/tools/perf/config/feature-checks/test-all.c
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -89,6 +89,10 @@
# include "test-stackprotector-all.c"
#undef main

+#define main main_test_libdw_dwarf_unwind
+# include "test-libdw-dwarf-unwind.c"
+#undef main
+
int main(int argc, char *argv[])
{
main_test_libpython();
@@ -111,6 +115,7 @@ int main(int argc, char *argv[])
main_test_libnuma();
main_test_timerfd();
main_test_stackprotector_all();
+ main_test_libdw_dwarf_unwind();

return 0;
}
diff --git a/tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c b/tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
new file mode 100644
index 000000000000..f676a3ff442a
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
@@ -0,0 +1,13 @@
+
+#include <elfutils/libdwfl.h>
+
+int main(void)
+{
+ /*
+ * This function is guarded via: __nonnull_attribute__ (1, 2).
+ * Passing '1' as arguments value. This code is never executed,
+ * only compiled.
+ */
+ dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
+ return 0;
+}
--
1.8.1.4

2014-02-27 11:47:06

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL 00/12] perf/core improvements and fixes


* Arnaldo Carvalho de Melo <[email protected]> wrote:

> From: Arnaldo Carvalho de Melo <[email protected]>
>
> Hi Ingo,
>
> Please consider pulling,
>
> - Arnaldo
>
> The following changes since commit 7e74efcf76c16f851df5c838c143c4a1865ea9fa:
>
> Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2014-02-22 17:26:24 +0100)
>
> are available in the git repository at:
>
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo
>
> for you to fetch changes up to 1029f9fedf87fa6f52096991588fa54ffd159584:
>
> perf symbols: Check compatible symtab type before loading dso (2014-02-24 16:25:01 -0300)
>
> ----------------------------------------------------------------
> perf/core improvements and fixes
>
> . Add support for the new DWARF unwinder library in elfutils (Jiri Olsa)
>
> . Fix build race in the generation of bison files (Jiri Olsa)
>
> . Further streamline the feature detection display, trimming it a bit to
> show just the libraries detected, using VF=1 gets a more verbose output,
> showing the less interesting feature checks as well (Jiri Olsa).
>
> . Check compatible symtab type before loading dso (Namhyung Kim)
>
> . Check return value of filename__read_debuglink() (Stephane Eranian)
>
> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
>
> ----------------------------------------------------------------
> Arnaldo Carvalho de Melo (1):
> perf tools: Warn the user about how to enable libunwind support
>
> Jiri Olsa (9):
> perf tests: Fix *.o make tests
> perf tests: Add pmu-bison.o make test
> perf tools: Fix bison OUTPUT directories dependency
> perf tools: Factor features display code
> perf tools: Add variable display for VF make output
> perf tools: Add feature check for libdw dwarf unwind
> perf tools: Add libdw DWARF post unwind support
> perf tools: Setup default dwarf post unwinder
> perf tests: Add NO_LIBDW_DWARF_UNWIND make test
>
> Namhyung Kim (1):
> perf symbols: Check compatible symtab type before loading dso
>
> Stephane Eranian (1):
> perf symbols: Check return value of filename__read_debuglink()
>
> tools/perf/Makefile.perf | 24 ++-
> tools/perf/arch/x86/Makefile | 5 +
> tools/perf/arch/x86/util/unwind-libdw.c | 51 +++++
> tools/perf/config/Makefile | 232 +++++++++++++++------
> tools/perf/config/feature-checks/Makefile | 6 +-
> tools/perf/config/feature-checks/test-all.c | 5 +
> .../feature-checks/test-libdw-dwarf-unwind.c | 13 ++
> tools/perf/tests/make | 25 ++-
> tools/perf/util/dso.c | 4 +-
> tools/perf/util/symbol-elf.c | 2 +
> tools/perf/util/symbol.c | 61 +++++-
> tools/perf/util/unwind-libdw.c | 210 +++++++++++++++++++
> tools/perf/util/unwind-libdw.h | 21 ++
> 13 files changed, 569 insertions(+), 90 deletions(-)
> create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
> create mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
> create mode 100644 tools/perf/util/unwind-libdw.c
> create mode 100644 tools/perf/util/unwind-libdw.h

Pulled, thanks a lot Arnaldo!

Btw., the build output looks weird now - on a system that used to pass
all feature tests there's this output:

BUILD: Doing 'make -j12' parallel build
config/Makefile:288: No libdw DWARF unwind found, Please install
elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR

Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ OFF ]
... DWARF post unwind library: libunwind

but:

Package elfutils-devel-0.156-5.fc19.x86_64 already installed and latest version

Also, the information content of this line is unclear to me:

... DWARF post unwind library: libunwind


what does that line want to tell?

Thanks,

Ingo

2014-02-27 12:03:32

by Jiri Olsa

[permalink] [raw]
Subject: Re: [GIT PULL 00/12] perf/core improvements and fixes

On Thu, Feb 27, 2014 at 12:46:58PM +0100, Ingo Molnar wrote:
>
> * Arnaldo Carvalho de Melo <[email protected]> wrote:
>
> > From: Arnaldo Carvalho de Melo <[email protected]>
> >
> > Hi Ingo,
> >
> > Please consider pulling,
> >
> > - Arnaldo
> >
> > The following changes since commit 7e74efcf76c16f851df5c838c143c4a1865ea9fa:
> >
> > Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2014-02-22 17:26:24 +0100)
> >
> > are available in the git repository at:
> >
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo
> >
> > for you to fetch changes up to 1029f9fedf87fa6f52096991588fa54ffd159584:
> >
> > perf symbols: Check compatible symtab type before loading dso (2014-02-24 16:25:01 -0300)
> >
> > ----------------------------------------------------------------
> > perf/core improvements and fixes
> >
> > . Add support for the new DWARF unwinder library in elfutils (Jiri Olsa)
> >
> > . Fix build race in the generation of bison files (Jiri Olsa)
> >
> > . Further streamline the feature detection display, trimming it a bit to
> > show just the libraries detected, using VF=1 gets a more verbose output,
> > showing the less interesting feature checks as well (Jiri Olsa).
> >
> > . Check compatible symtab type before loading dso (Namhyung Kim)
> >
> > . Check return value of filename__read_debuglink() (Stephane Eranian)
> >
> > Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
> >
> > ----------------------------------------------------------------
> > Arnaldo Carvalho de Melo (1):
> > perf tools: Warn the user about how to enable libunwind support
> >
> > Jiri Olsa (9):
> > perf tests: Fix *.o make tests
> > perf tests: Add pmu-bison.o make test
> > perf tools: Fix bison OUTPUT directories dependency
> > perf tools: Factor features display code
> > perf tools: Add variable display for VF make output
> > perf tools: Add feature check for libdw dwarf unwind
> > perf tools: Add libdw DWARF post unwind support
> > perf tools: Setup default dwarf post unwinder
> > perf tests: Add NO_LIBDW_DWARF_UNWIND make test
> >
> > Namhyung Kim (1):
> > perf symbols: Check compatible symtab type before loading dso
> >
> > Stephane Eranian (1):
> > perf symbols: Check return value of filename__read_debuglink()
> >
> > tools/perf/Makefile.perf | 24 ++-
> > tools/perf/arch/x86/Makefile | 5 +
> > tools/perf/arch/x86/util/unwind-libdw.c | 51 +++++
> > tools/perf/config/Makefile | 232 +++++++++++++++------
> > tools/perf/config/feature-checks/Makefile | 6 +-
> > tools/perf/config/feature-checks/test-all.c | 5 +
> > .../feature-checks/test-libdw-dwarf-unwind.c | 13 ++
> > tools/perf/tests/make | 25 ++-
> > tools/perf/util/dso.c | 4 +-
> > tools/perf/util/symbol-elf.c | 2 +
> > tools/perf/util/symbol.c | 61 +++++-
> > tools/perf/util/unwind-libdw.c | 210 +++++++++++++++++++
> > tools/perf/util/unwind-libdw.h | 21 ++
> > 13 files changed, 569 insertions(+), 90 deletions(-)
> > create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
> > create mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
> > create mode 100644 tools/perf/util/unwind-libdw.c
> > create mode 100644 tools/perf/util/unwind-libdw.h
>
> Pulled, thanks a lot Arnaldo!
>
> Btw., the build output looks weird now - on a system that used to pass
> all feature tests there's this output:
>
> BUILD: Doing 'make -j12' parallel build
> config/Makefile:288: No libdw DWARF unwind found, Please install
> elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR
>
> Auto-detecting system features:
> ... dwarf: [ on ]
> ... glibc: [ on ]
> ... gtk2: [ on ]
> ... libaudit: [ on ]
> ... libbfd: [ on ]
> ... libelf: [ on ]
> ... libnuma: [ on ]
> ... libperl: [ on ]
> ... libpython: [ on ]
> ... libslang: [ on ]
> ... libunwind: [ on ]
> ... libdw-dwarf-unwind: [ OFF ]
> ... DWARF post unwind library: libunwind
>
> but:
>
> Package elfutils-devel-0.156-5.fc19.x86_64 already installed and latest version
>
> Also, the information content of this line is unclear to me:
>
> ... DWARF post unwind library: libunwind
>
>
> what does that line want to tell?

this tells what DWARF unwind library is compiled
in.. 'libunwind' in this case

the other choice is 'libdw', which was not detected
in your case (and thats what the 1st message tells you)

we discussed with Arnaldo, that we would not display warnings
for missing features by default.. only tell that there are
missing features and display them for verbose (VF=1) output

jirka

2014-02-27 12:05:19

by Jiri Olsa

[permalink] [raw]
Subject: Re: [GIT PULL 00/12] perf/core improvements and fixes

On Thu, Feb 27, 2014 at 12:46:58PM +0100, Ingo Molnar wrote:
>
> * Arnaldo Carvalho de Melo <[email protected]> wrote:
>
> > From: Arnaldo Carvalho de Melo <[email protected]>
> >
> > Hi Ingo,
> >
> > Please consider pulling,
> >
> > - Arnaldo
> >
> > The following changes since commit 7e74efcf76c16f851df5c838c143c4a1865ea9fa:
> >
> > Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2014-02-22 17:26:24 +0100)
> >
> > are available in the git repository at:
> >
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo
> >
> > for you to fetch changes up to 1029f9fedf87fa6f52096991588fa54ffd159584:
> >
> > perf symbols: Check compatible symtab type before loading dso (2014-02-24 16:25:01 -0300)
> >
> > ----------------------------------------------------------------
> > perf/core improvements and fixes
> >
> > . Add support for the new DWARF unwinder library in elfutils (Jiri Olsa)
> >
> > . Fix build race in the generation of bison files (Jiri Olsa)
> >
> > . Further streamline the feature detection display, trimming it a bit to
> > show just the libraries detected, using VF=1 gets a more verbose output,
> > showing the less interesting feature checks as well (Jiri Olsa).
> >
> > . Check compatible symtab type before loading dso (Namhyung Kim)
> >
> > . Check return value of filename__read_debuglink() (Stephane Eranian)
> >
> > Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
> >
> > ----------------------------------------------------------------
> > Arnaldo Carvalho de Melo (1):
> > perf tools: Warn the user about how to enable libunwind support
> >
> > Jiri Olsa (9):
> > perf tests: Fix *.o make tests
> > perf tests: Add pmu-bison.o make test
> > perf tools: Fix bison OUTPUT directories dependency
> > perf tools: Factor features display code
> > perf tools: Add variable display for VF make output
> > perf tools: Add feature check for libdw dwarf unwind
> > perf tools: Add libdw DWARF post unwind support
> > perf tools: Setup default dwarf post unwinder
> > perf tests: Add NO_LIBDW_DWARF_UNWIND make test
> >
> > Namhyung Kim (1):
> > perf symbols: Check compatible symtab type before loading dso
> >
> > Stephane Eranian (1):
> > perf symbols: Check return value of filename__read_debuglink()
> >
> > tools/perf/Makefile.perf | 24 ++-
> > tools/perf/arch/x86/Makefile | 5 +
> > tools/perf/arch/x86/util/unwind-libdw.c | 51 +++++
> > tools/perf/config/Makefile | 232 +++++++++++++++------
> > tools/perf/config/feature-checks/Makefile | 6 +-
> > tools/perf/config/feature-checks/test-all.c | 5 +
> > .../feature-checks/test-libdw-dwarf-unwind.c | 13 ++
> > tools/perf/tests/make | 25 ++-
> > tools/perf/util/dso.c | 4 +-
> > tools/perf/util/symbol-elf.c | 2 +
> > tools/perf/util/symbol.c | 61 +++++-
> > tools/perf/util/unwind-libdw.c | 210 +++++++++++++++++++
> > tools/perf/util/unwind-libdw.h | 21 ++
> > 13 files changed, 569 insertions(+), 90 deletions(-)
> > create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
> > create mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
> > create mode 100644 tools/perf/util/unwind-libdw.c
> > create mode 100644 tools/perf/util/unwind-libdw.h
>
> Pulled, thanks a lot Arnaldo!
>
> Btw., the build output looks weird now - on a system that used to pass
> all feature tests there's this output:
>
> BUILD: Doing 'make -j12' parallel build
> config/Makefile:288: No libdw DWARF unwind found, Please install
> elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR
>
> Auto-detecting system features:
> ... dwarf: [ on ]
> ... glibc: [ on ]
> ... gtk2: [ on ]
> ... libaudit: [ on ]
> ... libbfd: [ on ]
> ... libelf: [ on ]
> ... libnuma: [ on ]
> ... libperl: [ on ]
> ... libpython: [ on ]
> ... libslang: [ on ]
> ... libunwind: [ on ]
> ... libdw-dwarf-unwind: [ OFF ]
> ... DWARF post unwind library: libunwind
>
> but:
>
> Package elfutils-devel-0.156-5.fc19.x86_64 already installed and latest version

forgot.. remote unwind in libdw is supported from version 0.158,
which I guess wasn't updated in FC19 yet

jirka

2014-02-27 12:30:59

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL 00/12] perf/core improvements and fixes


* Jiri Olsa <[email protected]> wrote:

> On Thu, Feb 27, 2014 at 12:46:58PM +0100, Ingo Molnar wrote:
> >
> > * Arnaldo Carvalho de Melo <[email protected]> wrote:
> >
> > > From: Arnaldo Carvalho de Melo <[email protected]>
> > >
> > > Hi Ingo,
> > >
> > > Please consider pulling,
> > >
> > > - Arnaldo
> > >
> > > The following changes since commit 7e74efcf76c16f851df5c838c143c4a1865ea9fa:
> > >
> > > Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2014-02-22 17:26:24 +0100)
> > >
> > > are available in the git repository at:
> > >
> > >
> > > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo
> > >
> > > for you to fetch changes up to 1029f9fedf87fa6f52096991588fa54ffd159584:
> > >
> > > perf symbols: Check compatible symtab type before loading dso (2014-02-24 16:25:01 -0300)
> > >
> > > ----------------------------------------------------------------
> > > perf/core improvements and fixes
> > >
> > > . Add support for the new DWARF unwinder library in elfutils (Jiri Olsa)
> > >
> > > . Fix build race in the generation of bison files (Jiri Olsa)
> > >
> > > . Further streamline the feature detection display, trimming it a bit to
> > > show just the libraries detected, using VF=1 gets a more verbose output,
> > > showing the less interesting feature checks as well (Jiri Olsa).
> > >
> > > . Check compatible symtab type before loading dso (Namhyung Kim)
> > >
> > > . Check return value of filename__read_debuglink() (Stephane Eranian)
> > >
> > > Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
> > >
> > > ----------------------------------------------------------------
> > > Arnaldo Carvalho de Melo (1):
> > > perf tools: Warn the user about how to enable libunwind support
> > >
> > > Jiri Olsa (9):
> > > perf tests: Fix *.o make tests
> > > perf tests: Add pmu-bison.o make test
> > > perf tools: Fix bison OUTPUT directories dependency
> > > perf tools: Factor features display code
> > > perf tools: Add variable display for VF make output
> > > perf tools: Add feature check for libdw dwarf unwind
> > > perf tools: Add libdw DWARF post unwind support
> > > perf tools: Setup default dwarf post unwinder
> > > perf tests: Add NO_LIBDW_DWARF_UNWIND make test
> > >
> > > Namhyung Kim (1):
> > > perf symbols: Check compatible symtab type before loading dso
> > >
> > > Stephane Eranian (1):
> > > perf symbols: Check return value of filename__read_debuglink()
> > >
> > > tools/perf/Makefile.perf | 24 ++-
> > > tools/perf/arch/x86/Makefile | 5 +
> > > tools/perf/arch/x86/util/unwind-libdw.c | 51 +++++
> > > tools/perf/config/Makefile | 232 +++++++++++++++------
> > > tools/perf/config/feature-checks/Makefile | 6 +-
> > > tools/perf/config/feature-checks/test-all.c | 5 +
> > > .../feature-checks/test-libdw-dwarf-unwind.c | 13 ++
> > > tools/perf/tests/make | 25 ++-
> > > tools/perf/util/dso.c | 4 +-
> > > tools/perf/util/symbol-elf.c | 2 +
> > > tools/perf/util/symbol.c | 61 +++++-
> > > tools/perf/util/unwind-libdw.c | 210 +++++++++++++++++++
> > > tools/perf/util/unwind-libdw.h | 21 ++
> > > 13 files changed, 569 insertions(+), 90 deletions(-)
> > > create mode 100644 tools/perf/arch/x86/util/unwind-libdw.c
> > > create mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
> > > create mode 100644 tools/perf/util/unwind-libdw.c
> > > create mode 100644 tools/perf/util/unwind-libdw.h
> >
> > Pulled, thanks a lot Arnaldo!
> >
> > Btw., the build output looks weird now - on a system that used to pass
> > all feature tests there's this output:
> >
> > BUILD: Doing 'make -j12' parallel build
> > config/Makefile:288: No libdw DWARF unwind found, Please install
> > elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR
> >
> > Auto-detecting system features:
> > ... dwarf: [ on ]
> > ... glibc: [ on ]
> > ... gtk2: [ on ]
> > ... libaudit: [ on ]
> > ... libbfd: [ on ]
> > ... libelf: [ on ]
> > ... libnuma: [ on ]
> > ... libperl: [ on ]
> > ... libpython: [ on ]
> > ... libslang: [ on ]
> > ... libunwind: [ on ]
> > ... libdw-dwarf-unwind: [ OFF ]
> > ... DWARF post unwind library: libunwind
> >
> > but:
> >
> > Package elfutils-devel-0.156-5.fc19.x86_64 already installed and latest version
> >
> > Also, the information content of this line is unclear to me:
> >
> > ... DWARF post unwind library: libunwind
> >
> >
> > what does that line want to tell?
>
> this tells what DWARF unwind library is compiled
> in.. 'libunwind' in this case

So my (stylistic) complaint is that it's really reading weird in a
table generated with the following purpose:

Auto-detecting system features:

Also, we already know that libunwind is present, because just in the
line before it, it says:

... libunwind: [ on ]

So it's doubly confusing. How about not displaying that line at all?
Is there a strong reason to not keep 'OFF' messages on a single line?

> the other choice is 'libdw', which was not detected in your case
> (and thats what the 1st message tells you)
>
> we discussed with Arnaldo, that we would not display warnings for
> missing features by default.. only tell that there are missing
> features and display them for verbose (VF=1) output

That's probably a good plan. I'd suggest the following 'short log' for
failures:

# Auto-detecting system features: 2 libraries are missing. Try 'make VF=1' for a verbose list.

I.e. that way people can notice if the count goes up or down after an
update. Also, that too should be a single line, so that it does not
spam people.

Thanks,

Ingo

2014-02-27 12:41:35

by Jiri Olsa

[permalink] [raw]
Subject: Re: [GIT PULL 00/12] perf/core improvements and fixes

On Thu, Feb 27, 2014 at 01:30:52PM +0100, Ingo Molnar wrote:
>
> * Jiri Olsa <[email protected]> wrote:
>
> > On Thu, Feb 27, 2014 at 12:46:58PM +0100, Ingo Molnar wrote:
> > >
> > > * Arnaldo Carvalho de Melo <[email protected]> wrote:
> > >
> > > > From: Arnaldo Carvalho de Melo <[email protected]>
> > > >

SNIP

> > > Pulled, thanks a lot Arnaldo!
> > >
> > > Btw., the build output looks weird now - on a system that used to pass
> > > all feature tests there's this output:
> > >
> > > BUILD: Doing 'make -j12' parallel build
> > > config/Makefile:288: No libdw DWARF unwind found, Please install
> > > elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR
> > >
> > > Auto-detecting system features:
> > > ... dwarf: [ on ]
> > > ... glibc: [ on ]
> > > ... gtk2: [ on ]
> > > ... libaudit: [ on ]
> > > ... libbfd: [ on ]
> > > ... libelf: [ on ]
> > > ... libnuma: [ on ]
> > > ... libperl: [ on ]
> > > ... libpython: [ on ]
> > > ... libslang: [ on ]
> > > ... libunwind: [ on ]
> > > ... libdw-dwarf-unwind: [ OFF ]
> > > ... DWARF post unwind library: libunwind
> > >
> > > but:
> > >
> > > Package elfutils-devel-0.156-5.fc19.x86_64 already installed and latest version
> > >
> > > Also, the information content of this line is unclear to me:
> > >
> > > ... DWARF post unwind library: libunwind
> > >
> > >
> > > what does that line want to tell?
> >
> > this tells what DWARF unwind library is compiled
> > in.. 'libunwind' in this case
>
> So my (stylistic) complaint is that it's really reading weird in a
> table generated with the following purpose:
>
> Auto-detecting system features:
>
> Also, we already know that libunwind is present, because just in the
> line before it, it says:
>
> ... libunwind: [ on ]
>
> So it's doubly confusing. How about not displaying that line at all?
> Is there a strong reason to not keep 'OFF' messages on a single line?

well, on/OFF lines are only about detecting libs

this line:
'DWARF post unwind library: libunwind'

is about telling which one goes in.. could be you have both
libraries detected and need to choose one or keep default

>
> > the other choice is 'libdw', which was not detected in your case
> > (and thats what the 1st message tells you)
> >
> > we discussed with Arnaldo, that we would not display warnings for
> > missing features by default.. only tell that there are missing
> > features and display them for verbose (VF=1) output
>
> That's probably a good plan. I'd suggest the following 'short log' for
> failures:
>
> # Auto-detecting system features: 2 libraries are missing. Try 'make VF=1' for a verbose list.
>
> I.e. that way people can notice if the count goes up or down after an
> update. Also, that too should be a single line, so that it does not
> spam people.

ook

jirka

2014-02-27 12:45:13

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL 00/12] perf/core improvements and fixes


* Jiri Olsa <[email protected]> wrote:

> On Thu, Feb 27, 2014 at 01:30:52PM +0100, Ingo Molnar wrote:
> >
> > * Jiri Olsa <[email protected]> wrote:
> >
> > > On Thu, Feb 27, 2014 at 12:46:58PM +0100, Ingo Molnar wrote:
> > > >
> > > > * Arnaldo Carvalho de Melo <[email protected]> wrote:
> > > >
> > > > > From: Arnaldo Carvalho de Melo <[email protected]>
> > > > >
>
> SNIP
>
> > > > Pulled, thanks a lot Arnaldo!
> > > >
> > > > Btw., the build output looks weird now - on a system that used to pass
> > > > all feature tests there's this output:
> > > >
> > > > BUILD: Doing 'make -j12' parallel build
> > > > config/Makefile:288: No libdw DWARF unwind found, Please install
> > > > elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR
> > > >
> > > > Auto-detecting system features:
> > > > ... dwarf: [ on ]
> > > > ... glibc: [ on ]
> > > > ... gtk2: [ on ]
> > > > ... libaudit: [ on ]
> > > > ... libbfd: [ on ]
> > > > ... libelf: [ on ]
> > > > ... libnuma: [ on ]
> > > > ... libperl: [ on ]
> > > > ... libpython: [ on ]
> > > > ... libslang: [ on ]
> > > > ... libunwind: [ on ]
> > > > ... libdw-dwarf-unwind: [ OFF ]
> > > > ... DWARF post unwind library: libunwind
> > > >
> > > > but:
> > > >
> > > > Package elfutils-devel-0.156-5.fc19.x86_64 already installed and latest version
> > > >
> > > > Also, the information content of this line is unclear to me:
> > > >
> > > > ... DWARF post unwind library: libunwind
> > > >
> > > >
> > > > what does that line want to tell?
> > >
> > > this tells what DWARF unwind library is compiled
> > > in.. 'libunwind' in this case
> >
> > So my (stylistic) complaint is that it's really reading weird in a
> > table generated with the following purpose:
> >
> > Auto-detecting system features:
> >
> > Also, we already know that libunwind is present, because just in the
> > line before it, it says:
> >
> > ... libunwind: [ on ]
> >
> > So it's doubly confusing. How about not displaying that line at all?
> > Is there a strong reason to not keep 'OFF' messages on a single line?
>
> well, on/OFF lines are only about detecting libs
>
> this line:
> 'DWARF post unwind library: libunwind'
>
> is about telling which one goes in.. could be you have both
> libraries detected and need to choose one or keep default

Okay - but that is not at all clear from the output.

Thanks,

Ingo