Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

 * Don't show scripts menu for 'perf top', fix from Feng Tang

 * Add framework for automated perf_event_attr tests, where tools with
   different command line options will be run from a 'perf test', via
   python glue, and the perf syscall will be intercepted to verify that
   the perf_event_attr fields set by the tool are those expected,
   from Jiri Olsa

 * Use normalized arch name for searching objdump path. This fixes cases
   where the system's objdump (e.g. x86_64) supports the architecture in
   the perf.data file (e.g. i686), but is not the same,
   fix from Namhyung Kim.

 * Postpone objdump check until annotation requested, from Namhyung Kim.

 * Add a 'link' method for hists, so that we can have the leader with
   buckets for all the entries in all the hists.  This new method
   is now used in the default 'diff' output, making the sum of the 'baseline'
   column be 100%, eliminating blind spots. Now we need to use this
   for 'diff' with > 2 perf.data files and for multi event 'report' and
   'annotate'.

 * libtraceevent fixes for compiler warnings trying to make perf it build
   on some distros, like fedora 14, 32-bit, some of the warnings really
   pointed to real bugs.

 * Remove temp dir on failure in 'perf test', fix from Jiri Olsa.

 * Fixes for handling data, stack mmaps, from Namhyung Kim.

 * Fix live annotation bug related to recent objdump lookup patches, from
   Namhyung Kim

 * Don't try to follow jump target on PLT symbols in the annotation browser,
   fix from Namhyung Kim.

 * Fix leak on hist_entry delete, from Namhyung Kim.

 * Fix a CPU_ALLOC related build error on builtin-test, from Zheng Liu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Nov 13, 2012
2 parents 95d18aa + 27f94d5 commit ccf59d8
Show file tree
Hide file tree
Showing 67 changed files with 2,118 additions and 504 deletions.
22 changes: 12 additions & 10 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int cmdline_init(struct pevent *pevent)
return 0;
}

