Skip to content

Commit

Permalink
Merge tag 'perf-tools-2020-08-14' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/acme/linux

Pull more perf tools updates from Arnaldo Carvalho de Melo:
 "Fixes:
   - Fixes for 'perf bench numa'.

   - Always memset source before memcpy in 'perf bench mem'.

   - Quote CC and CXX for their arguments to fix build in environments
     using those variables to pass more than just the compiler names.

   - Fix module symbol processing, addressing regression detected via
     "perf test".

   - Allow multiple probes in record+script_probe_vfs_getname.sh 'perf
     test' entry.

  Improvements:
   - Add script to autogenerate socket family name id->string table from
     copy of kernel header, used so far in 'perf trace'.

   - 'perf ftrace' improvements to provide similar options for this
     utility so that one can go from 'perf record', 'perf trace', etc to
     'perf ftrace' just by changing the name of the subcommand.

   - Prefer new "sched:sched_waking" trace event when it exists in 'perf
     sched' post processing.

   - Update POWER9 metrics to utilize other metrics.

   - Fall back to querying debuginfod if debuginfo not found locally.

  Miscellaneous:
   - Sync various kvm headers with kernel sources"

* tag 'perf-tools-2020-08-14' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (40 commits)
  perf ftrace: Make option description initials all capital letters
  perf build-ids: Fall back to debuginfod query if debuginfo not found
  perf bench numa: Remove dead code in parse_nodes_opt()
  perf stat: Update POWER9 metrics to utilize other metrics
  perf ftrace: Add change log
  perf: ftrace: Add set_tracing_options() to set all trace options
  perf ftrace: Add option --tid to filter by thread id
  perf ftrace: Add option -D/--delay to delay tracing
  perf: ftrace: Allow set graph depth by '--graph-opts'
  perf ftrace: Add support for trace option tracing_thresh
  perf ftrace: Add option 'verbose' to show more info for graph tracer
  perf ftrace: Add support for tracing option 'irq-info'
  perf ftrace: Add support for trace option funcgraph-irqs
  perf ftrace: Add support for trace option sleep-time
  perf ftrace: Add support for tracing option 'func_stack_trace'
  perf tools: Add general function to parse sublevel options
  perf ftrace: Add option '--inherit' to trace children processes
  perf ftrace: Show trace column header
  perf ftrace: Add option '-m/--buffer-size' to set per-cpu buffer size
  perf ftrace: Factor out function write_tracing_file_int()
  ...
  • Loading branch information
