Skip to content

Commit b89e791

Browse files
committed
Merge tag 'perf-core-for-mingo-4.17-20180403' 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: - Show only failing syscalls with 'perf trace --failure' (Arnaldo Carvalho de Melo) e.g: See what 'openat' syscalls are failing: # perf trace --failure -e openat 762.323 ( 0.007 ms): VideoCapture/4566 openat(dfd: CWD, filename: /dev/video2) = -1 ENOENT No such file or directory <SNIP N /dev/videoN open attempts... sigh, where is that improvised camera lid?!? > 790.228 ( 0.008 ms): VideoCapture/4566 openat(dfd: CWD, filename: /dev/video63) = -1 ENOENT No such file or directory ^C# - Show information about the event (freq, nr_samples, total period/nr_events) in the annotate --tui and --stdio2 'perf annotate' output, similar to the first line in the 'perf report --tui', but just for the samples for a the annotated symbol (Arnaldo Carvalho de Melo) - Introduce 'perf version --build-options' to show what features were linked, aliased as well as a shorter 'perf -vv' (Jin Yao) - Add a "dso_size" sort order (Kim Phillips) - Remove redundant ')' in the tracepoint output in 'perf trace' (Changbin Du) - Synchronize x86's cpufeatures.h, no effect on toolss (Arnaldo Carvalho de Melo) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents 642e7fd + 51125a2 commit b89e791

22 files changed

Lines changed: 418 additions & 116 deletions

File tree

‎tools/arch/x86/include/asm/cpufeatures.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@
316316
#define X86_FEATURE_VPCLMULQDQ (16*32+10) /* Carry-Less Multiplication Double Quadword */
317317
#define X86_FEATURE_AVX512_VNNI (16*32+11) /* Vector Neural Network Instructions */
318318
#define X86_FEATURE_AVX512_BITALG (16*32+12) /* Support for VPOPCNT[B,W] and VPSHUF-BITQMB instructions */
319+
#define X86_FEATURE_TME (16*32+13) /* Intel Total Memory Encryption */
319320
#define X86_FEATURE_AVX512_VPOPCNTDQ (16*32+14) /* POPCNT for vectors of DW/QW */
320321
#define X86_FEATURE_LA57 (16*32+16) /* 5-level page tables */
321322
#define X86_FEATURE_RDPID (16*32+22) /* RDPID instruction */
@@ -328,6 +329,7 @@
328329
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
329330
#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
330331
#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
332+
#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
331333
#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
332334
#define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
333335
#define X86_FEATURE_ARCH_CAPABILITIES (18*32+29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */

‎tools/include/tools/config.h‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _TOOLS_CONFIG_H
3+
#define _TOOLS_CONFIG_H
4+
5+
/* Subset of include/linux/kconfig.h */
6+
7+
#define __ARG_PLACEHOLDER_1 0,
8+
#define __take_second_arg(__ignored, val, ...) val
9+
10+
/*
11+
* Helper macros to use CONFIG_ options in C/CPP expressions. Note that
12+
* these only work with boolean and tristate options.
13+
*/
14+
15+
/*
16+
* Getting something that works in C and CPP for an arg that may or may
17+
* not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1"
18+
* we match on the placeholder define, insert the "0," for arg1 and generate
19+
* the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one).
20+
* When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
21+
* the last step cherry picks the 2nd arg, we get a zero.
22+
*/
23+
#define __is_defined(x) ___is_defined(x)
24+
#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
25+
#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)
26+
27+
/*
28+
* IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
29+
* otherwise. For boolean options, this is equivalent to
30+
* IS_ENABLED(CONFIG_FOO).
31+
*/
32+
#define IS_BUILTIN(option) __is_defined(option)
33+
34+
#endif /* _TOOLS_CONFIG_H */

‎tools/perf/Documentation/perf-report.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ OPTIONS
8080
- comm: command (name) of the task which can be read via /proc/<pid>/comm
8181
- pid: command and tid of the task
8282
- dso: name of library or module executed at the time of sample
83+
- dso_size: size of library or module executed at the time of sample
8384
- symbol: name of function executed at the time of sample
8485
- symbol_size: size of function executed at the time of sample
8586
- parent: name of function matched to the parent regex filter. Unmatched

‎tools/perf/Documentation/perf-trace.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
117117
--sched::
118118
Accrue thread runtime and provide a summary at the end of the session.
119119

