Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-4.14-20170725' 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 improvemends and fixes for v4.14:

New features:

- Filter out 'sshd' in the tracer ancestry in 'perf trace' syswide tracing,
  to elliminate tracing loops (Arnaldo Carvalho de Melo)

- Support lookup of symbols in other mount namespaces in 'perf top' (Krister Johansen)

- Initial 'clone' syscall args beautifier in 'perf trace' (Arnaldo Carvalho de Melo)

User visible changes:

- Ignore 'fd' and 'offset' args for MAP_ANONYMOUS in 'perf trace'
  (Arnaldo Carvalho de Melo)

- Process tracing data in 'perf annotate' pipe mode (David Carrillo-Cisneros)

- Make 'perf report --branch-history' work without callgraphs(-g) option
  in perf record (Jin Yao)

- Tag branch type/flag on "to" and tag cycles on "from" in 'perf report' (Jin Yao)

Fixes:

- Fix jvmti linker error when libelf config is disabled (Sudeep Holla)

- Fix cgroups refcount usage (Arnaldo Carvalho de Melo)

- Fix kernel symbol adjustment for s390x (Thomas Richter)

- Fix 'perf report --stdio --show-total-period', it was showing the
  number of samples, not the total period (Taeung Song)

Infrastructure changes:

- Add perf_sample dictionary to tracepoint handlers in 'perf script'
  python, which were already present for other types of events
  (hardware, etc) (Arun Kalyanasundaram)

- Make build fail on vendor events JSON parse error (Andi Kleen)

- Adopt strstarts() from the kernel (Arnaldo Carvalho de Melo)

Arch specific changes:

- Set no_aux_samples for the tracking event in Intel PT (Kan Liang)

- Always set no branch for Intel PT dummy event (Kan Liang)

Trivial changes:

- Simplify some error handlers in 'perf script' (Dan Carpenter)

- Add EXCLUDE_EXTLIBS and EXTRA_PERFLIBS to makefile (David Carrillo-Cisneros)

Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Jul 26, 2017
2 parents 510457e + 62e6039 commit ee438ec
Show file tree
Hide file tree
Showing 43 changed files with 798 additions and 300 deletions.
12 changes: 10 additions & 2 deletions tools/include/linux/string.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _TOOLS_LINUX_STRING_H_
#define _TOOLS_LINUX_STRING_H_


#include <linux/types.h> /* for size_t */
#include <string.h>

void *memdup(const void *src, size_t len);

Expand All @@ -18,6 +18,14 @@ extern size_t strlcpy(char *dest, const char *src, size_t size);

char *str_error_r(int errnum, char *buf, size_t buflen);

int prefixcmp(const char *str, const char *prefix);
/**
* strstarts - does @str start with @prefix?
* @str: string to examine
* @prefix: prefix to look for.
*/
static inline bool strstarts(const char *str, const char *prefix)
{
return strncmp(str, prefix, strlen(prefix)) == 0;
}

#endif /* _LINUX_STRING_H_ */
52 changes: 52 additions & 0 deletions tools/include/uapi/linux/sched.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef _UAPI_LINUX_SCHED_H
#define _UAPI_LINUX_SCHED_H

/*
* cloning flags:
*/
#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
#define CLONE_VM 0x00000100 /* set if VM shared between processes */
#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
#define CLONE_THREAD 0x00010000 /* Same thread group? */
#define CLONE_NEWNS 0x00020000 /* New mount namespace group */
#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
#define CLONE_DETACHED 0x00400000 /* Unused, ignored */
#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
#define CLONE_NEWCGROUP 0x02000000 /* New cgroup namespace */
#define CLONE_NEWUTS 0x04000000 /* New utsname namespace */
#define CLONE_NEWIPC 0x08000000 /* New ipc namespace */
#define CLONE_NEWUSER 0x10000000 /* New user namespace */
#define CLONE_NEWPID 0x20000000 /* New pid namespace */
#define CLONE_NEWNET 0x40000000 /* New network namespace */
#define CLONE_IO 0x80000000 /* Clone io context */

/*
* Scheduling policies
*/
#define SCHED_NORMAL 0
#define SCHED_FIFO 1
#define SCHED_RR 2
#define SCHED_BATCH 3
/* SCHED_ISO: reserved but not implemented yet */
#define SCHED_IDLE 5
#define SCHED_DEADLINE 6

/* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */
#define SCHED_RESET_ON_FORK 0x40000000

/*
* For the sched_{set,get}attr() calls
*/
#define SCHED_FLAG_RESET_ON_FORK 0x01
#define SCHED_FLAG_RECLAIM 0x02

