Skip to content

Commit 1977499

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 tooling updates from Arnaldo Carvalho de Melo: New features: * perf record: Add --initial-delay option (Andi Kleen) * Column colouring improvements in 'diff' (Ramkumar Ramachandra) Fixes: * Don't show counter information when workload fails (Arnaldo Carvalho de Melo) * Fixup leak on error path in parse events test. (Arnaldo Carvalho de Melo) * Fix --delay option in 'stat' man page (Andi Kleen) * Use the DWARF unwind info only if loaded (Jean Pihet): Developer stuff: * Improve forked workload error reporting by sending the errno in the signal data queueing integer field, using sigqueue and by doing the signal setup in the evlist methods, removing open coded equivalents in various tools. (Arnaldo Carvalho de Melo) * Do more auto exit cleanup shores in the 'evlist' destructor, so that the tools don't have to all do that sequence. (Arnaldo Carvalho de Melo) * Pack 'struct perf_session_env' and 'struct trace' (Arnaldo Carvalho de Melo) * Include tools/lib/api/ in MANIFEST, fixing detached tarballs (Arnaldo Carvalho de Melo) * Add test for building detached source tarballs (Arnaldo Carvalho de Melo) * Shut up libtracevent plugins make message (Jiri Olsa) * Fix installation tests path setup (Jiri Olsa) * Fix id_hdr_size initialization (Jiri Olsa) * Move some header files from tools/perf/ to tools/include/ to make them available to other tools/ dwelling codebases (Namhyung Kim) * Fix 'probe' build when DWARF support libraries not present (Arnaldo Carvalho de Melo) Refactorings: * Move logic to warn about kptr_restrict'ed kernels to separate function in 'report' (Arnaldo Carvalho de Melo) * Move hist browser selection code to separate function (Arnaldo Carvalho de Melo) * Move histogram entries collapsing to separate function (Arnaldo Carvalho de Melo) * Introduce evlist__for_each() & friends (Arnaldo Carvalho de Melo) * Automate setup of FEATURE_CHECK_(C|LD)FLAGS-all variables (Jiri Olsa) * Move arch setup into seprate Makefile (Jiri Olsa) Trivial stuff: * Remove misplaced __maybe_unused in 'stat' (Arnaldo Carvalho de Melo) * Remove old evsel_list usage in 'record' (Arnaldo Carvalho de Melo) * Comment typo fix (Cody P Schafer) * Remove unused test-volatile-register-var.c (Yann Droneaud) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents 1341f3e + 26f7f98 commit 1977499

Some content is hidden

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

55 files changed

+724
-436
lines changed

tools/perf/util/include/asm/bug.h renamed to tools/include/asm/bug.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#ifndef _PERF_ASM_GENERIC_BUG_H
2-
#define _PERF_ASM_GENERIC_BUG_H
1+
#ifndef _TOOLS_ASM_BUG_H
2+
#define _TOOLS_ASM_BUG_H
3+
4+
#include <linux/compiler.h>
35

46
#define __WARN_printf(arg...) do { fprintf(stderr, arg); } while (0)
57

@@ -19,4 +21,5 @@
1921
__warned = 1; \
2022
unlikely(__ret_warn_once); \
2123
})
22-
#endif
24+
25+
#endif /* _TOOLS_ASM_BUG_H */

tools/perf/util/include/linux/compiler.h renamed to tools/include/linux/compiler.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef _PERF_LINUX_COMPILER_H_
2-
#define _PERF_LINUX_COMPILER_H_
1+
#ifndef _TOOLS_LINUX_COMPILER_H_
2+
#define _TOOLS_LINUX_COMPILER_H_
33

44
#ifndef __always_inline
55
# define __always_inline inline __attribute__((always_inline))
@@ -27,4 +27,12 @@
2727
# define __weak __attribute__((weak))
2828
#endif
2929

30+
#ifndef likely
31+
# define likely(x) __builtin_expect(!!(x), 1)
3032
#endif
33+
34+
#ifndef unlikely
35+
# define unlikely(x) __builtin_expect(!!(x), 0)
36+
#endif
37+
38+
#endif /* _TOOLS_LINUX_COMPILER_H */

