Skip to content

Commit ee438ec

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-4.14-20170725' of git://git.kernel.org/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 <[email protected]>
2 parents 510457e + 62e6039 commit ee438ec

Some content is hidden

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

43 files changed

+798
-300
lines changed

tools/include/linux/string.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef _TOOLS_LINUX_STRING_H_
22
#define _TOOLS_LINUX_STRING_H_
33

4-
54
#include <linux/types.h> /* for size_t */
5+
#include <string.h>
66

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

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

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

21-
int prefixcmp(const char *str, const char *prefix);
21+
/**
22+
* strstarts - does @str start with @prefix?
23+
* @str: string to examine
24+
* @prefix: prefix to look for.
25+
*/
26+
static inline bool strstarts(const char *str, const char *prefix)
27+
{
28+
return strncmp(str, prefix, strlen(prefix)) == 0;
29+
}
2230

2331
#endif /* _LINUX_STRING_H_ */

tools/include/uapi/linux/sched.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#ifndef _UAPI_LINUX_SCHED_H
2+
#define _UAPI_LINUX_SCHED_H
3+
4+
/*
5+
* cloning flags:
6+
*/
7+
#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
8+
#define CLONE_VM 0x00000100 /* set if VM shared between processes */
9+
#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
10+
#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
11+
#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
12+
#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
13+
#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
14+
#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
15+
#define CLONE_THREAD 0x00010000 /* Same thread group? */
16+
#define CLONE_NEWNS 0x00020000 /* New mount namespace group */
17+
#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
18+
#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
19+
#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
20+
#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
21+
#define CLONE_DETACHED 0x00400000 /* Unused, ignored */
22+
#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
23+
#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
24+
#define CLONE_NEWCGROUP 0x02000000 /* New cgroup namespace */
25+
#define CLONE_NEWUTS 0x04000000 /* New utsname namespace */
26+
#define CLONE_NEWIPC 0x08000000 /* New ipc namespace */
27+
#define CLONE_NEWUSER 0x10000000 /* New user namespace */
28+
#define CLONE_NEWPID 0x20000000 /* New pid namespace */
29+
#define CLONE_NEWNET 0x40000000 /* New network namespace */
30+
#define CLONE_IO 0x80000000 /* Clone io context */
31+
32+
/*
33+
* Scheduling policies
34+
*/
35+
#define SCHED_NORMAL 0
36+
#define SCHED_FIFO 1
37+
#define SCHED_RR 2
38+
#define SCHED_BATCH 3
39+
/* SCHED_ISO: reserved but not implemented yet */
40+
#define SCHED_IDLE 5
41+
#define SCHED_DEADLINE 6
42+
43+
/* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */
44+
#define SCHED_RESET_ON_FORK 0x40000000
45+
46+
/*
47+
* For the sched_{set,get}attr() calls
48+
*/
49+
#define SCHED_FLAG_RESET_ON_FORK 0x01
50+
#define SCHED_FLAG_RECLAIM 0x02
51+
52+
#endif /* _UAPI_LINUX_SCHED_H */