120+
--failure::
121+
Show only syscalls that failed, i.e. that returned < 0.
122+
120123
-i::
121124
--input::
122125
Process events from a given perf data file.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
perf-version(1)
2+
===============
3+
4+
NAME
5+
----
6+
perf-version - display the version of perf binary
7+
8+
SYNOPSIS
9+
--------
10+
'perf version' [--build-options]
11+
12+
DESCRIPTION
13+
-----------
14+
With no options given, the 'perf version' prints the perf version
15+
on the standard output.
16+
17+
If the option '--build-options' is given, then the status of
18+
compiled-in libraries are printed on the standard output.
19+
20+
OPTIONS
21+
-------
22+
--build-options::
23+
Prints the status of compiled-in libraries on the
24+
standard output.

‎tools/perf/Makefile.config‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,16 @@ else
346346
ifneq ($(feature-dwarf_getlocations), 1)
347347
msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
348348
else
349-
CFLAGS += -DHAVE_DWARF_GETLOCATIONS
349+
CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
350350
endif # dwarf_getlocations
351351
endif # Dwarf support
352352
endif # libelf support
353353
endif # NO_LIBELF
354354

355+
ifeq ($(feature-glibc), 1)
356+
CFLAGS += -DHAVE_GLIBC_SUPPORT
357+
endif
358+
355359
ifdef NO_DWARF
356360
NO_LIBDW_DWARF_UNWIND := 1
357361
endif
@@ -635,6 +639,7 @@ else
635639
else
636640
LDFLAGS += $(PERL_EMBED_LDFLAGS)
637641
EXTLIBS += $(PERL_EMBED_LIBADD)
642+
CFLAGS += -DHAVE_LIBPERL_SUPPORT
638643
$(call detected,CONFIG_LIBPERL)
639644
endif
640645
endif
@@ -671,6 +676,7 @@ else
671676
LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
672677
EXTLIBS += $(PYTHON_EMBED_LIBADD)
673678
LANG_BINDINGS += $(obj-perf)python/perf.so
679+
CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
674680
$(call detected,CONFIG_LIBPYTHON)
675681
endif
676682
endif

‎tools/perf/builtin-trace.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct trace {
112112
bool multiple_threads;
113113
bool summary;
114114
bool summary_only;
115+
bool failure_only;
115116
bool show_comm;
116117
bool print_sample;
117118
bool show_tool_stats;
@@ -1565,7 +1566,7 @@ static int trace__printf_interrupted_entry(struct trace *trace)
15651566
struct thread_trace *ttrace;
15661567
size_t printed;
15671568

1568-
if (trace->current == NULL)
1569+
if (trace->failure_only || trace->current == NULL)
15691570
return 0;
15701571

15711572
ttrace = thread__priv(trace->current);
@@ -1638,7 +1639,7 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
16381639
args, trace, thread);
16391640

16401641
if (sc->is_exit) {
1641-
if (!(trace->duration_filter || trace->summary_only || trace->min_stack)) {
1642+
if (!(trace->duration_filter || trace->summary_only || trace->failure_only || trace->min_stack)) {
16421643
trace__fprintf_entry_head(trace, thread, 0, false, ttrace->entry_time, trace->output);
16431644
fprintf(trace->output, "%-70s)\n", ttrace->entry_str);
16441645
}
@@ -1742,7 +1743,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
17421743
}
17431744
}
17441745

1745-
if (trace->summary_only)
1746+
if (trace->summary_only || (ret >= 0 && trace->failure_only))
17461747
goto out;
17471748

17481749
trace__fprintf_entry_head(trace, thread, duration, duration_calculated, ttrace->entry_time, trace->output);
@@ -1961,7 +1962,7 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel,
19611962
trace->output);
19621963
}
19631964

1964-
fprintf(trace->output, ")\n");
1965+
fprintf(trace->output, "\n");
19651966

