Skip to content

Commit 883f4de

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-4.21-20181218' 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: - Implement BPF based syscall filtering in 'perf trace', using BPF maps and the augmented_raw_syscalls.c BPF proggie (Arnaldo Carvalho de Melo) - Allow specifying in .perfconfig a set of events use in 'perf trace' in addition to any other specified from the command line. This initially will be used to always use the augmented_raw_syscalls.o precompiled BPF program for getting pointer contents. (Arnaldo Carvalho de Melo) - Allow fine grained control about how the syscall output should be formatted. This will be used to allow producing the same output produced by the 'strace' tool, to then use in regression tests comparing the output of 'perf trace' with the one produced from 'strace' (Arnaldo Carvalho de Melo) - Beautify the renameat2 olddirfd, newdirfd and flags arguments (Arnaldo Carvalho de Melo) - Beautify arch_prctl 'code' syscall arg (Arnaldo Carvalho de Melo) - Beautify fadvise64 'advice' syscall arg (Arnaldo Carvalho de Melo) - Relax checks on perf-PID.map ownership, resulting in symbols in executable anonymous maps setup by JITs in things like node.js to be resolved in a 'perf top' session run by root without the need for --force to be used (Arnaldo Carvalho de Melo) - Update asm-generic/unistd.h copy (Arnaldo Carvalho de Melo) - Do not use the first and last symbols when setting up address filters in auxtrace, this fails when we don't have a symbol table, filter the entire area based on the dso size. (Adrian Hunter) - Do not use kernel headers to build libsubcmd, we shouldn't use anything from outside tools/, fixes the build with the Android NDK (Arnaldo Carvalho de Melo) - Add several prototypes for systems lacking those, such as open_memstream(), sigqueue(), fixing warnings building with Android's bionic libc that were preventing the use of -Werror there (Arnaldo Carvalho de Melo) - Use LDFLAGS in the libtraceevent build commands, allowing developers to override its values (Jiri Olsa) - Link libperf-jvmti.so with LDFLAGS variable, allowing distro packages to propagate its settings when building this library (Jiri Olsa) - cs-etm (ARM CoreSight) fixes: (Leo Yan) - Correct packets swapping in cs_etm__flush() - Avoid stale branch samples when flush packet - Remove unused 'trace_on' in cs_etm_decoder - Refactor enumeration cs_etm_sample_type - Rename CS_ETM_TRACE_ON to CS_ETM_DISCONTINUITY - Treat NO_SYNC element as trace discontinuity - Treat EO_TRACE element as trace discontinuity - Generate branch sample for exception packet - Use shebangs in the 'perf test' shell scripts, making them identifiable as shell scripts (Michael Petlan) - Avoid segfaults caused by negated options in 'perf stat' (Michael Petlan) - Fix processing of dereferenced args in bprintk events in libtracevent (Steven Rostedt) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents ca46afd + 89a0948 commit 883f4de

Some content is hidden

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

64 files changed

+842
-252
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _ASM_X86_PRCTL_H
3+
#define _ASM_X86_PRCTL_H
4+
5+
#define ARCH_SET_GS 0x1001
6+
#define ARCH_SET_FS 0x1002
7+
#define ARCH_GET_FS 0x1003
8+
#define ARCH_GET_GS 0x1004
9+
10+
#define ARCH_GET_CPUID 0x1011
11+
#define ARCH_SET_CPUID 0x1012
12+
13+
#define ARCH_MAP_VDSO_X32 0x2001
14+
#define ARCH_MAP_VDSO_32 0x2002
15+
#define ARCH_MAP_VDSO_64 0x2003
16+
17+
#endif /* _ASM_X86_PRCTL_H */

