Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-4.13-20170719' 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:

User visible changes:

- Allow adding and removing fields to the default 'perf script' columns,
  using + or - as field prefixes to do so (Andi Kleen)

- Display titles in left frame in the annotate browser (Jin Yao)

- Allow resolving the DSO name with 'perf script -F brstack{sym,off},dso'
  (Mark Santaniello)

- Support function filtering in 'perf ftrace' (Namhyung Kim)

- Allow specifying function call depth in 'perf ftrace' (Namhyumg Kim)

Infrastructure changes:

- Adopt __noreturn, __printf, __scanf, noinline, __packed and __aligned
  __alignment__(()) markers, to make the tools/ source code base to be
  more compact and look more like kernel code (Arnaldo Carvalho de Melo)

- Remove unnecessary check in annotate_browser_write() (Jin Yao)

- Return arch from symbol__disassemble() so that callers, such as
  the annotate TUI browser to use arch specific formattings, such
  as the upcoming instruction micro-op fusion on Intel Core (Jin Yao)

- Remove superfluous check before use in the coresight code base (Kim
  Phillips)

- Remove unused SAMPLE_SIZE defines and BTS priv array (Kim Phillips)

- Error handling fix/tidy ups in 'perf config' (Taeung Song)

- Avoid error in the BPF proggie built with clang in 'perf test llvm'
  when PROFILE_ALL_BRANCHES is set (Wang Nan)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Jun 20, 2017
2 parents 2eb0fc9 + dfe1c6d commit 007b811
Show file tree
Hide file tree
Showing 37 changed files with 496 additions and 161 deletions.
10 changes: 10 additions & 0 deletions tools/include/linux/compiler-gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@

/* &a[0] degrades to a pointer: a different type from an array */
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))

#define noinline __attribute__((noinline))

#define __packed __attribute__((packed))

#define __noreturn __attribute__((noreturn))

#define __aligned(x) __attribute__((aligned(x)))
#define __printf(a, b) __attribute__((format(printf, a, b)))
#define __scanf(a, b) __attribute__((format(scanf, a, b)))
4 changes: 4 additions & 0 deletions tools/include/linux/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
# define __always_inline inline __attribute__((always_inline))
#endif

#ifndef noinline
#define noinline
#endif

/* Are two types/vars the same type (ignoring qualifiers)? */
#ifndef __same_type
# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
Expand Down
33 changes: 33 additions & 0 deletions tools/perf/Documentation/perf-ftrace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,39 @@ OPTIONS
Ranges of CPUs are specified with -: 0-2.
Default is to trace on all online CPUs.

-T::
--trace-funcs=::
Only trace functions given by the argument. Multiple functions
can be given by using this option more than once. The function
argument also can be a glob pattern. It will be passed to
'set_ftrace_filter' in tracefs.

-N::
--notrace-funcs=::
Do not trace functions given by the argument. Like -T option,
this can be used more than once to specify multiple functions
(or glob patterns). It will be passed to 'set_ftrace_notrace'
in tracefs.

-G::
--graph-funcs=::
Set graph filter on the given function (or a glob pattern).
This is useful for the function_graph tracer only and enables
tracing for functions executed from the given function.
This can be used more than once to specify multiple functions.
It will be passed to 'set_graph_function' in tracefs.

-g::
--nograph-funcs=::
Set graph notrace filter on the given function (or a glob pattern).
Like -G option, this is useful for the function_graph tracer only
and disables tracing for function executed from the given function.
This can be used more than once to specify multiple functions.
It will be passed to 'set_graph_notrace' in tracefs.

-D::
--graph-depth=::
Set max depth for function graph tracer to follow

SEE ALSO
--------
Expand Down
12 changes: 11 additions & 1 deletion tools/perf/Documentation/perf-script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ OPTIONS
--fields::
Comma separated list of fields to print. Options are:
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
srcline, period, iregs, brstack, brstacksym, flags, bpf-output, brstackinsn,
srcline, period, iregs, brstack, brstacksym, flags, bpf-output, brstackinsn, brstackoff,
callindent, insn, insnlen. Field list can be prepended with the type, trace, sw or hw,
to indicate to which event type the field list applies.
e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace
Expand All @@ -130,6 +130,14 @@ OPTIONS
i.e., the specified fields apply to all event types if the type string
is not given.

In addition to overriding fields, it is also possible to add or remove
fields from the defaults. For example

-F -cpu,+insn

removes the cpu field and adds the insn field. Adding/removing fields
cannot be mixed with normal overriding.

The arguments are processed in the order received. A later usage can
reset a prior request. e.g.:

Expand Down Expand Up @@ -203,6 +211,8 @@ OPTIONS
is printed. This is the full execution path leading to the sample. This is only supported when the
sample was recorded with perf record -b or -j any.

The brstackoff field will print an offset into a specific dso/binary.

-k::
--vmlinux=<file>::
vmlinux pathname
Expand Down
29 changes: 14 additions & 15 deletions tools/perf/arch/arm/util/cs-etm.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <api/fs/fs.h>
#include <linux/bitops.h>
#include <linux/compiler.h>
#include <linux/coresight-pmu.h>
#include <linux/kernel.h>
#include <linux/log2.h>
Expand Down Expand Up @@ -202,19 +203,18 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
pr_debug2("%s snapshot size: %zu\n", CORESIGHT_ETM_PMU_NAME,
opts->auxtrace_snapshot_size);

