Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-4.17-20180403' of git://git.kernel.org…
Browse files Browse the repository at this point in the history
…/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 <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Ingo Molnar committed Apr 4, 2018
2 parents 642e7fd + 51125a2 commit b89e791
Show file tree
Hide file tree
Showing 22 changed files with 418 additions and 116 deletions.
2 changes: 2 additions & 0 deletions tools/arch/x86/include/asm/cpufeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
#define X86_FEATURE_VPCLMULQDQ (16*32+10) /* Carry-Less Multiplication Double Quadword */
#define X86_FEATURE_AVX512_VNNI (16*32+11) /* Vector Neural Network Instructions */
#define X86_FEATURE_AVX512_BITALG (16*32+12) /* Support for VPOPCNT[B,W] and VPSHUF-BITQMB instructions */
#define X86_FEATURE_TME (16*32+13) /* Intel Total Memory Encryption */
#define X86_FEATURE_AVX512_VPOPCNTDQ (16*32+14) /* POPCNT for vectors of DW/QW */
#define X86_FEATURE_LA57 (16*32+16) /* 5-level page tables */
#define X86_FEATURE_RDPID (16*32+22) /* RDPID instruction */
Expand All @@ -328,6 +329,7 @@
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
#define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
#define X86_FEATURE_ARCH_CAPABILITIES (18*32+29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */
Expand Down
34 changes: 34 additions & 0 deletions tools/include/tools/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _TOOLS_CONFIG_H
#define _TOOLS_CONFIG_H

/* Subset of include/linux/kconfig.h */

#define __ARG_PLACEHOLDER_1 0,
#define __take_second_arg(__ignored, val, ...) val

/*
* Helper macros to use CONFIG_ options in C/CPP expressions. Note that
* these only work with boolean and tristate options.
*/

/*
* Getting something that works in C and CPP for an arg that may or may
* not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1"
* we match on the placeholder define, insert the "0," for arg1 and generate
* the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one).
* When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
* the last step cherry picks the 2nd arg, we get a zero.
*/
#define __is_defined(x) ___is_defined(x)
#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)

/*
* IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
* otherwise. For boolean options, this is equivalent to
* IS_ENABLED(CONFIG_FOO).
*/
#define IS_BUILTIN(option) __is_defined(option)

#endif /* _TOOLS_CONFIG_H */
1 change: 1 addition & 0 deletions tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ OPTIONS
- comm: command (name) of the task which can be read via /proc/<pid>/comm
- pid: command and tid of the task
- dso: name of library or module executed at the time of sample
- dso_size: size of library or module executed at the time of sample
- symbol: name of function executed at the time of sample
- symbol_size: size of function executed at the time of sample
- parent: name of function matched to the parent regex filter. Unmatched
Expand Down
3 changes: 3 additions & 0 deletions tools/perf/Documentation/perf-trace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
--sched::
Accrue thread runtime and provide a summary at the end of the session.

--failure::
Show only syscalls that failed, i.e. that returned < 0.

-i::
--input::
Process events from a given perf data file.
Expand Down
24 changes: 24 additions & 0 deletions tools/perf/Documentation/perf-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
perf-version(1)
===============

NAME
----
perf-version - display the version of perf binary

SYNOPSIS
--------
'perf version' [--build-options]

DESCRIPTION
-----------
With no options given, the 'perf version' prints the perf version
on the standard output.

If the option '--build-options' is given, then the status of
compiled-in libraries are printed on the standard output.

OPTIONS
-------
--build-options::
Prints the status of compiled-in libraries on the
standard output.
8 changes: 7 additions & 1 deletion tools/perf/Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,16 @@ else
ifneq ($(feature-dwarf_getlocations), 1)
msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
else
CFLAGS += -DHAVE_DWARF_GETLOCATIONS
CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
endif # dwarf_getlocations
endif # Dwarf support
endif # libelf support
endif # NO_LIBELF

ifeq ($(feature-glibc), 1)
CFLAGS += -DHAVE_GLIBC_SUPPORT
endif

ifdef NO_DWARF
NO_LIBDW_DWARF_UNWIND := 1
endif
Expand Down Expand Up @@ -635,6 +639,7 @@ else
else
LDFLAGS += $(PERL_EMBED_LDFLAGS)
EXTLIBS += $(PERL_EMBED_LIBADD)
CFLAGS += -DHAVE_LIBPERL_SUPPORT
$(call detected,CONFIG_LIBPERL)
endif
endif
Expand Down Expand Up @@ -671,6 +676,7 @@ else
LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
EXTLIBS += $(PYTHON_EMBED_LIBADD)
LANG_BINDINGS += $(obj-perf)python/perf.so
CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
$(call detected,CONFIG_LIBPYTHON)
endif
endif
Expand Down
11 changes: 7 additions & 4 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ struct trace {
bool multiple_threads;
bool summary;
bool summary_only;
bool failure_only;
bool show_comm;
bool print_sample;
bool show_tool_stats;
Expand Down Expand Up @@ -1565,7 +1566,7 @@ static int trace__printf_interrupted_entry(struct trace *trace)
struct thread_trace *ttrace;
size_t printed;

if (trace->current == NULL)
if (trace->failure_only || trace->current == NULL)
return 0;

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

if (sc->is_exit) {
if (!(trace->duration_filter || trace->summary_only || trace->min_stack)) {
if (!(trace->duration_filter || trace->summary_only || trace->failure_only || trace->min_stack)) {
trace__fprintf_entry_head(trace, thread, 0, false, ttrace->entry_time, trace->output);
fprintf(trace->output, "%-70s)\n", ttrace->entry_str);
}
Expand Down Expand Up @@ -1742,7 +1743,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
}
}

if (trace->summary_only)
if (trace->summary_only || (ret >= 0 && trace->failure_only))
goto out;

trace__fprintf_entry_head(trace, thread, duration, duration_calculated, ttrace->entry_time, trace->output);
Expand Down Expand Up @@ -1961,7 +1962,7 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel,
trace->output);
}