Linus Torvalds committed Aug 15, 2020
2 parents 50f6c7d + 492e4ed commit 713eee8
Show file tree
Hide file tree
Showing 37 changed files with 1,253 additions and 247 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -13566,6 +13566,7 @@ F: arch/*/kernel/perf_event*.c
F: include/linux/perf_event.h
F: include/uapi/linux/perf_event.h
F: kernel/events/*
F: tools/lib/perf/
F: tools/perf/

PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS
Expand Down
7 changes: 5 additions & 2 deletions tools/arch/s390/include/uapi/asm/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,13 @@ struct kvm_guest_debug_arch {
#define KVM_SYNC_GSCB (1UL << 9)
#define KVM_SYNC_BPBC (1UL << 10)
#define KVM_SYNC_ETOKEN (1UL << 11)
#define KVM_SYNC_DIAG318 (1UL << 12)

#define KVM_SYNC_S390_VALID_FIELDS \
(KVM_SYNC_PREFIX | KVM_SYNC_GPRS | KVM_SYNC_ACRS | KVM_SYNC_CRS | \
KVM_SYNC_ARCH0 | KVM_SYNC_PFAULT | KVM_SYNC_VRS | KVM_SYNC_RICCB | \
KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN)
KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN | \
KVM_SYNC_DIAG318)

/* length and alignment of the sdnx as a power of two */
#define SDNXC 8
Expand Down Expand Up @@ -264,7 +266,8 @@ struct kvm_sync_regs {
__u8 reserved2 : 7;
__u8 padding1[51]; /* riccb needs to be 64byte aligned */
__u8 riccb[64]; /* runtime instrumentation controls block */
__u8 padding2[192]; /* sdnx needs to be 256byte aligned */
__u64 diag318; /* diagnose 0x318 info */
__u8 padding2[184]; /* sdnx needs to be 256byte aligned */
union {
__u8 sdnx[SDNXL]; /* state description annex */
struct {
Expand Down
5 changes: 3 additions & 2 deletions tools/build/Makefile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif

feature_check = $(eval $(feature_check_code))
define feature_check_code
feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC=$(CC) CXX=$(CXX) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
endef

feature_set = $(eval $(feature_set_code))
Expand Down Expand Up @@ -98,7 +98,8 @@ FEATURE_TESTS_EXTRA := \
llvm-version \
clang \
libbpf \
libpfm4
libpfm4 \
libdebuginfod

FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC)

Expand Down
4 changes: 4 additions & 0 deletions tools/build/feature/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ FILES= \
test-libelf-gelf_getnote.bin \
test-libelf-getshdrstrndx.bin \
test-libelf-mmap.bin \
test-libdebuginfod.bin \
test-libnuma.bin \
test-numa_num_possible_cpus.bin \
test-libperl.bin \
Expand Down Expand Up @@ -157,6 +158,9 @@ $(OUTPUT)test-libelf-gelf_getnote.bin:
$(OUTPUT)test-libelf-getshdrstrndx.bin:
$(BUILD) -lelf

$(OUTPUT)test-libdebuginfod.bin:
$(BUILD) -ldebuginfod

$(OUTPUT)test-libnuma.bin:
$(BUILD) -lnuma

Expand Down
8 changes: 8 additions & 0 deletions tools/build/feature/test-libdebuginfod.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include <elfutils/debuginfod.h>

int main(void)
{
debuginfod_client* c = debuginfod_begin();
return (long)c;
}
4 changes: 4 additions & 0 deletions tools/include/uapi/linux/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ struct kvm_run {
/* KVM_EXIT_FAIL_ENTRY */
struct {
__u64 hardware_entry_failure_reason;
__u32 cpu;
} fail_entry;
/* KVM_EXIT_EXCEPTION */
struct {
Expand Down Expand Up @@ -1031,6 +1032,9 @@ struct kvm_ppc_resize_hpt {
#define KVM_CAP_PPC_SECURE_GUEST 181
#define KVM_CAP_HALT_POLL 182
#define KVM_CAP_ASYNC_PF_INT 183
#define KVM_CAP_LAST_CPU 184
#define KVM_CAP_SMALLER_MAXPHYADDR 185
#define KVM_CAP_S390_DIAG318 186

#ifdef KVM_CAP_IRQ_ROUTING

Expand Down
2 changes: 2 additions & 0 deletions tools/include/uapi/linux/vhost.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@

/* Use message type V2 */
#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
/* IOTLB can accept batching hints */
#define VHOST_BACKEND_F_IOTLB_BATCH 0x2

#define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
Expand Down
14 changes: 8 additions & 6 deletions tools/lib/perf/Documentation/libperf-counting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ libperf-counting - counting interface

DESCRIPTION
-----------
The counting interface provides API to meassure and get count for specific perf events.
The counting interface provides API to measure and get count for specific perf events.

The following test tries to explain count on `counting.c` example.

It is by no means complete guide to counting, but shows libperf basic API for counting.

The `counting.c` comes with libbperf package and can be compiled and run like:
The `counting.c` comes with libperf package and can be compiled and run like:

[source,bash]
--
Expand All @@ -26,7 +26,8 @@ count 176242, enabled 176242, run 176242
It requires root access, because of the `PERF_COUNT_SW_CPU_CLOCK` event,
which is available only for root.

The `counting.c` example monitors two events on the current process and displays their count, in a nutshel it:
The `counting.c` example monitors two events on the current process and displays
their count, in a nutshell it:

* creates events
* adds them to the event list
Expand Down Expand Up @@ -152,7 +153,7 @@ Configure event list with the thread map and open events:
--

Both events are created as disabled (note the `disabled = 1` assignment above),
so we need to enable the whole list explicitely (both events).
so we need to enable the whole list explicitly (both events).

From this moment events are counting and we can do our workload.

Expand All @@ -167,7 +168,8 @@ When we are done we disable the events list.
79 perf_evlist__disable(evlist);
--

Now we need to get the counts from events, following code iterates throught the events list and read counts:
Now we need to get the counts from events, following code iterates through the
events list and read counts:

[source,c]
--
Expand All @@ -178,7 +180,7 @@ Now we need to get the counts from events, following code iterates throught the
85 }
--

And finaly cleanup.
And finally cleanup.

We close the whole events list (both events) and remove it together with the threads map:

Expand Down
13 changes: 7 additions & 6 deletions tools/lib/perf/Documentation/libperf-sampling.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ libperf-sampling - sampling interface

DESCRIPTION
-----------
The sampling interface provides API to meassure and get count for specific perf events.
The sampling interface provides API to measure and get count for specific perf events.

The following test tries to explain count on `sampling.c` example.

It is by no means complete guide to sampling, but shows libperf basic API for sampling.

The `sampling.c` comes with libbperf package and can be compiled and run like:
The `sampling.c` comes with libperf package and can be compiled and run like:

[source,bash]
--
Expand All @@ -33,7 +33,8 @@ cpu 0, pid 4465, tid 4470, ip 7f84fe0ebebf, period 176

It requires root access, because it uses hardware cycles event.

The `sampling.c` example profiles/samples all CPUs with hardware cycles, in a nutshel it:
The `sampling.c` example profiles/samples all CPUs with hardware cycles, in a
nutshell it:

- creates events
- adds them to the event list
Expand Down Expand Up @@ -90,7 +91,7 @@ Once the setup is complete we start by defining cycles event using the `struct p
36 };
--

Next step is to prepare cpus map.
Next step is to prepare CPUs map.

In this case we will monitor all the available CPUs:

Expand Down Expand Up @@ -152,7 +153,7 @@ Once the events list is open, we can create memory maps AKA perf ring buffers:
--

The event is created as disabled (note the `disabled = 1` assignment above),
so we need to enable the events list explicitely.
so we need to enable the events list explicitly.

From this moment the cycles event is sampling.

Expand Down Expand Up @@ -212,7 +213,7 @@ Each sample needs to get parsed:
106 cpu, pid, tid, ip, period);
--

And finaly cleanup.
And finally cleanup.

We close the whole events list (both events) and remove it together with the threads map:

Expand Down
4 changes: 2 additions & 2 deletions tools/lib/perf/Documentation/libperf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SYNOPSIS
void libperf_init(libperf_print_fn_t fn);
--

*API to handle cpu maps:*
*API to handle CPU maps:*

[source,c]
--
Expand Down Expand Up @@ -217,7 +217,7 @@ Following objects are key to the libperf interface:

[horizontal]

struct perf_cpu_map:: Provides a cpu list abstraction.
struct perf_cpu_map:: Provides a CPU list abstraction.

struct perf_thread_map:: Provides a thread list abstraction.

Expand Down
5 changes: 3 additions & 2 deletions tools/perf/Documentation/perf-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,9 @@ trace.*::

ftrace.*::
ftrace.tracer::
Can be used to select the default tracer. Possible values are
'function' and 'function_graph'.
Can be used to select the default tracer when neither -G nor
-F option is not specified. Possible values are 'function' and
'function_graph'.

llvm.*::
llvm.clang-path::
Expand Down
75 changes: 53 additions & 22 deletions tools/perf/Documentation/perf-ftrace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,28 @@ OPTIONS

-t::
--tracer=::
Tracer to use: function_graph or function.
Tracer to use when neither -G nor -F option is not
specified: function_graph or function.

-v::
--verbose=::
Verbosity level.

-F::
--funcs::
List all available functions to trace.

-p::
--pid=::
Trace on existing process id (comma separated list).

--tid=::
Trace on existing thread id (comma separated list).

-D::
--delay::
Time (ms) to wait before starting tracing after program start.

-a::
--all-cpus::
Force system-wide collection. Scripts run without a <command>
Expand All @@ -48,39 +60,58 @@ OPTIONS
Ranges of CPUs are specified with -: 0-2.
Default is to trace on all online CPUs.

-m::
--buffer-size::
Set the size of per-cpu tracing buffer, <size> is expected to
be a number with appended unit character - B/K/M/G.

--inherit::
Trace children processes spawned by our target.

-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.
Select function tracer and set function filter on the given
function (or a glob pattern). 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.
Select function tracer and 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.

--func-opts::
List of options allowed to set:
call-graph - Display kernel stack trace for function tracer.
irq-info - Display irq context info for function tracer.

-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.
Select function_graph tracer and set graph filter on the given
function (or a glob pattern). This is useful to trace 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.
Select function_graph tracer and 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
--graph-opts::
List of options allowed to set:
nosleep-time - Measure on-CPU time only for function_graph tracer.
noirqs - Ignore functions that happen inside interrupt.
verbose - Show process names, PIDs, timestamps, etc.
thresh=<n> - Setup trace duration threshold in microseconds.
depth=<n> - Set max depth for function graph tracer to follow.

SEE ALSO
--------
Expand Down
8 changes: 8 additions & 0 deletions tools/perf/Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@ ifndef NO_LIBELF
CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
endif

ifndef NO_LIBDEBUGINFOD
$(call feature_check,libdebuginfod)
ifeq ($(feature-libdebuginfod), 1)
CFLAGS += -DHAVE_DEBUGINFOD_SUPPORT
EXTLIBS += -ldebuginfod
endif
endif

ifndef NO_DWARF
ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
Expand Down
Loading

0 comments on commit 713eee8

Please sign in to comment.