tools/include/uapi/asm-generic/unistd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,10 @@ __SYSCALL(__NR_rseq, sys_rseq)
760760
#define __NR_ftruncate __NR3264_ftruncate
761761
#define __NR_lseek __NR3264_lseek
762762
#define __NR_sendfile __NR3264_sendfile
763+
#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
763764
#define __NR_newfstatat __NR3264_fstatat
764765
#define __NR_fstat __NR3264_fstat
766+
#endif
765767
#define __NR_mmap __NR3264_mmap
766768
#define __NR_fadvise64 __NR3264_fadvise64
767769
#ifdef __NR3264_stat
@@ -776,8 +778,10 @@ __SYSCALL(__NR_rseq, sys_rseq)
776778
#define __NR_ftruncate64 __NR3264_ftruncate
777779
#define __NR_llseek __NR3264_lseek
778780
#define __NR_sendfile64 __NR3264_sendfile
781+
#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
779782
#define __NR_fstatat64 __NR3264_fstatat
780783
#define __NR_fstat64 __NR3264_fstat
784+
#endif
781785
#define __NR_mmap2 __NR3264_mmap
782786
#define __NR_fadvise64_64 __NR3264_fadvise64
783787
#ifdef __NR3264_stat

tools/include/uapi/linux/fadvise.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef FADVISE_H_INCLUDED
3+
#define FADVISE_H_INCLUDED
4+
5+
#define POSIX_FADV_NORMAL 0 /* No further special treatment. */
6+
#define POSIX_FADV_RANDOM 1 /* Expect random page references. */
7+
#define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
8+
#define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
9+
10+
/*
11+
* The advise values for POSIX_FADV_DONTNEED and POSIX_ADV_NOREUSE
12+
* for s390-64 differ from the values for the rest of the world.
13+
*/
14+
#if defined(__s390x__)
15+
#define POSIX_FADV_DONTNEED 6 /* Don't need these pages. */
16+
#define POSIX_FADV_NOREUSE 7 /* Data will be accessed once. */
17+
#else
18+
#define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
19+
#define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
20+
#endif
21+
22+
#endif /* FADVISE_H_INCLUDED */

tools/lib/subcmd/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ endif
3636
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
3737

3838
CFLAGS += -I$(srctree)/tools/include/
39-
CFLAGS += -I$(srctree)/include/uapi
40-
CFLAGS += -I$(srctree)/include
4139

4240
SUBCMD_IN := $(OUTPUT)libsubcmd-in.o
4341

tools/lib/traceevent/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ $(TE_IN): force
177177
$(Q)$(MAKE) $(build)=libtraceevent
178178