19661967
if (callchain_ret > 0)
19671968
trace__fprintf_callchain(trace, sample);
@@ -3087,6 +3088,8 @@ int cmd_trace(int argc, const char **argv)
30873088
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
30883089
OPT_BOOLEAN('T', "time", &trace.full_time,
30893090
"Show full timestamp, not time relative to first start"),
3091+
OPT_BOOLEAN(0, "failure", &trace.failure_only,
3092+
"Show only syscalls that failed"),
30903093
OPT_BOOLEAN('s', "summary", &trace.summary_only,
30913094
"Show only syscall summary with statistics"),
30923095
OPT_BOOLEAN('S', "with-summary", &trace.summary,

‎tools/perf/builtin-version.c‎

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,91 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include "builtin.h"
33
#include "perf.h"
4+
#include "color.h"
45
#include <linux/compiler.h>
6+
#include <tools/config.h>
57
#include <stdio.h>
8+
#include <string.h>
9+
#include <subcmd/parse-options.h>
610

7-
int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused)
11+
int version_verbose;
12+
13+
struct version {
14+
bool build_options;
15+
};
16+
17+
static struct version version;
18+
19+
static struct option version_options[] = {
20+
OPT_BOOLEAN(0, "build-options", &version.build_options,
21+
"display the build options"),
22+
};
23+
24+
static const char * const version_usage[] = {
25+
"perf version [<options>]",
26+
NULL
27+
};
28+
29+
static void on_off_print(const char *status)
30+
{
31+
printf("[ ");
32+
33+
if (!strcmp(status, "OFF"))
34+
color_fprintf(stdout, PERF_COLOR_RED, "%-3s", status);
35+
else
36+
color_fprintf(stdout, PERF_COLOR_GREEN, "%-3s", status);
37+
38+
printf(" ]");
39+
}
40+
41+
static void status_print(const char *name, const char *macro,
42+
const char *status)
843
{
44+
printf("%22s: ", name);
45+
on_off_print(status);
46+
printf(" # %s\n", macro);
47+
}
48+
49+
#define STATUS(__d, __m) \
50+
do { \
51+
if (IS_BUILTIN(__d)) \
52+
status_print(#__m, #__d, "on"); \
53+
else \
54+
status_print(#__m, #__d, "OFF"); \
55+
} while (0)
56+
57+
static void library_status(void)
58+
{
59+
STATUS(HAVE_DWARF_SUPPORT, dwarf);
60+
STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
61+
STATUS(HAVE_GLIBC_SUPPORT, glibc);
62+
STATUS(HAVE_GTK2_SUPPORT, gtk2);
63+
STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
64+
STATUS(HAVE_LIBBFD_SUPPORT, libbfd);
65+
STATUS(HAVE_LIBELF_SUPPORT, libelf);
66+
STATUS(HAVE_LIBNUMA_SUPPORT, libnuma);
67+
STATUS(HAVE_LIBNUMA_SUPPORT, numa_num_possible_cpus);
68+
STATUS(HAVE_LIBPERL_SUPPORT, libperl);
69+
STATUS(HAVE_LIBPYTHON_SUPPORT, libpython);
70+
STATUS(HAVE_SLANG_SUPPORT, libslang);
71+
STATUS(HAVE_LIBCRYPTO_SUPPORT, libcrypto);
72+
STATUS(HAVE_LIBUNWIND_SUPPORT, libunwind);
73+
STATUS(HAVE_DWARF_SUPPORT, libdw-dwarf-unwind);
74+
STATUS(HAVE_ZLIB_SUPPORT, zlib);
75+
STATUS(HAVE_LZMA_SUPPORT, lzma);
76+
STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid);
77+
STATUS(HAVE_LIBBPF_SUPPORT, bpf);
78+
}
79+
80+
int cmd_version(int argc, const char **argv)
81+
{
82+
argc = parse_options(argc, argv, version_options, version_usage,
83+
PARSE_OPT_STOP_AT_NON_OPTION);
84+
985
printf("perf version %s\n", perf_version_string);
86+
87+
if (version.build_options || version_verbose == 1)
88+
library_status();
89+
1090
return 0;
1191
}

‎tools/perf/perf.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
190190
break;
191191
}
192192

193+
if (!strcmp(cmd, "-vv")) {
194+
(*argv)[0] = "version";
195+
version_verbose = 1;
196+
break;
197+
}
198+
193199
/*
194200
* Check remaining flags.
195201
*/

‎tools/perf/perf.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct record_opts {
8484
struct option;
8585
extern const char * const *record_usage;
8686
extern struct option *record_options;
87+
extern int version_verbose;
8788

8889
int record__parse_freq(const struct option *opt, const char *str, int unset);
8990
#endif

0 commit comments

Comments
 (0)