Skip to content

Commit ccf59d8

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 95d18aa + 27f94d5 commit ccf59d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2118
-504
lines changed

tools/lib/traceevent/event-parse.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int cmdline_init(struct pevent *pevent)
174174
return 0;
175175
}
176176

177-
static char *find_cmdline(struct pevent *pevent, int pid)
177+
static const char *find_cmdline(struct pevent *pevent, int pid)
178178
{
179179
const struct cmdline *comm;
180180
struct cmdline key;
@@ -2637,7 +2637,7 @@ process_func_handler(struct event_format *event, struct pevent_function_handler
26372637
struct print_arg *farg;
26382638
enum event_type type;
26392639
char *token;
2640-
char *test;
2640+
const char *test;
26412641
int i;
26422642

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

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

3934-
static void print_event_fields(struct trace_seq *s, void *data, int size,
3934+
static void print_event_fields(struct trace_seq *s, void *data,
3935+
int size __maybe_unused,
39353936
struct event_format *event)
39363937
{
39373938
struct format_field *field;
@@ -4408,7 +4409,7 @@ void pevent_event_info(struct trace_seq *s, struct event_format *event,
44084409
void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
44094410
struct pevent_record *record)
44104411
{
4411-
static char *spaces = " "; /* 20 spaces */
4412+
static const char *spaces = " "; /* 20 spaces */
44124413
struct event_format *event;
44134414
unsigned long secs;
44144415
unsigned long usecs;
@@ -5070,8 +5071,8 @@ static const char * const pevent_error_str[] = {
50705071
};
50715072
#undef _PE
50725073

5073-
int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
5074-
char *buf, size_t buflen)
5074+
int pevent_strerror(struct pevent *pevent __maybe_unused,
5075+
enum pevent_errno errnum, char *buf, size_t buflen)
50755076
{
50765077
int idx;
50775078
const char *msg;
@@ -5100,6 +5101,7 @@ int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
51005101
case PEVENT_ERRNO__READ_FORMAT_FAILED:
51015102
case PEVENT_ERRNO__READ_PRINT_FAILED:
51025103
case PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED:
5104+
case PEVENT_ERRNO__INVALID_ARG_TYPE:
51035105
snprintf(buf, buflen, "%s", msg);
51045106
break;
51055107

@@ -5362,7 +5364,7 @@ int pevent_register_print_function(struct pevent *pevent,
53625364
if (type == PEVENT_FUNC_ARG_VOID)
53635365
break;
53645366

5365-
if (type < 0 || type >= PEVENT_FUNC_ARG_MAX_TYPES) {
5367+
if (type >= PEVENT_FUNC_ARG_MAX_TYPES) {
53665368
do_warning("Invalid argument type %d", type);
53675369
ret = PEVENT_ERRNO__INVALID_ARG_TYPE;
53685370
goto out_free;
@@ -5560,7 +5562,7 @@ void pevent_free(struct pevent *pevent)
55605562
}
55615563

55625564
if (pevent->func_map) {
5563-
for (i = 0; i < pevent->func_count; i++) {
5565+
for (i = 0; i < (int)pevent->func_count; i++) {
55645566
free(pevent->func_map[i].func);
55655567
free(pevent->func_map[i].mod);
55665568
}
@@ -5582,7 +5584,7 @@ void pevent_free(struct pevent *pevent)
55825584
}
55835585

55845586
if (pevent->printk_map) {
5585-
for (i = 0; i < pevent->printk_count; i++)
5587+
for (i = 0; i < (int)pevent->printk_count; i++)
55865588
free(pevent->printk_map[i].printk);
55875589
free(pevent->printk_map);
55885590
}

tools/perf/Documentation/android.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ For x86:
4848
II. Compile perf for Android
4949
------------------------------------------------
5050
You need to run make with the NDK toolchain and sysroot defined above:
51-
make CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"
51+
For arm:
52+
make ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"
53+
For x86:
54+
make ARCH=x86 CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"
5255

5356
III. Install perf
5457
-----------------------------------------------

tools/perf/Makefile

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ endif
169169

170170
### --- END CONFIGURATION SECTION ---
171171

172-
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
172+
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
173173
BASIC_LDFLAGS =
174174

175175
ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y)
@@ -371,7 +371,6 @@ LIB_OBJS += $(OUTPUT)util/help.o
371371
LIB_OBJS += $(OUTPUT)util/levenshtein.o
372372
LIB_OBJS += $(OUTPUT)util/parse-options.o
373373
LIB_OBJS += $(OUTPUT)util/parse-events.o
374-
LIB_OBJS += $(OUTPUT)util/parse-events-test.o
375374
LIB_OBJS += $(OUTPUT)util/path.o
376375
LIB_OBJS += $(OUTPUT)util/rbtree.o
377376
LIB_OBJS += $(OUTPUT)util/bitmap.o
@@ -389,7 +388,6 @@ LIB_OBJS += $(OUTPUT)util/sigchain.o
389388
LIB_OBJS += $(OUTPUT)util/dso.o
390389
LIB_OBJS += $(OUTPUT)util/symbol.o
391390
LIB_OBJS += $(OUTPUT)util/symbol-elf.o
392-
LIB_OBJS += $(OUTPUT)util/dso-test-data.o
393391
LIB_OBJS += $(OUTPUT)util/color.o
394392
LIB_OBJS += $(OUTPUT)util/pager.o
395393
LIB_OBJS += $(OUTPUT)util/header.o
@@ -430,6 +428,10 @@ LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
430428

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

431+
LIB_OBJS += $(OUTPUT)tests/parse-events.o
432+
LIB_OBJS += $(OUTPUT)tests/dso-data.o
433+
LIB_OBJS += $(OUTPUT)tests/attr.o
434+
433435
BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
434436
BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
435437
# Benchmark modules
@@ -459,8 +461,8 @@ BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
459461
BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
460462
BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
461463
BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
462-
BUILTIN_OBJS += $(OUTPUT)builtin-test.o
463464
BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
465+
BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o
464466

465467
PERFLIBS = $(LIB_FILE) $(LIBTRACEEVENT)
466468

@@ -490,14 +492,23 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y)
490492
LIBC_SUPPORT := 1
491493
endif
492494
ifeq ($(LIBC_SUPPORT),1)
495+
msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
496+
493497
NO_LIBELF := 1
494498
NO_DWARF := 1
495499
NO_DEMANGLE := 1
496500
else
497501
msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
498502
endif
499503
else
500-
FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
504+
# for linking with debug library, run like:
505+
# make DEBUG=1 LIBDW_DIR=/opt/libdw/
506+
ifdef LIBDW_DIR
507+
LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
508+
LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
509+
endif
510+
511+
FLAGS_DWARF=$(ALL_CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS)
501512
ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y)
502513
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);
503514
NO_DWARF := 1
@@ -552,7 +563,8 @@ ifndef NO_DWARF
552563
ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
553564
msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
554565
else
555-
BASIC_CFLAGS += -DDWARF_SUPPORT
566+
BASIC_CFLAGS := -DDWARF_SUPPORT $(LIBDW_CFLAGS) $(BASIC_CFLAGS)
567+
BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS)
556568
EXTLIBS += -lelf -ldw
557569
LIB_OBJS += $(OUTPUT)util/probe-finder.o
558570
LIB_OBJS += $(OUTPUT)util/dwarf-aux.o
@@ -891,10 +903,14 @@ $(OUTPUT)%.s: %.S
891903
$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
892904
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
893905
'-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
894-
'-DBINDIR="$(bindir_relative_SQ)"' \
895906
'-DPREFIX="$(prefix_SQ)"' \
896907
$<
897908

909+
$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS
910+
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
911+
'-DBINDIR="$(bindir_SQ)"' \
912+
$<
913+
898914
$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
899915
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
900916

@@ -1059,6 +1075,10 @@ install: all try-install-man
10591075
$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
10601076
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'
10611077
$(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
1078+
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'
1079+
$(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'
1080+
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
1081+
$(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
10621082

10631083
install-python_ext:
10641084
$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'

tools/perf/arch/common.c

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,54 @@ static int lookup_triplets(const char *const *triplets, const char *name)
9393
return -1;
9494
}
9595

96+
/*
97+
* Return architecture name in a normalized form.
98+
* The conversion logic comes from the Makefile.
99+
*/
100+
static const char *normalize_arch(char *arch)
101+
{
102+
if (!strcmp(arch, "x86_64"))
103+
return "x86";
104+
if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6')
105+
return "x86";
106+
if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5))
107+
return "sparc";
108+
if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110"))
109+
return "arm";
110+
if (!strncmp(arch, "s390", 4))
111+
return "s390";
112+
if (!strncmp(arch, "parisc", 6))
113+
return "parisc";
114+
if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3))
115+
return "powerpc";
116+
if (!strncmp(arch, "mips", 4))
117+
return "mips";
118+
if (!strncmp(arch, "sh", 2) && isdigit(arch[2]))
119+
return "sh";
120+
121+
return arch;
122+
}
123+
96124
static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
97125
const char *name,
98126
const char **path)
99127
{
100128
int idx;
101-
char *arch, *cross_env;
129+
const char *arch, *cross_env;
102130
struct utsname uts;
103131
const char *const *path_list;
104132
char *buf = NULL;
105133

134+
arch = normalize_arch(env->arch);
135+
106136
if (uname(&uts) < 0)
107137
goto out;
108138

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

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

130-
arch = env->arch;
131-
132160
if (!strcmp(arch, "arm"))
133161
path_list = arm_triplets;
134162
else if (!strcmp(arch, "powerpc"))
@@ -139,9 +167,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
139167
path_list = s390_triplets;
140168
else if (!strcmp(arch, "sparc"))
141169
path_list = sparc_triplets;
142-
else if (!strcmp(arch, "x86") || !strcmp(arch, "i386") ||
143-
!strcmp(arch, "i486") || !strcmp(arch, "i586") ||
144-
!strcmp(arch, "i686"))
170+
else if (!strcmp(arch, "x86"))
145171
path_list = x86_triplets;
146172
else if (!strcmp(arch, "mips"))
147173
path_list = mips_triplets;
@@ -173,6 +199,13 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
173199

174200
int perf_session_env__lookup_objdump(struct perf_session_env *env)
175201
{
202+
/*
203+
* For live mode, env->arch will be NULL and we can use
204+
* the native objdump tool.
205+
*/
206+
if (env->arch == NULL)
207+
return 0;
208+
176209
return perf_session_env__lookup_binutils_path(env, "objdump",
177210
&objdump_path);
178211
}

tools/perf/builtin-annotate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void hists__find_annotations(struct hists *self, int evidx,
139139
}
140140

141141
if (use_browser > 0) {
142-
key = hist_entry__tui_annotate(he, evidx, NULL, NULL, 0);
142+
key = hist_entry__tui_annotate(he, evidx, NULL);
143143
switch (key) {
144144
case K_RIGHT:
145145
next = rb_next(nd);

0 commit comments

Comments
 (0)