tools/lib/string.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,45 @@ void *memdup(const void *src, size_t len)
3939
* @s: input string
4040
* @res: result
4141
*
42-
* This routine returns 0 iff the first character is one of 'Yy1Nn0'.
43-
* Otherwise it will return -EINVAL. Value pointed to by res is
44-
* updated upon finding a match.
42+
* This routine returns 0 iff the first character is one of 'Yy1Nn0', or
43+
* [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value
44+
* pointed to by res is updated upon finding a match.
4545
*/
4646
int strtobool(const char *s, bool *res)
4747
{
48+
if (!s)
49+
return -EINVAL;
50+
4851
switch (s[0]) {
4952
case 'y':
5053
case 'Y':
5154
case '1':
5255
*res = true;
53-
break;
56+
return 0;
5457
case 'n':
5558
case 'N':
5659
case '0':
5760
*res = false;
58-
break;
61+
return 0;
62+
case 'o':
63+
case 'O':
64+
switch (s[1]) {
65+
case 'n':
66+
case 'N':
67+
*res = true;
68+
return 0;
69+
case 'f':
70+
case 'F':
71+
*res = false;
72+
return 0;
73+
default:
74+
break;
75+
}
5976
default:
60-
return -EINVAL;
77+
break;
6178
}
62-
return 0;
79+
80+
return -EINVAL;
6381
}
6482

6583
/**
@@ -87,12 +105,3 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size)
87105
}
88106
return ret;
89107
}
90-
91-
int prefixcmp(const char *str, const char *prefix)
92-
{
93-
for (; ; str++, prefix++)
94-
if (!*prefix)
95-
return 0;
96-
else if (*str != *prefix)
97-
return (unsigned char)*prefix - (unsigned char)*str;
98-
}

tools/lib/subcmd/help.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static void list_commands_in_dir(struct cmdnames *cmds,
171171
while ((de = readdir(dir)) != NULL) {
172172
int entlen;
173173

174-
if (prefixcmp(de->d_name, prefix))
174+
if (!strstarts(de->d_name, prefix))
175175
continue;
176176

177177
astrcat(&buf, de->d_name);

tools/lib/subcmd/parse-options.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
368368
return 0;
369369
}
370370
if (!rest) {
371-
if (!prefixcmp(options->long_name, "no-")) {
371+
if (strstarts(options->long_name, "no-")) {
372372
/*
373373
* The long name itself starts with "no-", so
374374
* accept the option without "no-" so that users
@@ -381,7 +381,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
381381
goto match;
382382
}
383383
/* Abbreviated case */
384-
if (!prefixcmp(options->long_name + 3, arg)) {
384+
if (strstarts(options->long_name + 3, arg)) {
385385
flags |= OPT_UNSET;
386386
goto is_abbreviated;
387387
}
@@ -406,7 +406,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
406406
continue;
407407
}
408408
/* negated and abbreviated very much? */
409-
if (!prefixcmp("no-", arg)) {
409+
if (strstarts("no-", arg)) {
410410
flags |= OPT_UNSET;
411411
goto is_abbreviated;
412412
}
@@ -416,7 +416,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
416416
flags |= OPT_UNSET;
417417
rest = skip_prefix(arg + 3, options->long_name);
418418
/* abbreviated and negated? */
419-
if (!rest && !prefixcmp(options->long_name, arg + 3))
419+
if (!rest && strstarts(options->long_name, arg + 3))
420420
goto is_abbreviated;
421421
if (!rest)
422422
continue;
@@ -456,15 +456,15 @@ static void check_typos(const char *arg, const struct option *options)
456456
if (strlen(arg) < 3)
457457
return;
458458

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

464464
for (; options->type != OPTION_END; options++) {
465465
if (!options->long_name)
466466
continue;
467-
if (!prefixcmp(options->long_name, arg)) {
467+
if (strstarts(options->long_name, arg)) {
468468
fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg);
469469
exit(129);
470470
}
@@ -933,10 +933,10 @@ int parse_options_usage(const char * const *usagestr,
933933
if (opts->long_name == NULL)
934934
continue;
935935

936-
if (!prefixcmp(opts->long_name, optstr))
936+
if (strstarts(opts->long_name, optstr))
937937
print_option_help(opts, 0);
938-
if (!prefixcmp("no-", optstr) &&
939-
!prefixcmp(opts->long_name, optstr + 3))
938+
if (strstarts("no-", optstr) &&
939+
strstarts(opts->long_name, optstr + 3))
940940
print_option_help(opts, 0);
941941
}
942942

tools/perf/Documentation/perf-top.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ Default is to monitor all CPUS.
237237
--hierarchy::
238238
Enable hierarchy output.
239239

240+
--force::
241+
Don't do ownership validation.
242+
243+
240244
INTERACTIVE PROMPTING KEYS
241245
--------------------------
242246

tools/perf/MANIFEST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ tools/include/linux/hash.h
7070
tools/include/linux/kernel.h
7171
tools/include/linux/list.h
7272
tools/include/linux/log2.h
73+
tools/include/uapi/asm-generic/fcntl.h
7374
tools/include/uapi/asm-generic/mman-common.h
7475
tools/include/uapi/asm-generic/mman.h
7576
tools/include/uapi/linux/bpf.h
@@ -78,6 +79,7 @@ tools/include/uapi/linux/fcntl.h
7879
tools/include/uapi/linux/hw_breakpoint.h
7980
tools/include/uapi/linux/mman.h
8081
tools/include/uapi/linux/perf_event.h
82+
tools/include/uapi/linux/sched.h
8183
tools/include/uapi/linux/stat.h
8284
tools/include/linux/poison.h
8385
tools/include/linux/rbtree.h

tools/perf/Makefile.perf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ include ../scripts/utilities.mak
3333
#
3434
# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
3535
#
36+
# Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
37+
# EXTLIBS.
38+
#
39+
# Define EXTRA_PERFLIBS to pass extra libraries to PERFLIBS.
40+
#
3641
# Define NO_DWARF if you do not want debug-info analysis feature at all.
3742
#
3843
# Define WERROR=0 to disable treating any warnings as errors.
@@ -352,7 +357,8 @@ ifdef ASCIIDOC8
352357
export ASCIIDOC8
353358
endif
354359

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

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

514520
$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
515-
$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $< -lelf -lrt
521+
$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
516522
endif
517523

518524
$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)

tools/perf/arch/s390/util/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
libperf-y += header.o
2+
libperf-y += sym-handling.o
23
libperf-y += kvm-stat.o
34

45
libperf-$(CONFIG_DWARF) += dwarf-regs.o
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Architecture specific ELF symbol handling and relocation mapping.
3+
*
4+
* Copyright 2017 IBM Corp.
5+
* Author(s): Thomas Richter <[email protected]>
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License (version 2 only)
9+
* as published by the Free Software Foundation.
10+
*/
11+
12+
#include "symbol.h"
13+
14+
#ifdef HAVE_LIBELF_SUPPORT
15+
bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
16+
{
17+
if (ehdr.e_type == ET_EXEC)
18+
return false;
19+
return ehdr.e_type == ET_REL || ehdr.e_type == ET_DYN;
20+
}
21+
22+
#endif

0 commit comments

Comments
 (0)