179179
$(OUTPUT)libtraceevent.so.$(EVENT_PARSE_VERSION): $(TE_IN)
180-
$(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@
180+
$(QUIET_LINK)$(CC) --shared $(LDFLAGS) $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@
181181
@ln -sf $(@F) $(OUTPUT)libtraceevent.so
182182
@ln -sf $(@F) $(OUTPUT)libtraceevent.so.$(EP_VERSION)
183183

@@ -196,7 +196,7 @@ $(PLUGINS_IN): force
196196
$(Q)$(MAKE) $(build)=$(plugin_obj)
197197

198198
$(OUTPUT)%.so: $(OUTPUT)%-in.o
199-
$(QUIET_LINK)$(CC) $(CFLAGS) -shared -nostartfiles -o $@ $^
199+
$(QUIET_LINK)$(CC) $(CFLAGS) -shared $(LDFLAGS) -nostartfiles -o $@ $^
200200

201201
define make_version.h
202202
(echo '/* This file is automatically generated. Do not modify. */'; \

tools/lib/traceevent/event-parse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4973,6 +4973,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e
49734973

49744974
if (arg->type == TEP_PRINT_BSTRING) {
49754975
trace_seq_puts(s, arg->string.string);
4976+
arg = arg->next;
49764977
break;
49774978
}
49784979

tools/perf/Documentation/perf-config.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,38 @@ diff.*::
521521
Possible values are 'delta', 'delta-abs', 'ratio' and
522522
'wdiff'. Default is 'delta'.
523523

524+
trace.*::
525+
trace.add_events::
526+
Allows adding a set of events to add to the ones specified
527+
by the user, or use as a default one if none was specified.
528+
The initial use case is to add augmented_raw_syscalls.o to
529+
activate the 'perf trace' logic that looks for syscall
530+
pointer contents after the normal tracepoint payload.
531+
532+
trace.args_alignment::
533+
Number of columns to align the argument list, default is 70,
534+
use 40 for the strace default, zero to no alignment.
535+
536+
trace.no_inherit::
537+
Do not follow children threads.
538+
539+
trace.show_arg_names::
540+
Should syscall argument names be printed? If not then trace.show_zeros
541+
will be set.
542+
543+
trace.show_duration::
544+
Show syscall duration.
545+
546+
trace.show_prefix::
547+
If set to 'yes' will show common string prefixes in tables. The default
548+
is to remove the common prefix in things like "MAP_SHARED", showing just "SHARED".
549+
550+
trace.show_timestamp::
551+
Show syscall start timestamp.
552+
553+
trace.show_zeros::
554+
Do not suppress syscall arguments that are equal to zero.
555+
524556
SEE ALSO
525557
--------
526558
linkperf:perf[1]

tools/perf/Documentation/perf-trace.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
205205
because the file may be huge. A time out is needed in such cases.
206206
This option sets the time out limit. The default value is 500 ms.
207207

208+
--sort-events::
209+
Do sorting on batches of events, use when noticing out of order events that
210+
may happen, for instance, when a thread gets migrated to a different CPU
211+
while processing a syscall.
212+
213+
208214
PAGEFAULTS
209215
----------
210216

tools/perf/Makefile.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ ifndef NO_BIONIC
294294
$(call feature_check,bionic)
295295
ifeq ($(feature-bionic), 1)
296296
BIONIC := 1
297+
CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
298+
CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
297299
EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
298300
EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
299301
endif

tools/perf/Makefile.perf

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ SHELL = $(SHELL_PATH)
396396
linux_uapi_dir := $(srctree)/tools/include/uapi/linux
397397
asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic
398398
arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/
399+
x86_arch_asm_uapi_dir := $(srctree)/tools/arch/x86/include/uapi/asm/
399400

400401
beauty_outdir := $(OUTPUT)trace/beauty/generated
401402
beauty_ioctl_outdir := $(beauty_outdir)/ioctl
@@ -409,6 +410,12 @@ _dummy := $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_ou
409410
$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl)
410411
$(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@
411412

413+
fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c
414+
fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh
415+
416+
$(fadvise_advice_array): $(linux_uapi_dir)/in.h $(fadvise_advice_tbl)
417+
$(Q)$(SHELL) '$(fadvise_advice_tbl)' $(linux_uapi_dir) > $@
418+
412419
pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c
413420
asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
414421
pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
@@ -490,6 +497,18 @@ prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh
490497
$(prctl_option_array): $(prctl_hdr_dir)/prctl.h $(prctl_option_tbl)
491498
$(Q)$(SHELL) '$(prctl_option_tbl)' $(prctl_hdr_dir) > $@
492499

500+
x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c
501+
x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh
502+
503+
$(x86_arch_prctl_code_array): $(x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl)
504+
$(Q)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(x86_arch_asm_uapi_dir) > $@
505+
506+
rename_flags_array := $(beauty_outdir)/rename_flags_array.c
507+
rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh
508+
509+
$(rename_flags_array): $(linux_uapi_dir)/fs.h $(rename_flags_tbl)
510+
$(Q)$(SHELL) '$(rename_flags_tbl)' $(linux_uapi_dir) > $@
511+
493512
arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c
494513
arch_errno_hdr_dir := $(srctree)/tools
495514
arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
@@ -592,6 +611,7 @@ __build-dir = $(subst $(OUTPUT),,$(dir $@))
592611
build-dir = $(if $(__build-dir),$(__build-dir),.)
593612

594613
prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \
614+
$(fadvise_advice_array) \
595615
$(pkey_alloc_access_rights_array) \
596616
$(sndrv_pcm_ioctl_array) \
597617
$(sndrv_ctl_ioctl_array) \
@@ -604,6 +624,8 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc
604624
$(mount_flags_array) \
605625
$(perf_ioctl_array) \
606626
$(prctl_option_array) \
627+
$(x86_arch_prctl_code_array) \
628+
$(rename_flags_array) \
607629
$(arch_errno_name_array)
608630

609631
$(OUTPUT)%.o: %.c prepare FORCE
@@ -647,7 +669,7 @@ $(LIBJVMTI_IN): FORCE
647669
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
648670

649671
$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
650-
$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
672+
$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
651673
endif
652674

653675
$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
@@ -887,6 +909,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
887909
$(OUTPUT)util/intel-pt-decoder/inat-tables.c \
888910
$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
889911
$(OUTPUT)pmu-events/pmu-events.c \
912+
$(OUTPUT)$(fadvise_advice_array) \
890913
$(OUTPUT)$(madvise_behavior_array) \
891914
$(OUTPUT)$(mmap_flags_array) \
892915
$(OUTPUT)$(mount_flags_array) \
@@ -900,6 +923,8 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
900923
$(OUTPUT)$(vhost_virtio_ioctl_array) \
901924
$(OUTPUT)$(perf_ioctl_array) \
902925
$(OUTPUT)$(prctl_option_array) \
926+
$(OUTPUT)$(x86_arch_prctl_code_array) \
927+
$(OUTPUT)$(rename_flags_array) \
903928
$(OUTPUT)$(arch_errno_name_array)
904929
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
905930

tools/perf/builtin-config.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ int cmd_config(int argc, const char **argv)
196196
pr_err("Error: takes no arguments\n");
197197
parse_options_usage(config_usage, config_options, "l", 1);
198198
} else {
199+
do_action_list:
199200
if (show_config(set) < 0) {
200201
pr_err("Nothing configured, "
201202
"please check your %s \n", config_filename);
@@ -204,10 +205,8 @@ int cmd_config(int argc, const char **argv)
204205
}
205206
break;
206207
default:
207-
if (!argc) {
208-
usage_with_options(config_usage, config_options);
209-
break;
210-
}
208+
if (!argc)
209+
goto do_action_list;
211210

212211
for (i = 0; argv[i]; i++) {
213212
char *var, *value;

tools/perf/builtin-stat.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ static int parse_metric_groups(const struct option *opt,
709709
return metricgroup__parse_groups(opt, str, &stat_config.metric_events);
710710
}
711711

712-
static const struct option stat_options[] = {
712+
static struct option stat_options[] = {
713713
OPT_BOOLEAN('T', "transaction", &transaction_run,
714714
"hardware transaction statistics"),
715715
OPT_CALLBACK('e', "event", &evsel_list, "event",
@@ -1599,6 +1599,12 @@ int cmd_stat(int argc, const char **argv)
15991599
return -ENOMEM;
16001600

16011601
parse_events__shrink_config_terms();
1602+
1603+
/* String-parsing callback-based options would segfault when negated */
1604+
set_option_flag(stat_options, 'e', "event", PARSE_OPT_NONEG);
1605+
set_option_flag(stat_options, 'M', "metrics", PARSE_OPT_NONEG);
1606+
set_option_flag(stat_options, 'G', "cgroup", PARSE_OPT_NONEG);
1607+
16021608
argc = parse_options_subcommand(argc, argv, stat_options, stat_subcommands,
16031609
(const char **) stat_usage,
16041610
PARSE_OPT_STOP_AT_NON_OPTION);

tools/perf/builtin-timechart.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
#include "util/data.h"
4444
#include "util/debug.h"
4545

46+
#ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE
47+
FILE *open_memstream(char **ptr, size_t *sizeloc);
48+
#endif
49+
4650
#define SUPPORT_OLD_POWER_EVENTS 1
4751
#define PWR_EVENT_EXIT -1
4852

0 commit comments

Comments
 (0)