fprintf(trace->output, ")\n");
fprintf(trace->output, "\n");

if (callchain_ret > 0)
trace__fprintf_callchain(trace, sample);
Expand Down Expand Up @@ -3087,6 +3088,8 @@ int cmd_trace(int argc, const char **argv)
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
OPT_BOOLEAN('T', "time", &trace.full_time,
"Show full timestamp, not time relative to first start"),
OPT_BOOLEAN(0, "failure", &trace.failure_only,
"Show only syscalls that failed"),
OPT_BOOLEAN('s', "summary", &trace.summary_only,
"Show only syscall summary with statistics"),
OPT_BOOLEAN('S', "with-summary", &trace.summary,
Expand Down
82 changes: 81 additions & 1 deletion tools/perf/builtin-version.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,91 @@
// SPDX-License-Identifier: GPL-2.0
#include "builtin.h"
#include "perf.h"
#include "color.h"
#include <linux/compiler.h>
#include <tools/config.h>
#include <stdio.h>
#include <string.h>
#include <subcmd/parse-options.h>

int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused)
int version_verbose;

struct version {
bool build_options;
};

static struct version version;

static struct option version_options[] = {
OPT_BOOLEAN(0, "build-options", &version.build_options,
"display the build options"),
};

static const char * const version_usage[] = {
"perf version [<options>]",
NULL
};

static void on_off_print(const char *status)
{
printf("[ ");

if (!strcmp(status, "OFF"))
color_fprintf(stdout, PERF_COLOR_RED, "%-3s", status);
else
color_fprintf(stdout, PERF_COLOR_GREEN, "%-3s", status);

printf(" ]");
}

static void status_print(const char *name, const char *macro,
const char *status)
{
printf("%22s: ", name);
on_off_print(status);
printf(" # %s\n", macro);
}

#define STATUS(__d, __m) \
do { \
if (IS_BUILTIN(__d)) \
status_print(#__m, #__d, "on"); \
else \
status_print(#__m, #__d, "OFF"); \
} while (0)

static void library_status(void)
{
STATUS(HAVE_DWARF_SUPPORT, dwarf);
STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
STATUS(HAVE_GLIBC_SUPPORT, glibc);
STATUS(HAVE_GTK2_SUPPORT, gtk2);
STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
STATUS(HAVE_LIBBFD_SUPPORT, libbfd);
STATUS(HAVE_LIBELF_SUPPORT, libelf);
STATUS(HAVE_LIBNUMA_SUPPORT, libnuma);
STATUS(HAVE_LIBNUMA_SUPPORT, numa_num_possible_cpus);
STATUS(HAVE_LIBPERL_SUPPORT, libperl);
STATUS(HAVE_LIBPYTHON_SUPPORT, libpython);
STATUS(HAVE_SLANG_SUPPORT, libslang);
STATUS(HAVE_LIBCRYPTO_SUPPORT, libcrypto);
STATUS(HAVE_LIBUNWIND_SUPPORT, libunwind);
STATUS(HAVE_DWARF_SUPPORT, libdw-dwarf-unwind);
STATUS(HAVE_ZLIB_SUPPORT, zlib);
STATUS(HAVE_LZMA_SUPPORT, lzma);
STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid);
STATUS(HAVE_LIBBPF_SUPPORT, bpf);
}

int cmd_version(int argc, const char **argv)
{
argc = parse_options(argc, argv, version_options, version_usage,
PARSE_OPT_STOP_AT_NON_OPTION);

printf("perf version %s\n", perf_version_string);

if (version.build_options || version_verbose == 1)
library_status();

return 0;
}
6 changes: 6 additions & 0 deletions tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
break;
}

if (!strcmp(cmd, "-vv")) {
(*argv)[0] = "version";
version_verbose = 1;
break;
}

/*
* Check remaining flags.
*/
Expand Down
1 change: 1 addition & 0 deletions tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct record_opts {
struct option;
extern const char * const *record_usage;
extern struct option *record_options;
extern int version_verbose;

int record__parse_freq(const struct option *opt, const char *str, int unset);
#endif
8 changes: 7 additions & 1 deletion tools/perf/ui/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ void ui_browser__set_percent_color(struct ui_browser *browser,
ui_browser__set_color(browser, color);
}

void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x)
{
SLsmg_gotorc(browser->y + y, browser->x + x);
}

void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
{
SLsmg_gotorc(browser->y + y + browser->extra_title_lines, browser->x + x);
}

void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, const char *msg,
unsigned int width)
{
Expand Down Expand Up @@ -191,6 +196,7 @@ void ui_browser__refresh_dimensions(struct ui_browser *browser)
{
browser->width = SLtt_Screen_Cols - 1;
browser->height = browser->rows = SLtt_Screen_Rows - 2;
browser->rows -= browser->extra_title_lines;
browser->y = 1;
browser->x = 0;
}
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/ui/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct ui_browser {
u64 index, top_idx;
void *top, *entries;
u16 y, x, width, height, rows, columns, horiz_scroll;
u8 extra_title_lines;
int current_color;
void *priv;
const char *title;
Expand All @@ -38,6 +39,7 @@ bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row);
void ui_browser__refresh_dimensions(struct ui_browser *browser);
void ui_browser__reset_index(struct ui_browser *browser);

void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x);
void ui_browser__gotorc(struct ui_browser *browser, int y, int x);
void ui_browser__write_nstring(struct ui_browser *browser, const char *msg,
unsigned int width);
Expand Down
Loading

0 comments on commit b89e791

Please sign in to comment.