tools/lib/traceevent/Makefile

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ ifeq ($(BUILD_SRC),)
8686
ifneq ($(OUTPUT),)
8787

8888
define build_output
89-
$(if $(VERBOSE:1=),@)+$(MAKE) -C $(OUTPUT) \
90-
BUILD_SRC=$(CURDIR)/ -f $(CURDIR)/Makefile $1
89+
$(if $(VERBOSE:1=),@)+$(MAKE) -C $(OUTPUT) \
90+
BUILD_SRC=$(CURDIR)/ -f $(CURDIR)/Makefile $1
9191
endef
9292

9393
all: sub-make
@@ -221,23 +221,23 @@ $(PLUGINS): %.so: %.o
221221
$(QUIET_LINK)$(CC) $(CFLAGS) -shared -nostartfiles -o $@ $<
222222

223223
define make_version.h
224-
(echo '/* This file is automatically generated. Do not modify. */'; \
225-
echo \#define VERSION_CODE $(shell \
226-
expr $(VERSION) \* 256 + $(PATCHLEVEL)); \
227-
echo '#define EXTRAVERSION ' $(EXTRAVERSION); \
228-
echo '#define VERSION_STRING "'$(VERSION).$(PATCHLEVEL).$(EXTRAVERSION)'"'; \
229-
echo '#define FILE_VERSION '$(FILE_VERSION); \
230-
) > $1
224+
(echo '/* This file is automatically generated. Do not modify. */'; \
225+
echo \#define VERSION_CODE $(shell \
226+
expr $(VERSION) \* 256 + $(PATCHLEVEL)); \
227+
echo '#define EXTRAVERSION ' $(EXTRAVERSION); \
228+
echo '#define VERSION_STRING "'$(VERSION).$(PATCHLEVEL).$(EXTRAVERSION)'"'; \
229+
echo '#define FILE_VERSION '$(FILE_VERSION); \
230+
) > $1
231231
endef
232232

233233
define update_version.h
234-
($(call make_version.h, $@.tmp); \
235-
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
236-
rm -f $@.tmp; \
237-
else \
238-
echo ' UPDATE $@'; \
239-
mv -f $@.tmp $@; \
240-
fi);
234+
($(call make_version.h, $@.tmp); \
235+
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
236+
rm -f $@.tmp; \
237+
else \
238+
echo ' UPDATE $@'; \
239+
mv -f $@.tmp $@; \
240+
fi);
241241
endef
242242

243243
ep_version.h: force
@@ -246,13 +246,13 @@ ep_version.h: force
246246
VERSION_FILES = ep_version.h
247247

248248
define update_dir
249-
(echo $1 > $@.tmp; \
250-
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
251-
rm -f $@.tmp; \
252-
else \
253-
echo ' UPDATE $@'; \
254-
mv -f $@.tmp $@; \
255-
fi);
249+
(echo $1 > $@.tmp; \
250+
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
251+
rm -f $@.tmp; \
252+
else \
253+
echo ' UPDATE $@'; \
254+
mv -f $@.tmp $@; \
255+
fi);
256256
endef
257257

258258
## make deps
@@ -262,10 +262,10 @@ all_deps := $(all_objs:%.o=.%.d)
262262

263263
# let .d file also depends on the source and header files
264264
define check_deps
265-
@set -e; $(RM) $@; \
266-
$(CC) -MM $(CFLAGS) $< > $@.$$$$; \
267-
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
268-
$(RM) $@.$$$$
265+
@set -e; $(RM) $@; \
266+
$(CC) -MM $(CFLAGS) $< > $@.$$$$; \
267+
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
268+
$(RM) $@.$$$$
269269
endef
270270

271271
$(all_deps): .%.d: $(src)/%.c
@@ -329,9 +329,12 @@ clean:
329329

330330
endif # skip-makefile
331331

332-
PHONY += force
332+
PHONY += force plugins
333333
force:
334334

335+
plugins:
336+
@echo > /dev/null
337+
335338
# Declare the contents of the .PHONY variable as phony. We keep that
336339
# information in a variable so we can use it in if_changed and friends.
337340
.PHONY: $(PHONY)