if (cs_etm_evsel) {
/*
* To obtain the auxtrace buffer file descriptor, the auxtrace
* event must come first.
*/
perf_evlist__to_front(evlist, cs_etm_evsel);
/*
* In the case of per-cpu mmaps, we need the CPU on the
* AUX event.
*/
if (!cpu_map__empty(cpus))
perf_evsel__set_sample_bit(cs_etm_evsel, CPU);
}
/*
* To obtain the auxtrace buffer file descriptor, the auxtrace
* event must come first.
*/
perf_evlist__to_front(evlist, cs_etm_evsel);

/*
* In the case of per-cpu mmaps, we need the CPU on the
* AUX event.
*/
if (!cpu_map__empty(cpus))
perf_evsel__set_sample_bit(cs_etm_evsel, CPU);

/* Add dummy event to keep tracking */
if (opts->full_auxtrace) {
Expand Down Expand Up @@ -583,8 +583,7 @@ static FILE *cs_device__open_file(const char *name)

}

static __attribute__((format(printf, 2, 3)))
int cs_device__print_file(const char *name, const char *fmt, ...)
static int __printf(2, 3) cs_device__print_file(const char *name, const char *fmt, ...)
{
va_list args;
FILE *file;
Expand Down
4 changes: 0 additions & 4 deletions tools/perf/arch/x86/util/intel-bts.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
#define KiB_MASK(x) (KiB(x) - 1)
#define MiB_MASK(x) (MiB(x) - 1)

#define INTEL_BTS_DFLT_SAMPLE_SIZE KiB(4)

#define INTEL_BTS_MAX_SAMPLE_SIZE KiB(60)

struct intel_bts_snapshot_ref {
void *ref_buf;
size_t ref_offset;
Expand Down
4 changes: 0 additions & 4 deletions tools/perf/arch/x86/util/intel-pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
#define KiB_MASK(x) (KiB(x) - 1)
#define MiB_MASK(x) (MiB(x) - 1)

#define INTEL_PT_DEFAULT_SAMPLE_SIZE KiB(4)

#define INTEL_PT_MAX_SAMPLE_SIZE KiB(60)

#define INTEL_PT_PSB_PERIOD_NEAR 256

struct intel_pt_snapshot_ref {
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ static inline uint32_t lfsr_32(uint32_t lfsr)
* kernel (KSM, zero page, etc.) cannot optimize away RAM
* accesses:
*/
static inline u64 access_data(u64 *data __attribute__((unused)), u64 val)
static inline u64 access_data(u64 *data, u64 val)
{
if (g->p.data_reads)
val += *data;
Expand Down
67 changes: 39 additions & 28 deletions tools/perf/builtin-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static int parse_config_arg(char *arg, char **var, char **value)

int cmd_config(int argc, const char **argv)
{
int i, ret = 0;
int i, ret = -1;
struct perf_config_set *set;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
const char *config_filename;
Expand Down Expand Up @@ -186,52 +186,63 @@ int cmd_config(int argc, const char **argv)
* because of reinitializing with options config file location.
*/
set = perf_config_set__new();
if (!set) {
ret = -1;
if (!set)
goto out_err;
}

switch (actions) {
case ACTION_LIST:
if (argc) {
pr_err("Error: takes no arguments\n");
parse_options_usage(config_usage, config_options, "l", 1);
} else {
ret = show_config(set);
if (ret < 0)
if (show_config(set) < 0) {
pr_err("Nothing configured, "
"please check your %s \n", config_filename);
goto out_err;
}
}
break;
default:
if (argc) {
for (i = 0; argv[i]; i++) {
char *var, *value;
char *arg = strdup(argv[i]);

if (!arg) {
pr_err("%s: strdup failed\n", __func__);
ret = -1;
break;
}
if (!argc) {
usage_with_options(config_usage, config_options);
break;
}

if (parse_config_arg(arg, &var, &value) < 0) {
free(arg);
ret = -1;
break;
}
for (i = 0; argv[i]; i++) {
char *var, *value;
char *arg = strdup(argv[i]);

if (!arg) {
pr_err("%s: strdup failed\n", __func__);
goto out_err;
}

if (value == NULL)
ret = show_spec_config(set, var);
else
ret = set_config(set, config_filename, var, value);
if (parse_config_arg(arg, &var, &value) < 0) {
free(arg);
goto out_err;
}
} else
usage_with_options(config_usage, config_options);

if (value == NULL) {
if (show_spec_config(set, var) < 0) {
pr_err("%s is not configured: %s\n",
var, config_filename);
free(arg);
goto out_err;
}
} else {
if (set_config(set, config_filename, var, value) < 0) {
pr_err("Failed to set '%s=%s' on %s\n",
var, value, config_filename);
free(arg);
goto out_err;
}
}
free(arg);
}
}

perf_config_set__delete(set);
ret = 0;
out_err:
perf_config_set__delete(set);
return ret;
}
Loading

0 comments on commit 007b811

Please sign in to comment.