#endif /* _UAPI_LINUX_SCHED_H */
41 changes: 25 additions & 16 deletions tools/lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,45 @@ void *memdup(const void *src, size_t len)
* @s: input string
* @res: result
*
* This routine returns 0 iff the first character is one of 'Yy1Nn0'.
* Otherwise it will return -EINVAL. Value pointed to by res is
* updated upon finding a match.
* This routine returns 0 iff the first character is one of 'Yy1Nn0', or
* [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value
* pointed to by res is updated upon finding a match.
*/
int strtobool(const char *s, bool *res)
{
if (!s)
return -EINVAL;

switch (s[0]) {
case 'y':
case 'Y':
case '1':
*res = true;
break;
return 0;
case 'n':
case 'N':
case '0':
*res = false;
break;
return 0;
case 'o':
case 'O':
switch (s[1]) {
case 'n':
case 'N':
*res = true;
return 0;
case 'f':
case 'F':
*res = false;
return 0;
default:
break;
}
default:
return -EINVAL;
break;
}
return 0;

return -EINVAL;
}

/**
Expand Down Expand Up @@ -87,12 +105,3 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size)
}
return ret;
}

int prefixcmp(const char *str, const char *prefix)
{
for (; ; str++, prefix++)
if (!*prefix)
return 0;
else if (*str != *prefix)
return (unsigned char)*prefix - (unsigned char)*str;
}
2 changes: 1 addition & 1 deletion tools/lib/subcmd/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static void list_commands_in_dir(struct cmdnames *cmds,
while ((de = readdir(dir)) != NULL) {
int entlen;

if (prefixcmp(de->d_name, prefix))
if (!strstarts(de->d_name, prefix))
continue;

astrcat(&buf, de->d_name);
Expand Down
18 changes: 9 additions & 9 deletions tools/lib/subcmd/parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
return 0;
}
if (!rest) {
if (!prefixcmp(options->long_name, "no-")) {
if (strstarts(options->long_name, "no-")) {
/*
* The long name itself starts with "no-", so
* accept the option without "no-" so that users
Expand All @@ -381,7 +381,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
goto match;
}
/* Abbreviated case */
if (!prefixcmp(options->long_name + 3, arg)) {
if (strstarts(options->long_name + 3, arg)) {
flags |= OPT_UNSET;
goto is_abbreviated;
}
Expand All @@ -406,7 +406,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
continue;
}
/* negated and abbreviated very much? */
if (!prefixcmp("no-", arg)) {
if (strstarts("no-", arg)) {
flags |= OPT_UNSET;
goto is_abbreviated;
}
Expand All @@ -416,7 +416,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
flags |= OPT_UNSET;
rest = skip_prefix(arg + 3, options->long_name);
/* abbreviated and negated? */
if (!rest && !prefixcmp(options->long_name, arg + 3))
if (!rest && strstarts(options->long_name, arg + 3))
goto is_abbreviated;
if (!rest)
continue;
Expand Down Expand Up @@ -456,15 +456,15 @@ static void check_typos(const char *arg, const struct option *options)
if (strlen(arg) < 3)
return;

if (!prefixcmp(arg, "no-")) {
if (strstarts(arg, "no-")) {
fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg);
exit(129);
}

for (; options->type != OPTION_END; options++) {
if (!options->long_name)
continue;
if (!prefixcmp(options->long_name, arg)) {
if (strstarts(options->long_name, arg)) {
fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg);
exit(129);
}
Expand Down Expand Up @@ -933,10 +933,10 @@ int parse_options_usage(const char * const *usagestr,
if (opts->long_name == NULL)
continue;

if (!prefixcmp(opts->long_name, optstr))
if (strstarts(opts->long_name, optstr))
print_option_help(opts, 0);
if (!prefixcmp("no-", optstr) &&
!prefixcmp(opts->long_name, optstr + 3))
if (strstarts("no-", optstr) &&
strstarts(opts->long_name, optstr + 3))
print_option_help(opts, 0);
}

Expand Down
4 changes: 4 additions & 0 deletions tools/perf/Documentation/perf-top.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ Default is to monitor all CPUS.
--hierarchy::
Enable hierarchy output.

--force::
Don't do ownership validation.


INTERACTIVE PROMPTING KEYS
--------------------------

Expand Down
2 changes: 2 additions & 0 deletions tools/perf/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ tools/include/linux/hash.h
tools/include/linux/kernel.h
tools/include/linux/list.h
tools/include/linux/log2.h
tools/include/uapi/asm-generic/fcntl.h
tools/include/uapi/asm-generic/mman-common.h
tools/include/uapi/asm-generic/mman.h
tools/include/uapi/linux/bpf.h
Expand All @@ -78,6 +79,7 @@ tools/include/uapi/linux/fcntl.h
tools/include/uapi/linux/hw_breakpoint.h
tools/include/uapi/linux/mman.h
tools/include/uapi/linux/perf_event.h
tools/include/uapi/linux/sched.h
tools/include/uapi/linux/stat.h
tools/include/linux/poison.h
tools/include/linux/rbtree.h
Expand Down
10 changes: 8 additions & 2 deletions tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ include ../scripts/utilities.mak
#
# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
#
# Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
# EXTLIBS.
#
# Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.
#
# Define NO_DWARF if you do not want debug-info analysis feature at all.
#
# Define WERROR=0 to disable treating any warnings as errors.
Expand Down Expand Up @@ -352,7 +357,8 @@ ifdef ASCIIDOC8
export ASCIIDOC8
endif

LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group

ifeq ($(USE_CLANG), 1)
CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
Expand Down Expand Up @@ -512,7 +518,7 @@ $(LIBJVMTI_IN): FORCE
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti

$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $< -lelf -lrt
$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
endif

$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/s390/util/Build
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
libperf-y += header.o
libperf-y += sym-handling.o
libperf-y += kvm-stat.o

libperf-$(CONFIG_DWARF) += dwarf-regs.o
Expand Down
22 changes: 22 additions & 0 deletions tools/perf/arch/s390/util/sym-handling.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Architecture specific ELF symbol handling and relocation mapping.
*
* Copyright 2017 IBM Corp.
* Author(s): Thomas Richter <tmricht@linux.vnet.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2 only)
* as published by the Free Software Foundation.
*/

#include "symbol.h"

#ifdef HAVE_LIBELF_SUPPORT
bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
{
if (ehdr.e_type == ET_EXEC)
return false;
return ehdr.e_type == ET_REL || ehdr.e_type == ET_DYN;
}

#endif
3 changes: 3 additions & 0 deletions tools/perf/arch/x86/util/intel-pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
perf_evsel__set_sample_bit(switch_evsel, TID);
perf_evsel__set_sample_bit(switch_evsel, TIME);
perf_evsel__set_sample_bit(switch_evsel, CPU);
perf_evsel__reset_sample_bit(switch_evsel, BRANCH_STACK);

opts->record_switch_events = false;
ptr->have_sched_switch = 3;
Expand Down Expand Up @@ -752,6 +753,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
tracking_evsel->attr.freq = 0;
tracking_evsel->attr.sample_period = 1;

tracking_evsel->no_aux_samples = true;
if (need_immediate)
tracking_evsel->immediate = true;

Expand All @@ -761,6 +763,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
/* And the CPU for switch events */
perf_evsel__set_sample_bit(tracking_evsel, CPU);
}
perf_evsel__reset_sample_bit(tracking_evsel, BRANCH_STACK);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,13 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
*/
process_branch_stack(sample->branch_stack, al, sample);

sample->period = 1;
sample->weight = 1;

he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true);
if (he == NULL)
return -ENOMEM;

ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
ret = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
hists__inc_nr_samples(hists, true);
return ret;
}
Expand Down Expand Up @@ -397,6 +396,7 @@ int cmd_annotate(int argc, const char **argv)
.namespaces = perf_event__process_namespaces,
.attr = perf_event__process_attr,
.build_id = perf_event__process_build_id,
.tracing_data = perf_event__process_tracing_data,
.feature = perf_event__process_feature,
.ordered_events = true,
.ordering_requires_timestamps = true,
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/builtin-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "util/util.h"
#include "util/debug.h"
#include "util/config.h"
#include <linux/string.h>

static bool use_system_config, use_user_config;

Expand Down Expand Up @@ -79,7 +80,7 @@ static int show_spec_config(struct perf_config_set *set, const char *var)
return -1;

perf_config_items__for_each_entry(&set->sections, section) {
if (prefixcmp(var, section->name) != 0)
if (!strstarts(var, section->name))
continue;

perf_config_items__for_each_entry(&section->items, item) {
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static int perf_ftrace_config(const char *var, const char *value, void *cb)
{
struct perf_ftrace *ftrace = cb;

if (prefixcmp(var, "ftrace."))
if (!strstarts(var, "ftrace."))
return 0;

if (strcmp(var, "ftrace.tracer"))
Expand Down
Loading

0 comments on commit ee438ec

Please sign in to comment.