tools/perf/Documentation/perf-record.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ overrides that and uses per-thread mmaps. A side-effect of that is that
209209
inheritance is automatically disabled. --per-thread is ignored with a warning
210210
if combined with -a or -C options.
211211

212+
--initial-delay msecs::
213+
After starting the program, wait msecs before measuring. This is useful to
214+
filter out the startup phase of the program, which is often very different.
215+
212216
SEE ALSO
213217
--------
214218
linkperf:perf-stat[1], linkperf:perf-list[1]

tools/perf/Documentation/perf-stat.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ use --per-core in addition to -a. (system-wide). The output includes the
133133
core number and the number of online logical processors on that physical processor.
134134

135135
-D msecs::
136-
--initial-delay msecs::
136+
--delay msecs::
137137
After starting the program, wait msecs before measuring. This is useful to
138138
filter out the startup phase of the program, which is often very different.
139139

tools/perf/MANIFEST

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
tools/perf
22
tools/scripts
33
tools/lib/traceevent
4-
tools/lib/lk
4+
tools/lib/api
55
tools/lib/symbol/kallsyms.c
66
tools/lib/symbol/kallsyms.h
7+
tools/include/asm/bug.h
8+
tools/include/linux/compiler.h
79
include/linux/const.h
810
include/linux/perf_event.h
911
include/linux/rbtree.h

tools/perf/Makefile.perf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ LIB_H += ../../include/linux/hash.h
211211
LIB_H += ../../include/linux/stringify.h
212212
LIB_H += util/include/linux/bitmap.h
213213
LIB_H += util/include/linux/bitops.h
214-
LIB_H += util/include/linux/compiler.h
214+
LIB_H += ../include/linux/compiler.h
215215
LIB_H += util/include/linux/const.h
216216
LIB_H += util/include/linux/ctype.h
217217
LIB_H += util/include/linux/kernel.h
@@ -226,7 +226,7 @@ LIB_H += util/include/linux/string.h
226226
LIB_H += util/include/linux/types.h
227227
LIB_H += util/include/linux/linkage.h
228228
LIB_H += util/include/asm/asm-offsets.h
229-
LIB_H += util/include/asm/bug.h
229+
LIB_H += ../include/asm/bug.h
230230
LIB_H += util/include/asm/byteorder.h
231231
LIB_H += util/include/asm/hweight.h
232232
LIB_H += util/include/asm/swab.h

tools/perf/builtin-annotate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
232232
perf_session__fprintf_dsos(session, stdout);
233233