static char *find_cmdline(struct pevent *pevent, int pid)
static const char *find_cmdline(struct pevent *pevent, int pid)
{
const struct cmdline *comm;
struct cmdline key;
Expand Down Expand Up @@ -2637,7 +2637,7 @@ process_func_handler(struct event_format *event, struct pevent_function_handler
struct print_arg *farg;
enum event_type type;
char *token;
char *test;
const char *test;
int i;

arg->type = PRINT_FUNC;
Expand Down Expand Up @@ -3889,7 +3889,7 @@ static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size,
struct event_format *event, struct print_arg *arg)
{
unsigned char *buf;
char *fmt = "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x";
const char *fmt = "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x";

if (arg->type == PRINT_FUNC) {
process_defined_func(s, data, size, event, arg);
Expand Down Expand Up @@ -3931,7 +3931,8 @@ static int is_printable_array(char *p, unsigned int len)
return 1;
}

static void print_event_fields(struct trace_seq *s, void *data, int size,
static void print_event_fields(struct trace_seq *s, void *data,
int size __maybe_unused,
struct event_format *event)
{
struct format_field *field;
Expand Down Expand Up @@ -4408,7 +4409,7 @@ void pevent_event_info(struct trace_seq *s, struct event_format *event,
void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
struct pevent_record *record)
{
static char *spaces = " "; /* 20 spaces */
static const char *spaces = " "; /* 20 spaces */
struct event_format *event;
unsigned long secs;
unsigned long usecs;
Expand Down Expand Up @@ -5070,8 +5071,8 @@ static const char * const pevent_error_str[] = {
};
#undef _PE

int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
char *buf, size_t buflen)
int pevent_strerror(struct pevent *pevent __maybe_unused,
enum pevent_errno errnum, char *buf, size_t buflen)
{
int idx;
const char *msg;
Expand Down Expand Up @@ -5100,6 +5101,7 @@ int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
case PEVENT_ERRNO__READ_FORMAT_FAILED:
case PEVENT_ERRNO__READ_PRINT_FAILED:
case PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED:
case PEVENT_ERRNO__INVALID_ARG_TYPE:
snprintf(buf, buflen, "%s", msg);
break;

Expand Down Expand Up @@ -5362,7 +5364,7 @@ int pevent_register_print_function(struct pevent *pevent,
if (type == PEVENT_FUNC_ARG_VOID)
break;

if (type < 0 || type >= PEVENT_FUNC_ARG_MAX_TYPES) {
if (type >= PEVENT_FUNC_ARG_MAX_TYPES) {
do_warning("Invalid argument type %d", type);
ret = PEVENT_ERRNO__INVALID_ARG_TYPE;
goto out_free;
Expand Down Expand Up @@ -5560,7 +5562,7 @@ void pevent_free(struct pevent *pevent)
}

if (pevent->func_map) {
for (i = 0; i < pevent->func_count; i++) {
for (i = 0; i < (int)pevent->func_count; i++) {
free(pevent->func_map[i].func);
free(pevent->func_map[i].mod);
}
Expand All @@ -5582,7 +5584,7 @@ void pevent_free(struct pevent *pevent)
}

if (pevent->printk_map) {
for (i = 0; i < pevent->printk_count; i++)
for (i = 0; i < (int)pevent->printk_count; i++)
free(pevent->printk_map[i].printk);
free(pevent->printk_map);
}
Expand Down
5 changes: 4 additions & 1 deletion tools/perf/Documentation/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ For x86:
II. Compile perf for Android
------------------------------------------------
You need to run make with the NDK toolchain and sysroot defined above:
make CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"
For arm:
make ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"
For x86:
make ARCH=x86 CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"

III. Install perf
-----------------------------------------------
Expand Down
34 changes: 27 additions & 7 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ endif

### --- END CONFIGURATION SECTION ---

BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -Iutil -I. -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
BASIC_LDFLAGS =

ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y)
Expand Down Expand Up @@ -371,7 +371,6 @@ LIB_OBJS += $(OUTPUT)util/help.o
LIB_OBJS += $(OUTPUT)util/levenshtein.o
LIB_OBJS += $(OUTPUT)util/parse-options.o
LIB_OBJS += $(OUTPUT)util/parse-events.o
LIB_OBJS += $(OUTPUT)util/parse-events-test.o
LIB_OBJS += $(OUTPUT)util/path.o
LIB_OBJS += $(OUTPUT)util/rbtree.o
LIB_OBJS += $(OUTPUT)util/bitmap.o
Expand All @@ -389,7 +388,6 @@ LIB_OBJS += $(OUTPUT)util/sigchain.o
LIB_OBJS += $(OUTPUT)util/dso.o
LIB_OBJS += $(OUTPUT)util/symbol.o
LIB_OBJS += $(OUTPUT)util/symbol-elf.o
LIB_OBJS += $(OUTPUT)util/dso-test-data.o
LIB_OBJS += $(OUTPUT)util/color.o
LIB_OBJS += $(OUTPUT)util/pager.o
LIB_OBJS += $(OUTPUT)util/header.o
Expand Down Expand Up @@ -430,6 +428,10 @@ LIB_OBJS += $(OUTPUT)ui/stdio/hist.o

LIB_OBJS += $(OUTPUT)arch/common.o

LIB_OBJS += $(OUTPUT)tests/parse-events.o
LIB_OBJS += $(OUTPUT)tests/dso-data.o
LIB_OBJS += $(OUTPUT)tests/attr.o

BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
# Benchmark modules
Expand Down Expand Up @@ -459,8 +461,8 @@ BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
BUILTIN_OBJS += $(OUTPUT)builtin-test.o
BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o

PERFLIBS = $(LIB_FILE) $(LIBTRACEEVENT)

Expand Down Expand Up @@ -490,14 +492,23 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y)
LIBC_SUPPORT := 1
endif
ifeq ($(LIBC_SUPPORT),1)
msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);

NO_LIBELF := 1
NO_DWARF := 1
NO_DEMANGLE := 1
else
msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
endif
else
FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
# 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

FLAGS_DWARF=$(ALL_CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y)
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
Expand Down Expand Up @@ -552,7 +563,8 @@ ifndef NO_DWARF
ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
else
BASIC_CFLAGS += -DDWARF_SUPPORT
BASIC_CFLAGS := -DDWARF_SUPPORT $(LIBDW_CFLAGS) $(BASIC_CFLAGS)
BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS)
EXTLIBS += -lelf -ldw
LIB_OBJS += $(OUTPUT)util/probe-finder.o
LIB_OBJS += $(OUTPUT)util/dwarf-aux.o
Expand Down Expand Up @@ -891,10 +903,14 @@ $(OUTPUT)%.s: %.S
$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
'-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
'-DBINDIR="$(bindir_relative_SQ)"' \
'-DPREFIX="$(prefix_SQ)"' \
$<

$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
'-DBINDIR="$(bindir_SQ)"' \
$<

$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<

Expand Down Expand Up @@ -1059,6 +1075,10 @@ install: all try-install-man
$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'
$(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'
$(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
$(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'

install-python_ext:
$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
Expand Down
47 changes: 40 additions & 7 deletions tools/perf/arch/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,54 @@ static int lookup_triplets(const char *const *triplets, const char *name)
return -1;
}

/*
* Return architecture name in a normalized form.
* The conversion logic comes from the Makefile.
*/
static const char *normalize_arch(char *arch)
{
if (!strcmp(arch, "x86_64"))
return "x86";
if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6')
return "x86";
if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5))
return "sparc";
if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110"))
return "arm";
if (!strncmp(arch, "s390", 4))
return "s390";
if (!strncmp(arch, "parisc", 6))
return "parisc";
if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3))
return "powerpc";
if (!strncmp(arch, "mips", 4))
return "mips";
if (!strncmp(arch, "sh", 2) && isdigit(arch[2]))
return "sh";

return arch;
}

static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
const char *name,
const char **path)
{
int idx;
char *arch, *cross_env;
const char *arch, *cross_env;
struct utsname uts;
const char *const *path_list;
char *buf = NULL;

arch = normalize_arch(env->arch);

if (uname(&uts) < 0)
goto out;

/*
* We don't need to try to find objdump path for native system.
* Just use default binutils path (e.g.: "objdump").
*/
if (!strcmp(uts.machine, env->arch))
if (!strcmp(normalize_arch(uts.machine), arch))
goto out;

cross_env = getenv("CROSS_COMPILE");
Expand All @@ -127,8 +157,6 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
free(buf);
}

arch = env->arch;

if (!strcmp(arch, "arm"))
path_list = arm_triplets;
else if (!strcmp(arch, "powerpc"))
Expand All @@ -139,9 +167,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
path_list = s390_triplets;
else if (!strcmp(arch, "sparc"))
path_list = sparc_triplets;
else if (!strcmp(arch, "x86") || !strcmp(arch, "i386") ||
!strcmp(arch, "i486") || !strcmp(arch, "i586") ||
!strcmp(arch, "i686"))
else if (!strcmp(arch, "x86"))
path_list = x86_triplets;
else if (!strcmp(arch, "mips"))
path_list = mips_triplets;
Expand Down Expand Up @@ -173,6 +199,13 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,

int perf_session_env__lookup_objdump(struct perf_session_env *env)
{
/*
* For live mode, env->arch will be NULL and we can use
* the native objdump tool.
*/
if (env->arch == NULL)
return 0;

return perf_session_env__lookup_binutils_path(env, "objdump",
&objdump_path);
}
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static void hists__find_annotations(struct hists *self, int evidx,
}

if (use_browser > 0) {
key = hist_entry__tui_annotate(he, evidx, NULL, NULL, 0);
key = hist_entry__tui_annotate(he, evidx, NULL);
switch (key) {
case K_RIGHT:
next = rb_next(nd);
Expand Down
Loading

0 comments on commit ccf59d8

Please sign in to comment.