234234
total_nr_samples = 0;
235-
list_for_each_entry(pos, &session->evlist->entries, node) {
235+
evlist__for_each(session->evlist, pos) {
236236
struct hists *hists = &pos->hists;
237237
u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
238238

tools/perf/builtin-diff.c

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,10 @@ static struct perf_evsel *evsel_match(struct perf_evsel *evsel,
356356
{
357357
struct perf_evsel *e;
358358

359-
list_for_each_entry(e, &evlist->entries, node)
359+
evlist__for_each(evlist, e) {
360360
if (perf_evsel__match2(evsel, e))
361361
return e;
362+
}
362363

363364
return NULL;
364365
}
@@ -367,7 +368,7 @@ static void perf_evlist__collapse_resort(struct perf_evlist *evlist)
367368
{
368369
struct perf_evsel *evsel;
369370

370-
list_for_each_entry(evsel, &evlist->entries, node) {
371+
evlist__for_each(evlist, evsel) {
371372
struct hists *hists = &evsel->hists;
372373

373374
hists__collapse_resort(hists, NULL);
@@ -614,7 +615,7 @@ static void data_process(void)
614615
struct perf_evsel *evsel_base;
615616
bool first = true;
616617

617-
list_for_each_entry(evsel_base, &evlist_base->entries, node) {
618+
evlist__for_each(evlist_base, evsel_base) {
618619
struct data__file *d;
619620
int i;
620621

@@ -769,6 +770,81 @@ static int hpp__entry_baseline(struct hist_entry *he, char *buf, size_t size)
769770
return ret;
770771
}
771772

773+
static int __hpp__color_compare(struct perf_hpp_fmt *fmt,
774+
struct perf_hpp *hpp, struct hist_entry *he,
775+
int comparison_method)
776+
{
777+
struct diff_hpp_fmt *dfmt =
778+
container_of(fmt, struct diff_hpp_fmt, fmt);
779+
struct hist_entry *pair = get_pair_fmt(he, dfmt);
780+
double diff;
781+
s64 wdiff;
782+
char pfmt[20] = " ";
783+
784+
if (!pair)
785+
goto dummy_print;
786+
787+
switch (comparison_method) {
788+
case COMPUTE_DELTA:
789+
if (pair->diff.computed)
790+
diff = pair->diff.period_ratio_delta;
791+
else
792+
diff = compute_delta(he, pair);
793+
794+
if (fabs(diff) < 0.01)
795+
goto dummy_print;
796+
scnprintf(pfmt, 20, "%%%+d.2f%%%%", dfmt->header_width - 1);
797+
return percent_color_snprintf(hpp->buf, hpp->size,
798+
pfmt, diff);
799+
case COMPUTE_RATIO:
800+
if (he->dummy)
801+
goto dummy_print;
802+
if (pair->diff.computed)
803+
diff = pair->diff.period_ratio;
804+
else
805+
diff = compute_ratio(he, pair);
806+
807+
scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width);
808+
return value_color_snprintf(hpp->buf, hpp->size,
809+
pfmt, diff);
810+
case COMPUTE_WEIGHTED_DIFF:
811+
if (he->dummy)
812+
goto dummy_print;
813+
if (pair->diff.computed)
814+
wdiff = pair->diff.wdiff;
815+
else
816+
wdiff = compute_wdiff(he, pair);
817+
818+
scnprintf(pfmt, 20, "%%14ld", dfmt->header_width);
819+
return color_snprintf(hpp->buf, hpp->size,
820+
get_percent_color(wdiff),
821+
pfmt, wdiff);
822+
default:
823+
BUG_ON(1);
824+
}
825+
dummy_print:
826+
return scnprintf(hpp->buf, hpp->size, "%*s",
827+
dfmt->header_width, pfmt);
828+
}
829+
830+
static int hpp__color_delta(struct perf_hpp_fmt *fmt,
831+
struct perf_hpp *hpp, struct hist_entry *he)
832+
{
833+
return __hpp__color_compare(fmt, hpp, he, COMPUTE_DELTA);
834+
}
835+
836+
static int hpp__color_ratio(struct perf_hpp_fmt *fmt,
837+
struct perf_hpp *hpp, struct hist_entry *he)
838+
{
839+
return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO);
840+
}
841+
842+
static int hpp__color_wdiff(struct perf_hpp_fmt *fmt,
843+
struct perf_hpp *hpp, struct hist_entry *he)
844+
{
845+
return __hpp__color_compare(fmt, hpp, he, COMPUTE_WEIGHTED_DIFF);
846+
}
847+
772848
static void
773849
hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size)
774850
{
@@ -940,8 +1016,22 @@ static void data__hpp_register(struct data__file *d, int idx)
9401016
fmt->entry = hpp__entry_global;
9411017

9421018
/* TODO more colors */
943-
if (idx == PERF_HPP_DIFF__BASELINE)
1019+
switch (idx) {
1020+
case PERF_HPP_DIFF__BASELINE:
9441021
fmt->color = hpp__color_baseline;
1022+
break;
1023+
case PERF_HPP_DIFF__DELTA:
1024+
fmt->color = hpp__color_delta;
1025+
break;
1026+
case PERF_HPP_DIFF__RATIO:
1027+
fmt->color = hpp__color_ratio;
1028+
break;
1029+
case PERF_HPP_DIFF__WEIGHTED_DIFF:
1030+
fmt->color = hpp__color_wdiff;
1031+
break;
1032+
default:
1033+
break;
1034+
}
9451035

9461036
init_header(d, dfmt);
9471037
perf_hpp__column_register(fmt);

tools/perf/builtin-evlist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
2929
if (session == NULL)
3030
return -ENOMEM;
3131

32-
list_for_each_entry(pos, &session->evlist->entries, node)
32+
evlist__for_each(session->evlist, pos)
3333
perf_evsel__fprintf(pos, details, stdout);
3434

3535
perf_session__delete(session);

0 commit comments

Comments
 (0)