License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2011-01-12 06:56:53 +08:00
|
|
|
#ifndef __PERF_EVLIST_H
|
|
|
|
#define __PERF_EVLIST_H 1
|
|
|
|
|
2017-06-16 22:39:15 +08:00
|
|
|
#include <linux/compiler.h>
|
2017-04-17 22:39:06 +08:00
|
|
|
#include <linux/kernel.h>
|
2017-02-21 23:35:01 +08:00
|
|
|
#include <linux/refcount.h>
|
2011-01-12 06:56:53 +08:00
|
|
|
#include <linux/list.h>
|
2014-09-04 05:02:59 +08:00
|
|
|
#include <api/fd/array.h>
|
2019-07-21 19:24:23 +08:00
|
|
|
#include <internal/evlist.h>
|
2019-09-03 16:39:52 +08:00
|
|
|
#include <internal/evsel.h>
|
2019-08-30 22:44:32 +08:00
|
|
|
#include "events_stats.h"
|
2012-08-15 03:42:15 +08:00
|
|
|
#include "evsel.h"
|
2019-09-23 23:20:38 +08:00
|
|
|
#include <pthread.h>
|
2017-04-20 02:49:18 +08:00
|
|
|
#include <signal.h>
|
2011-11-09 18:47:15 +08:00
|
|
|
#include <unistd.h>
|
2011-01-12 06:56:53 +08:00
|
|
|
|
2011-01-12 08:30:02 +08:00
|
|
|
struct pollfd;
|
2011-01-30 20:46:46 +08:00
|
|
|
struct thread_map;
|
2019-07-21 19:23:49 +08:00
|
|
|
struct perf_cpu_map;
|
2013-12-20 01:43:45 +08:00
|
|
|
struct record_opts;
|
2011-01-12 08:30:02 +08:00
|
|
|
|
2019-09-23 23:20:38 +08:00
|
|
|
/*
|
|
|
|
* State machine of bkw_mmap_state:
|
|
|
|
*
|
|
|
|
* .________________(forbid)_____________.
|
|
|
|
* | V
|
|
|
|
* NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
|
|
|
|
* ^ ^ | ^ |
|
|
|
|
* | |__(forbid)____/ |___(forbid)___/|
|
|
|
|
* | |
|
|
|
|
* \_________________(3)_______________/
|
|
|
|
*
|
|
|
|
* NOTREADY : Backward ring buffers are not ready
|
|
|
|
* RUNNING : Backward ring buffers are recording
|
|
|
|
* DATA_PENDING : We are required to collect data from backward ring buffers
|
|
|
|
* EMPTY : We have collected data from backward ring buffers.
|
|
|
|
*
|
|
|
|
* (0): Setup backward ring buffer
|
|
|
|
* (1): Pause ring buffers for reading
|
|
|
|
* (2): Read from ring buffers
|
|
|
|
* (3): Resume ring buffers for recording
|
|
|
|
*/
|
|
|
|
enum bkw_mmap_state {
|
|
|
|
BKW_MMAP_NOTREADY,
|
|
|
|
BKW_MMAP_RUNNING,
|
|
|
|
BKW_MMAP_DATA_PENDING,
|
|
|
|
BKW_MMAP_EMPTY,
|
|
|
|
};
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
struct evlist {
|
2019-07-21 19:24:23 +08:00
|
|
|
struct perf_evlist core;
|
2015-06-18 03:40:26 +08:00
|
|
|
bool enabled;
|
2013-08-27 16:23:09 +08:00
|
|
|
int id_pos;
|
|
|
|
int is_pos;
|
|
|
|
u64 combined_sample_type;
|
2016-07-14 16:34:42 +08:00
|
|
|
enum bkw_mmap_state bkw_mmap_state;
|
2011-11-09 18:47:15 +08:00
|
|
|
struct {
|
|
|
|
int cork_fd;
|
|
|
|
pid_t pid;
|
|
|
|
} workload;
|
2019-07-28 02:30:53 +08:00
|
|
|
struct mmap *mmap;
|
|
|
|
struct mmap *overwrite_mmap;
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel *selected;
|
2015-02-15 01:50:11 +08:00
|
|
|
struct events_stats stats;
|
2015-08-28 17:48:05 +08:00
|
|
|
struct perf_env *env;
|
perf stat: Support --cputype option for hybrid events
In previous patch, we have supported the syntax which enables
the event on a specified pmu, such as:
cpu_core/<event>/
cpu_atom/<event>/
While this syntax is not very easy for applying on a set of
events or applying on a group. In following example, we have to
explicitly assign the pmu prefix.
# ./perf stat -e '{cpu_core/cycles/,cpu_core/instructions/}' -- sleep 1
Performance counter stats for 'sleep 1':
1,158,545 cpu_core/cycles/
1,003,113 cpu_core/instructions/
1.002428712 seconds time elapsed
A much easier way is:
# ./perf stat --cputype core -e '{cycles,instructions}' -- sleep 1
Performance counter stats for 'sleep 1':
1,101,071 cpu_core/cycles/
939,892 cpu_core/instructions/
1.002363142 seconds time elapsed
For this example, the '--cputype' enables the events from specified
pmu (cpu_core).
If '--cputype' conflicts with pmu prefix, '--cputype' is ignored.
# ./perf stat --cputype core -e cycles,cpu_atom/instructions/ -a -- sleep 1
Performance counter stats for 'system wide':
21,003,407 cpu_core/cycles/
367,886 cpu_atom/instructions/
1.002203520 seconds time elapsed
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210909062215.10278-1-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-09-09 14:22:15 +08:00
|
|
|
const char *hybrid_pmu_name;
|
2019-07-21 19:23:52 +08:00
|
|
|
void (*trace_event_sample_raw)(struct evlist *evlist,
|
2019-01-17 21:37:17 +08:00
|
|
|
union perf_event *event,
|
|
|
|
struct perf_sample *sample);
|
perf header: Add infrastructure to record first and last sample time
perf report/script/... have a --time option to limit the time range of
output. That's very useful to slice large traces, e.g. when processing
the output of perf script for some analysis.
But right now --time only supports absolute time. Also there is no fast
way to get the start/end times of a given trace except for looking at
it. This makes it hard to e.g. only decode the first half of the trace,
which is useful for parallelization of scripts
Another problem is that perf records are variable size and there is no
synchronization mechanism. So the only way to find the last sample
reliably would be to walk all samples. But we want to avoid that in perf
report/... because it is already quite expensive. That is why storing
the first sample time and last sample time in perf record is better.
This patch creates a new header feature type HEADER_SAMPLE_TIME and
related ops. Save the first sample time and the last sample time to the
feature section in perf file header. That will be done when, for
instance, processing build-ids, where we already have to process all
samples to create the build-id table, take advantage of that to further
amortize that processing by storing HEADER_SAMPLE_TIME to make 'perf
report/script' faster when using --time.
Committer testing:
After this patch is applied the header is written with zeroes, we need
the next patch, for "perf record" to actually write the timestamps:
# perf report -D | grep PERF_RECORD_SAMPLE\(
22501155244406 0x44f0 [0x28]: PERF_RECORD_SAMPLE(IP, 0x4001): 25016/25016: 0xffffffffa21be8c5 period: 1 addr: 0
<SNIP>
22501155793625 0x4a30 [0x28]: PERF_RECORD_SAMPLE(IP, 0x4001): 25016/25016: 0xffffffffa21ffd50 period: 2828043 addr: 0
# perf report --header | grep "time of "
# time of first sample : 0.000000
# time of last sample : 0.000000
#
Changelog:
v7: 1. Rebase to latest perf/core branch.
2. Add following clarification in patch description according to
Arnaldo's suggestion.
"That will be done when, for instance, processing build-ids,
where we already have to process all samples to create the
build-id table, take advantage of that to further amortize
that processing by storing HEADER_SAMPLE_TIME to make
'perf report/script' faster when using --time."
v4: Use perf script time style for timestamp printing. Also add with
the printing of sample duration.
v3: Remove the definitions of first_sample_time/last_sample_time from
perf_session. Just define them in perf_evlist
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1512738826-2628-2-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-12-08 21:13:41 +08:00
|
|
|
u64 first_sample_time;
|
|
|
|
u64 last_sample_time;
|
2019-03-12 13:30:50 +08:00
|
|
|
struct {
|
|
|
|
pthread_t th;
|
|
|
|
volatile int done;
|
|
|
|
} thread;
|
2020-07-17 15:00:47 +08:00
|
|
|
struct {
|
|
|
|
int fd; /* control file descriptor */
|
|
|
|
int ack; /* ack file descriptor for control commands */
|
|
|
|
int pos; /* index at evlist core object to check signals */
|
|
|
|
} ctl_fd;
|
2011-01-12 06:56:53 +08:00
|
|
|
};
|
|
|
|
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel_str_handler {
|
perf tools: Save some loops using perf_evlist__id2evsel
Since we already ask for PERF_SAMPLE_ID and use it to quickly find the
associated evsel, add handler func + data to struct perf_evsel to avoid
using chains of if(strcmp(event_name)) and also to avoid all the linear
list searches via trace_event_find.
To demonstrate the technique convert 'perf sched' to it:
# perf sched record sleep 5m
And then:
Performance counter stats for '/tmp/oldperf sched lat':
646.929438 task-clock # 0.999 CPUs utilized
9 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
20,901 page-faults # 0.032 M/sec
1,290,144,450 cycles # 1.994 GHz
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
1,606,158,439 instructions # 1.24 insns per cycle
339,088,395 branches # 524.151 M/sec
4,550,735 branch-misses # 1.34% of all branches
0.647524759 seconds time elapsed
Versus:
Performance counter stats for 'perf sched lat':
473.564691 task-clock # 0.999 CPUs utilized
9 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
20,903 page-faults # 0.044 M/sec
944,367,984 cycles # 1.994 GHz
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
1,442,385,571 instructions # 1.53 insns per cycle
308,383,106 branches # 651.195 M/sec
4,481,784 branch-misses # 1.45% of all branches
0.474215751 seconds time elapsed
[root@emilia ~]#
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-1kbzpl74lwi6lavpqke2u2p3@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2011-11-29 03:57:40 +08:00
|
|
|
const char *name;
|
|
|
|
void *handler;
|
|
|
|
};
|
|
|
|
|
2019-07-21 19:23:55 +08:00
|
|
|
struct evlist *evlist__new(void);
|
2020-12-01 02:04:05 +08:00
|
|
|
struct evlist *evlist__new_default(void);
|
|
|
|
struct evlist *evlist__new_dummy(void);
|
2019-07-21 19:23:54 +08:00
|
|
|
void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
|
|
|
|
struct perf_thread_map *threads);
|
2019-09-02 20:34:52 +08:00
|
|
|
void evlist__exit(struct evlist *evlist);
|
2019-07-21 19:23:56 +08:00
|
|
|
void evlist__delete(struct evlist *evlist);
|
2011-01-12 06:56:53 +08:00
|
|
|
|
2019-07-21 19:23:59 +08:00
|
|
|
void evlist__add(struct evlist *evlist, struct evsel *entry);
|
2019-07-21 19:24:00 +08:00
|
|
|
void evlist__remove(struct evlist *evlist, struct evsel *evsel);
|
2017-07-04 00:10:20 +08:00
|
|
|
|
2020-06-17 20:16:20 +08:00
|
|
|
int __evlist__add_default(struct evlist *evlist, bool precise);
|
2017-07-04 00:10:20 +08:00
|
|
|
|
2020-06-17 20:16:20 +08:00
|
|
|
static inline int evlist__add_default(struct evlist *evlist)
|
2017-07-04 00:10:20 +08:00
|
|
|
{
|
2020-06-17 20:16:20 +08:00
|
|
|
return __evlist__add_default(evlist, true);
|
2017-07-04 00:10:20 +08:00
|
|
|
}
|
|
|
|
|
2020-06-17 20:16:20 +08:00
|
|
|
int __evlist__add_default_attrs(struct evlist *evlist,
|
perf stat: Initialize default events wrt exclude_{guest,host}
When no event is specified the tools use perf_evlist__add_default(), that will
call event_attr_init to initialize the KVM exclusion bits.
When the change was made to the tools so that by default guest samples would be
excluded, the changes were made just to the parsing routines and to
perf_evlist__add_default(), not to perf_evlist__add_attrs, that is used so far
just by perf stat to add multiple events, according to the level of detail
specified.
Recently the tools were changed to reconstruct the event name from all the
details in perf_event_attr, not just from .type and .config, but taking into
account all the feature bits (.exclude_{guest,host,user,kernel,etc},
.precise_ip, etc).
That is when we noticed that the default for perf stat wasn't the one for the
rest of the tools, i.e. the .exclude_guest bit wasn't being set.
I.e. the default, that doesn't call event_attr_init was showing the :HG
modifier:
$ perf stat usleep 1
Performance counter stats for 'usleep 1':
0.942119 task-clock # 0.454 CPUs utilized
1 context-switches # 0.001 M/sec
0 CPU-migrations # 0.000 K/sec
126 page-faults # 0.134 M/sec
693,193 cycles:HG # 0.736 GHz [40.11%]
407,461 stalled-cycles-frontend:HG # 58.78% frontend cycles idle [72.29%]
365,403 stalled-cycles-backend:HG # 52.71% backend cycles idle
465,982 instructions:HG # 0.67 insns per cycle
# 0.87 stalled cycles per insn
89,760 branches:HG # 95.275 M/sec
6,178 branch-misses:HG # 6.88% of all branches
0.002077228 seconds time elapsed
While if one explicitely specifies the same events, which will make the parsing code
to be called and thus event_attr_init is called:
$ perf stat -e task-clock,context-switches,migrations,page-faults,cycles,stalled-cycles-frontend,stalled-cycles-backend,instructions,branches,branch-misses usleep 1
Performance counter stats for 'usleep 1':
1.040349 task-clock # 0.500 CPUs utilized
2 context-switches # 0.002 M/sec
0 CPU-migrations # 0.000 K/sec
127 page-faults # 0.122 M/sec
587,966 cycles # 0.565 GHz [13.18%]
459,167 stalled-cycles-frontend # 78.09% frontend cycles idle
390,249 stalled-cycles-backend # 66.37% backend cycles idle
504,006 instructions # 0.86 insns per cycle
# 0.91 stalled cycles per insn
96,455 branches # 92.714 M/sec
6,522 branch-misses # 6.76% of all branches [96.12%]
0.002078681 seconds time elapsed
Fix it by introducing a perf_evlist__add_default_attrs method that will call
evlist_attr_init in all the perf_event_attr entries before adding the events.
Reported-by: Ingo Molnar <mingo@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-4eysr236r0pgiyum9epwxw7s@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-05-31 00:53:54 +08:00
|
|
|
struct perf_event_attr *attrs, size_t nr_attrs);
|
2012-10-03 22:50:55 +08:00
|
|
|
|
2020-06-17 20:16:20 +08:00
|
|
|
#define evlist__add_default_attrs(evlist, array) \
|
|
|
|
__evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
|
2011-01-12 06:56:53 +08:00
|
|
|
|
perf stat: Add Topdown metrics events as default events
The Topdown Microarchitecture Analysis (TMA) Method is a structured
analysis methodology to identify critical performance bottlenecks in
out-of-order processors. From the Ice Lake and later platforms, the
Topdown information can be retrieved from the dedicated "metrics"
register, which isn't impacted by other events. Also, the Topdown
metrics support both per thread/process and per core measuring. Adding
Topdown metrics events as default events can enrich the default
measuring information, and would not cost any extra multiplexing.
Introduce arch_evlist__add_default_attrs() to allow architecture
specific default events. Add the Topdown metrics events in the X86
specific arch_evlist__add_default_attrs(). Other architectures can add
their own default events later separately.
With the patch:
$ perf stat sleep 1
Performance counter stats for 'sleep 1':
0.82 msec task-clock:u # 0.001 CPUs utilized
0 context-switches:u # 0.000 K/sec
0 cpu-migrations:u # 0.000 K/sec
61 page-faults:u # 0.074 M/sec
319,941 cycles:u # 0.388 GHz
242,802 instructions:u # 0.76 insn per cycle
54,380 branches:u # 66.028 M/sec
4,043 branch-misses:u # 7.43% of all branches
1,585,555 slots:u # 1925.189 M/sec
238,941 topdown-retiring:u # 15.0% retiring
410,378 topdown-bad-spec:u # 25.8% bad speculation
634,222 topdown-fe-bound:u # 39.9% frontend bound
304,675 topdown-be-bound:u # 19.2% backend bound
1.001791625 seconds time elapsed
0.000000000 seconds user
0.001572000 seconds sys
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lore.kernel.org/lkml/20210121133752.118327-1-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-01-21 21:37:52 +08:00
|
|
|
int arch_evlist__add_default_attrs(struct evlist *evlist);
|
perf parse-events: Architecture specific leader override
Currently topdown events must appear after a slots event:
$ perf stat -e '{slots,topdown-fe-bound}' /bin/true
Performance counter stats for '/bin/true':
3,183,090 slots
986,133 topdown-fe-bound
Reversing the events yields:
$ perf stat -e '{topdown-fe-bound,slots}' /bin/true
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (topdown-fe-bound).
For metrics the order of events is determined by iterating over a
hashmap, and so slots isn't guaranteed to be first which can yield this
error.
Change the set_leader in parse-events, called when a group is closed, so
that rather than always making the first event the leader, if the slots
event exists then it is made the leader. It is then moved to the head of
the evlist otherwise it won't be opened in the correct order.
The result is:
$ perf stat -e '{topdown-fe-bound,slots}' /bin/true
Performance counter stats for '/bin/true':
3,274,795 slots
1,001,702 topdown-fe-bound
A problem with this approach is the slots event is identified by name,
names can be overwritten like 'cpu/slots,name=foo/' and this causes the
leader change to fail.
The change also modifies and fixes mixed groups like, with the change:
$ perf stat -e '{instructions,slots,topdown-fe-bound}' -a -- sleep 2
Performance counter stats for 'system wide':
5574985410 slots
971981616 instructions
1348461887 topdown-fe-bound
2.001263120 seconds time elapsed
Without the change:
$ perf stat -e '{instructions,slots,topdown-fe-bound}' -a -- sleep 2
Performance counter stats for 'system wide':
<not counted> instructions
<not counted> slots
<not supported> topdown-fe-bound
2.006247990 seconds time elapsed
Something that may be undesirable here is that the events are reordered
in the output.
Reviewed-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vineet Singh <vineet.singh@intel.com>
Link: http://lore.kernel.org/lkml/20211130174945.247604-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-12-01 01:49:45 +08:00
|
|
|
struct evsel *arch_evlist__leader(struct list_head *list);
|
perf stat: Add Topdown metrics events as default events
The Topdown Microarchitecture Analysis (TMA) Method is a structured
analysis methodology to identify critical performance bottlenecks in
out-of-order processors. From the Ice Lake and later platforms, the
Topdown information can be retrieved from the dedicated "metrics"
register, which isn't impacted by other events. Also, the Topdown
metrics support both per thread/process and per core measuring. Adding
Topdown metrics events as default events can enrich the default
measuring information, and would not cost any extra multiplexing.
Introduce arch_evlist__add_default_attrs() to allow architecture
specific default events. Add the Topdown metrics events in the X86
specific arch_evlist__add_default_attrs(). Other architectures can add
their own default events later separately.
With the patch:
$ perf stat sleep 1
Performance counter stats for 'sleep 1':
0.82 msec task-clock:u # 0.001 CPUs utilized
0 context-switches:u # 0.000 K/sec
0 cpu-migrations:u # 0.000 K/sec
61 page-faults:u # 0.074 M/sec
319,941 cycles:u # 0.388 GHz
242,802 instructions:u # 0.76 insn per cycle
54,380 branches:u # 66.028 M/sec
4,043 branch-misses:u # 7.43% of all branches
1,585,555 slots:u # 1925.189 M/sec
238,941 topdown-retiring:u # 15.0% retiring
410,378 topdown-bad-spec:u # 25.8% bad speculation
634,222 topdown-fe-bound:u # 39.9% frontend bound
304,675 topdown-be-bound:u # 19.2% backend bound
1.001791625 seconds time elapsed
0.000000000 seconds user
0.001572000 seconds sys
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lore.kernel.org/lkml/20210121133752.118327-1-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-01-21 21:37:52 +08:00
|
|
|
|
2020-06-17 20:16:20 +08:00
|
|
|
int evlist__add_dummy(struct evlist *evlist);
|
2022-05-24 15:54:26 +08:00
|
|
|
struct evsel *evlist__add_aux_dummy(struct evlist *evlist, bool system_wide);
|
|
|
|
static inline struct evsel *evlist__add_dummy_on_all_cpus(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
return evlist__add_aux_dummy(evlist, true);
|
|
|
|
}
|
2016-01-08 00:14:56 +08:00
|
|
|
|
2020-11-30 20:40:10 +08:00
|
|
|
int evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr,
|
|
|
|
evsel__sb_cb_t cb, void *data);
|
2020-04-30 02:42:16 +08:00
|
|
|
void evlist__set_cb(struct evlist *evlist, evsel__sb_cb_t cb, void *data);
|
2020-11-30 20:40:10 +08:00
|
|
|
int evlist__start_sb_thread(struct evlist *evlist, struct target *target);
|
|
|
|
void evlist__stop_sb_thread(struct evlist *evlist);
|
2019-03-12 13:30:50 +08:00
|
|
|
|
2020-06-17 20:16:20 +08:00
|
|
|
int evlist__add_newtp(struct evlist *evlist, const char *sys, const char *name, void *handler);
|
2012-10-03 22:40:22 +08:00
|
|
|
|
2019-10-01 22:14:26 +08:00
|
|
|
int __evlist__set_tracepoints_handlers(struct evlist *evlist,
|
|
|
|
const struct evsel_str_handler *assocs,
|
|
|
|
size_t nr_assocs);
|
|
|
|
|
|
|
|
#define evlist__set_tracepoints_handlers(evlist, array) \
|
|
|
|
__evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array))
|
|
|
|
|
2020-11-30 20:38:02 +08:00
|
|
|
int evlist__set_tp_filter(struct evlist *evlist, const char *filter);
|
|
|
|
int evlist__set_tp_filter_pid(struct evlist *evlist, pid_t pid);
|
|
|
|
int evlist__set_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
|
2012-09-27 02:07:39 +08:00
|
|
|
|
2020-11-30 20:38:02 +08:00
|
|
|
int evlist__append_tp_filter(struct evlist *evlist, const char *filter);
|
2019-10-08 03:52:17 +08:00
|
|
|
|
2020-11-30 20:38:02 +08:00
|
|
|
int evlist__append_tp_filter_pid(struct evlist *evlist, pid_t pid);
|
|
|
|
int evlist__append_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
|
2019-10-08 04:00:34 +08:00
|
|
|
|
2020-11-30 20:48:07 +08:00
|
|
|
struct evsel *evlist__find_tracepoint_by_id(struct evlist *evlist, int id);
|
|
|
|
struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const char *name);
|
2013-08-29 12:29:51 +08:00
|
|
|
|
2019-08-16 22:00:45 +08:00
|
|
|
int evlist__add_pollfd(struct evlist *evlist, int fd);
|
|
|
|
int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask);
|
2014-08-13 10:04:11 +08:00
|
|
|
|
2021-02-05 14:50:01 +08:00
|
|
|
#ifdef HAVE_EVENTFD_SUPPORT
|
|
|
|
int evlist__add_wakeup_eventfd(struct evlist *evlist, int fd);
|
|
|
|
#endif
|
|
|
|
|
2019-09-01 04:48:33 +08:00
|
|
|
int evlist__poll(struct evlist *evlist, int timeout);
|
2014-08-19 04:25:59 +08:00
|
|
|
|
2020-12-01 01:17:57 +08:00
|
|
|
struct evsel *evlist__id2evsel(struct evlist *evlist, u64 id);
|
|
|
|
struct evsel *evlist__id2evsel_strict(struct evlist *evlist, u64 id);
|
2011-01-13 08:39:13 +08:00
|
|
|
|
2020-12-01 01:17:57 +08:00
|
|
|
struct perf_sample_id *evlist__id2sid(struct evlist *evlist, u64 id);
|
2012-10-11 20:10:35 +08:00
|
|
|
|
2020-11-30 20:33:55 +08:00
|
|
|
void evlist__toggle_bkw_mmap(struct evlist *evlist, enum bkw_mmap_state state);
|
2016-07-14 16:34:42 +08:00
|
|
|
|
2019-07-28 18:45:35 +08:00
|
|
|
void evlist__mmap_consume(struct evlist *evlist, int idx);
|
2013-10-24 15:43:33 +08:00
|
|
|
|
2019-07-21 19:24:06 +08:00
|
|
|
int evlist__open(struct evlist *evlist);
|
2019-07-21 19:24:07 +08:00
|
|
|
void evlist__close(struct evlist *evlist);
|
2011-10-25 20:42:19 +08:00
|
|
|
|
2016-04-12 05:15:29 +08:00
|
|
|
struct callchain_param;
|
|
|
|
|
2020-12-01 01:44:40 +08:00
|
|
|
void evlist__set_id_pos(struct evlist *evlist);
|
2020-12-01 02:07:49 +08:00
|
|
|
void evlist__config(struct evlist *evlist, struct record_opts *opts, struct callchain_param *callchain);
|
2013-12-20 01:43:45 +08:00
|
|
|
int record_opts__config(struct record_opts *opts);
|
2011-11-09 00:41:57 +08:00
|
|
|
|
2020-11-30 20:26:54 +08:00
|
|
|
int evlist__prepare_workload(struct evlist *evlist, struct target *target,
|
|
|
|
const char *argv[], bool pipe_output,
|
|
|
|
void (*exec_error)(int signo, siginfo_t *info, void *ucontext));
|
|
|
|
int evlist__start_workload(struct evlist *evlist);
|
2011-11-09 18:47:15 +08:00
|
|
|
|
2014-10-17 23:16:00 +08:00
|
|
|
struct option;
|
|
|
|
|
2020-12-01 02:09:45 +08:00
|
|
|
int __evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str);
|
|
|
|
int evlist__parse_mmap_pages(const struct option *opt, const char *str, int unset);
|
2013-09-01 18:36:12 +08:00
|
|
|
|
2016-04-16 04:46:31 +08:00
|
|
|
unsigned long perf_event_mlock_kb_in_pages(void);
|
|
|
|
|
2019-07-28 18:45:35 +08:00
|
|
|
int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
|
2017-12-03 10:00:38 +08:00
|
|
|
unsigned int auxtrace_pages,
|
perf record: Implement --mmap-flush=<number> option
Implement a --mmap-flush option that specifies minimal number of bytes
that is extracted from mmaped kernel buffer to store into a trace. The
default option value is 1 byte what means every time trace writing
thread finds some new data in the mmaped buffer the data is extracted,
possibly compressed and written to a trace.
$ tools/perf/perf record --mmap-flush 1024 -e cycles -- matrix.gcc
$ tools/perf/perf record --aio --mmap-flush 1K -e cycles -- matrix.gcc
The option is independent from -z setting, doesn't vary with compression
level and can serve two purposes.
The first purpose is to increase the compression ratio of a trace data.
Larger data chunks are compressed more effectively so the implemented
option allows specifying data chunk size to compress. Also at some cases
executing more write syscalls with smaller data size can take longer
than executing less write syscalls with bigger data size due to syscall
overhead so extracting bigger data chunks specified by the option value
could additionally decrease runtime overhead.
The second purpose is to avoid self monitoring live-lock issue in system
wide (-a) profiling mode. Profiling in system wide mode with compression
(-a -z) can additionally induce data into the kernel buffers along with
the data from monitored processes. If performance data rate and volume
from the monitored processes is high then trace streaming and
compression activity in the tool is also high. High tool process
activity can lead to subtle live-lock effect when compression of single
new byte from some of mmaped kernel buffer leads to generation of the
next single byte at some mmaped buffer. So perf tool process ends up in
endless self monitoring.
Implemented synch parameter is the mean to force data move independently
from the specified flush threshold value. Despite the provided flush
value the tool needs capability to unconditionally drain memory buffers,
at least in the end of the collection.
Committer testing:
Running with the default value, i.e. as soon as there is something to
read go on consuming, we first write the synthesized events, small
chunks of about 128 bytes:
# perf trace -m 2048 --call-graph dwarf -e write -- perf record
<SNIP>
101.142 ( 0.004 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x210db60, count: 120) = 120
__libc_write (/usr/lib64/libpthread-2.28.so)
ion (/home/acme/bin/perf)
record__write (inlined)
process_synthesized_event (/home/acme/bin/perf)
perf_tool__process_synth_event (inlined)
perf_event__synthesize_mmap_events (/home/acme/bin/perf)
Then we move to reading the mmap buffers consuming the events put there
by the kernel perf infrastructure:
107.561 ( 0.005 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x7f1befc02000, count: 336) = 336
__libc_write (/usr/lib64/libpthread-2.28.so)
ion (/home/acme/bin/perf)
record__write (inlined)
record__pushfn (/home/acme/bin/perf)
perf_mmap__push (/home/acme/bin/perf)
record__mmap_read_evlist (inlined)
record__mmap_read_all (inlined)
__cmd_record (inlined)
cmd_record (/home/acme/bin/perf)
12919.953 ( 0.136 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x7f1befc83150, count: 184984) = 184984
<SNIP same backtrace as in the 107.561 timestamp>
12920.094 ( 0.155 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x7f1befc02150, count: 261816) = 261816
<SNIP same backtrace as in the 107.561 timestamp>
12920.253 ( 0.093 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x7f1befb81120, count: 170832) = 170832
<SNIP same backtrace as in the 107.561 timestamp>
If we limit it to write only when more than 16MB are available for
reading, it throttles that to a quarter of the --mmap-pages set for
'perf record', which by default get to 528384 bytes, found out using
'record -v':
mmap flush: 132096
mmap size 528384B
With that in place all the writes coming from
record__mmap_read_evlist(), i.e. from the mmap buffers setup by the
kernel perf infrastructure were at least 132096 bytes long.
Trying with a bigger mmap size:
perf trace -e write perf record -v -m 2048 --mmap-flush 16M
74982.928 ( 2.471 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff94a6cc000, count: 3580888) = 3580888
74985.406 ( 2.353 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff949ecb000, count: 3453256) = 3453256
74987.764 ( 2.629 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff9496ca000, count: 3859232) = 3859232
74990.399 ( 2.341 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff948ec9000, count: 3769032) = 3769032
74992.744 ( 2.064 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff9486c8000, count: 3310520) = 3310520
74994.814 ( 2.619 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff947ec7000, count: 4194688) = 4194688
74997.439 ( 2.787 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff9476c6000, count: 4029760) = 4029760
Was again limited to a quarter of the mmap size:
mmap flush: 2098176
mmap size 8392704B
A warning about that would be good to have but can be added later,
something like:
"max flush is a quarter of the mmap size, if wanting to bump the mmap
flush further, bump the mmap size as well using -m/--mmap-pages"
Also rename the 'sync' parameters to 'synch' to keep tools/perf building
with older glibcs:
cc1: warnings being treated as errors
builtin-record.c: In function 'record__mmap_read_evlist':
builtin-record.c:775: warning: declaration of 'sync' shadows a global declaration
/usr/include/unistd.h:933: warning: shadowed declaration is here
builtin-record.c: In function 'record__mmap_read_all':
builtin-record.c:856: warning: declaration of 'sync' shadows a global declaration
/usr/include/unistd.h:933: warning: shadowed declaration is here
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/f6600d72-ecfa-2eb7-7e51-f6954547d500@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-03-19 01:40:26 +08:00
|
|
|
bool auxtrace_overwrite, int nr_cblocks,
|
2019-03-19 01:42:19 +08:00
|
|
|
int affinity, int flush, int comp_level);
|
2019-07-28 18:45:35 +08:00
|
|
|
int evlist__mmap(struct evlist *evlist, unsigned int pages);
|
2019-08-16 22:19:55 +08:00
|
|
|
void evlist__munmap(struct evlist *evlist);
|
2011-01-30 21:59:43 +08:00
|
|
|
|
2019-07-28 18:45:35 +08:00
|
|
|
size_t evlist__mmap_size(unsigned long pages);
|
2017-01-09 17:51:59 +08:00
|
|
|
|
2019-07-21 19:24:09 +08:00
|
|
|
void evlist__disable(struct evlist *evlist);
|
2019-07-21 19:24:08 +08:00
|
|
|
void evlist__enable(struct evlist *evlist);
|
2020-11-30 20:33:55 +08:00
|
|
|
void evlist__toggle_enable(struct evlist *evlist);
|
2020-12-11 04:43:28 +08:00
|
|
|
void evlist__disable_evsel(struct evlist *evlist, char *evsel_name);
|
|
|
|
void evlist__enable_evsel(struct evlist *evlist, char *evsel_name);
|
2011-07-25 22:06:19 +08:00
|
|
|
|
2020-12-01 02:01:08 +08:00
|
|
|
void evlist__set_selected(struct evlist *evlist, struct evsel *evsel);
|
2011-10-06 06:11:32 +08:00
|
|
|
|
2020-12-01 01:56:52 +08:00
|
|
|
int evlist__create_maps(struct evlist *evlist, struct target *target);
|
2020-11-30 20:38:02 +08:00
|
|
|
int evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel);
|
2011-01-30 20:46:46 +08:00
|
|
|
|
2020-11-30 20:22:07 +08:00
|
|
|
void evlist__set_leader(struct evlist *evlist);
|
2012-08-15 03:35:48 +08:00
|
|
|
|
2020-06-17 20:24:21 +08:00
|
|
|
u64 __evlist__combined_sample_type(struct evlist *evlist);
|
|
|
|
u64 evlist__combined_sample_type(struct evlist *evlist);
|
2020-06-17 20:31:25 +08:00
|
|
|
u64 evlist__combined_branch_type(struct evlist *evlist);
|
2020-06-17 20:29:48 +08:00
|
|
|
bool evlist__sample_id_all(struct evlist *evlist);
|
2020-12-01 02:13:12 +08:00
|
|
|
u16 evlist__id_hdr_size(struct evlist *evlist);
|
2011-05-21 23:49:00 +08:00
|
|
|
|
2020-11-30 20:43:07 +08:00
|
|
|
int evlist__parse_sample(struct evlist *evlist, union perf_event *event, struct perf_sample *sample);
|
|
|
|
int evlist__parse_sample_timestamp(struct evlist *evlist, union perf_event *event, u64 *timestamp);
|
2017-08-03 19:10:28 +08:00
|
|
|
|
2020-06-17 20:24:21 +08:00
|
|
|
bool evlist__valid_sample_type(struct evlist *evlist);
|
2020-06-17 20:29:48 +08:00
|
|
|
bool evlist__valid_sample_id_all(struct evlist *evlist);
|
2020-12-01 02:07:49 +08:00
|
|
|
bool evlist__valid_read_format(struct evlist *evlist);
|
2012-01-27 22:34:20 +08:00
|
|
|
|
2020-12-01 01:52:44 +08:00
|
|
|
void evlist__splice_list_tail(struct evlist *evlist, struct list_head *list);
|
2012-08-15 03:42:15 +08:00
|
|
|
|
2020-12-01 01:52:44 +08:00
|
|
|
static inline bool evlist__empty(struct evlist *evlist)
|
2017-07-21 13:11:57 +08:00
|
|
|
{
|
2019-07-21 19:24:23 +08:00
|
|
|
return list_empty(&evlist->core.entries);
|
2017-07-21 13:11:57 +08:00
|
|
|
}
|
|
|
|
|
2019-09-03 16:39:52 +08:00
|
|
|
static inline struct evsel *evlist__first(struct evlist *evlist)
|
2012-08-15 03:42:15 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(&evlist->core);
|
|
|
|
|
|
|
|
return container_of(evsel, struct evsel, core);
|
2012-08-15 03:42:15 +08:00
|
|
|
}
|
|
|
|
|
2019-09-03 16:39:52 +08:00
|
|
|
static inline struct evsel *evlist__last(struct evlist *evlist)
|
2012-08-15 03:42:15 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__last(&evlist->core);
|
|
|
|
|
|
|
|
return container_of(evsel, struct evsel, core);
|
2012-08-15 03:42:15 +08:00
|
|
|
}
|
2012-09-07 01:54:11 +08:00
|
|
|
|
2020-06-17 20:19:46 +08:00
|
|
|
int evlist__strerror_open(struct evlist *evlist, int err, char *buf, size_t size);
|
|
|
|
int evlist__strerror_mmap(struct evlist *evlist, int err, char *buf, size_t size);
|
2013-10-17 23:07:58 +08:00
|
|
|
|
2020-12-01 02:01:08 +08:00
|
|
|
bool evlist__can_select_event(struct evlist *evlist, const char *str);
|
2020-12-01 01:52:44 +08:00
|
|
|
void evlist__to_front(struct evlist *evlist, struct evsel *move_evsel);
|
2013-12-11 20:36:35 +08:00
|
|
|
|
2014-01-10 21:37:27 +08:00
|
|
|
/**
|
2016-06-23 22:26:15 +08:00
|
|
|
* __evlist__for_each_entry - iterate thru all the evsels
|
2014-01-10 21:37:27 +08:00
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 22:26:15 +08:00
|
|
|
#define __evlist__for_each_entry(list, evsel) \
|
2019-07-21 19:24:22 +08:00
|
|
|
list_for_each_entry(evsel, list, core.node)
|
2014-01-10 21:37:27 +08:00
|
|
|
|
|
|
|
/**
|
2016-06-23 22:26:15 +08:00
|
|
|
* evlist__for_each_entry - iterate thru all the evsels
|
2014-01-10 21:37:27 +08:00
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 22:26:15 +08:00
|
|
|
#define evlist__for_each_entry(evlist, evsel) \
|
2019-07-21 19:24:23 +08:00
|
|
|
__evlist__for_each_entry(&(evlist)->core.entries, evsel)
|
2014-01-10 21:37:27 +08:00
|
|
|
|
|
|
|
/**
|
2016-06-23 22:26:15 +08:00
|
|
|
* __evlist__for_each_entry_continue - continue iteration thru all the evsels
|
2014-01-10 21:37:27 +08:00
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 22:26:15 +08:00
|
|
|
#define __evlist__for_each_entry_continue(list, evsel) \
|
2019-07-21 19:24:22 +08:00
|
|
|
list_for_each_entry_continue(evsel, list, core.node)
|
2014-01-10 21:37:27 +08:00
|
|
|
|
|
|
|
/**
|
2016-06-23 22:26:15 +08:00
|
|
|
* evlist__for_each_entry_continue - continue iteration thru all the evsels
|
2014-01-10 21:37:27 +08:00
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 22:26:15 +08:00
|
|
|
#define evlist__for_each_entry_continue(evlist, evsel) \
|
2019-07-21 19:24:23 +08:00
|
|
|
__evlist__for_each_entry_continue(&(evlist)->core.entries, evsel)
|
2014-01-10 21:37:27 +08:00
|
|
|
|
2021-08-21 17:19:33 +08:00
|
|
|
/**
|
|
|
|
* __evlist__for_each_entry_from - continue iteration from @evsel (included)
|
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
|
|
|
#define __evlist__for_each_entry_from(list, evsel) \
|
|
|
|
list_for_each_entry_from(evsel, list, core.node)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* evlist__for_each_entry_from - continue iteration from @evsel (included)
|
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
|
|
|
#define evlist__for_each_entry_from(evlist, evsel) \
|
|
|
|
__evlist__for_each_entry_from(&(evlist)->core.entries, evsel)
|
|
|
|
|
2014-01-10 21:37:27 +08:00
|
|
|
/**
|
2016-06-23 22:26:15 +08:00
|
|
|
* __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
|
2014-01-10 21:37:27 +08:00
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 22:26:15 +08:00
|
|
|
#define __evlist__for_each_entry_reverse(list, evsel) \
|
2019-07-21 19:24:22 +08:00
|
|
|
list_for_each_entry_reverse(evsel, list, core.node)
|
2014-01-10 21:37:27 +08:00
|
|
|
|
|
|
|
/**
|
2016-06-23 22:26:15 +08:00
|
|
|
* evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
|
2014-01-10 21:37:27 +08:00
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 22:26:15 +08:00
|
|
|
#define evlist__for_each_entry_reverse(evlist, evsel) \
|
2019-07-21 19:24:23 +08:00
|
|
|
__evlist__for_each_entry_reverse(&(evlist)->core.entries, evsel)
|
2014-01-10 21:37:27 +08:00
|
|
|
|
|
|
|
/**
|
2016-06-23 22:26:15 +08:00
|
|
|
* __evlist__for_each_entry_safe - safely iterate thru all the evsels
|
2014-01-10 21:37:27 +08:00
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @tmp: struct evsel temp iterator
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 22:26:15 +08:00
|
|
|
#define __evlist__for_each_entry_safe(list, tmp, evsel) \
|
2019-07-21 19:24:22 +08:00
|
|
|
list_for_each_entry_safe(evsel, tmp, list, core.node)
|
2014-01-10 21:37:27 +08:00
|
|
|
|
|
|
|
/**
|
2016-06-23 22:26:15 +08:00
|
|
|
* evlist__for_each_entry_safe - safely iterate thru all the evsels
|
2014-01-10 21:37:27 +08:00
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
* @tmp: struct evsel temp iterator
|
|
|
|
*/
|
2016-06-23 22:26:15 +08:00
|
|
|
#define evlist__for_each_entry_safe(evlist, tmp, evsel) \
|
2019-07-21 19:24:23 +08:00
|
|
|
__evlist__for_each_entry_safe(&(evlist)->core.entries, tmp, evsel)
|
2013-12-11 20:36:29 +08:00
|
|
|
|
2022-01-05 14:13:37 +08:00
|
|
|
/** Iterator state for evlist__for_each_cpu */
|
|
|
|
struct evlist_cpu_iterator {
|
|
|
|
/** The list being iterated through. */
|
|
|
|
struct evlist *container;
|
|
|
|
/** The current evsel of the iterator. */
|
|
|
|
struct evsel *evsel;
|
|
|
|
/** The CPU map index corresponding to the evsel->core.cpus for the current CPU. */
|
|
|
|
int cpu_map_idx;
|
|
|
|
/**
|
|
|
|
* The CPU map index corresponding to evlist->core.all_cpus for the
|
|
|
|
* current CPU. Distinct from cpu_map_idx as the evsel's cpu map may
|
|
|
|
* contain fewer entries.
|
|
|
|
*/
|
|
|
|
int evlist_cpu_map_idx;
|
|
|
|
/** The number of CPU map entries in evlist->core.all_cpus. */
|
|
|
|
int evlist_cpu_map_nr;
|
|
|
|
/** The current CPU of the iterator. */
|
2022-01-05 14:13:51 +08:00
|
|
|
struct perf_cpu cpu;
|
2022-01-05 14:13:37 +08:00
|
|
|
/** If present, used to set the affinity when switching between CPUs. */
|
|
|
|
struct affinity *affinity;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* evlist__for_each_cpu - without affinity, iterate over the evlist. With
|
|
|
|
* affinity, iterate over all CPUs and then the evlist
|
|
|
|
* for each evsel on that CPU. When switching between
|
|
|
|
* CPUs the affinity is set to the CPU to avoid IPIs
|
|
|
|
* during syscalls.
|
|
|
|
* @evlist_cpu_itr: the iterator instance.
|
|
|
|
* @evlist: evlist instance to iterate.
|
|
|
|
* @affinity: NULL or used to set the affinity to the current CPU.
|
|
|
|
*/
|
|
|
|
#define evlist__for_each_cpu(evlist_cpu_itr, evlist, affinity) \
|
|
|
|
for ((evlist_cpu_itr) = evlist__cpu_begin(evlist, affinity); \
|
|
|
|
!evlist_cpu_iterator__end(&evlist_cpu_itr); \
|
|
|
|
evlist_cpu_iterator__next(&evlist_cpu_itr))
|
|
|
|
|
|
|
|
/** Returns an iterator set to the first CPU/evsel of evlist. */
|
|
|
|
struct evlist_cpu_iterator evlist__cpu_begin(struct evlist *evlist, struct affinity *affinity);
|
|
|
|
/** Move to next element in iterator, updating CPU, evsel and the affinity. */
|
|
|
|
void evlist_cpu_iterator__next(struct evlist_cpu_iterator *evlist_cpu_itr);
|
|
|
|
/** Returns true when iterator is at the end of the CPUs and evlist. */
|
|
|
|
bool evlist_cpu_iterator__end(const struct evlist_cpu_iterator *evlist_cpu_itr);
|
2019-11-21 08:15:15 +08:00
|
|
|
|
2020-12-01 01:39:41 +08:00
|
|
|
struct evsel *evlist__get_tracking_event(struct evlist *evlist);
|
|
|
|
void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_evsel);
|
2015-10-06 02:06:04 +08:00
|
|
|
|
2020-11-30 20:48:07 +08:00
|
|
|
struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
|
2016-07-10 19:07:53 +08:00
|
|
|
|
2020-12-01 01:17:57 +08:00
|
|
|
struct evsel *evlist__event2evsel(struct evlist *evlist, union perf_event *event);
|
2017-11-14 22:01:06 +08:00
|
|
|
|
2020-12-01 02:07:49 +08:00
|
|
|
bool evlist__exclude_kernel(struct evlist *evlist);
|
2018-05-21 22:57:44 +08:00
|
|
|
|
2020-12-01 01:58:32 +08:00
|
|
|
void evlist__force_leader(struct evlist *evlist);
|
|
|
|
|
|
|
|
struct evsel *evlist__reset_weak_group(struct evlist *evlist, struct evsel *evsel, bool close);
|
2018-05-21 22:57:44 +08:00
|
|
|
|
2020-07-17 15:01:33 +08:00
|
|
|
#define EVLIST_CTL_CMD_ENABLE_TAG "enable"
|
|
|
|
#define EVLIST_CTL_CMD_DISABLE_TAG "disable"
|
|
|
|
#define EVLIST_CTL_CMD_ACK_TAG "ack\n"
|
2020-09-01 17:37:57 +08:00
|
|
|
#define EVLIST_CTL_CMD_SNAPSHOT_TAG "snapshot"
|
perf tools: Add 'evlist' control command
Add a new 'evlist' control command to display all the evlist events.
When it is received, perf will scan and print current evlist into perf
record terminal.
The interface string for control file is:
evlist [-v|-g|-F]
The syntax follows perf evlist command:
-F Show just the sample frequency used for each event.
-v Show all fields.
-g Show event group information.
Example session:
terminal 1:
# mkfifo control ack
# perf record --control=fifo:control,ack -e '{cycles,instructions}'
terminal 2:
# echo evlist > control
terminal 1:
cycles
instructions
dummy:HG
terminal 2:
# echo 'evlist -v' > control
terminal 1:
cycles: size: 120, { sample_period, sample_freq }: 4000, sample_type: \
IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, inherit: 1, freq: 1, \
sample_id_all: 1, exclude_guest: 1
instructions: size: 120, config: 0x1, { sample_period, sample_freq }: 4000, \
sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, inherit: 1, freq: 1, \
sample_id_all: 1, exclude_guest: 1
dummy:HG: type: 1, size: 120, config: 0x9, { sample_period, sample_freq }: 4000, \
sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, inherit: 1, mmap: 1, \
comm: 1, freq: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, \
bpf_event: 1
terminal 2:
# echo 'evlist -g' > control
terminal 1:
{cycles,instructions}
dummy:HG
terminal 2:
# echo 'evlist -F' > control
terminal 1:
cycles: sample_freq=4000
instructions: sample_freq=4000
dummy:HG: sample_freq=4000
This new evlist command is handy to get real event names when
wildcards are used.
Adding evsel_fprintf.c object to python/perf.so build, because
it's now evlist.c dependency.
Adding PYTHON_PERF define for python/perf.so compilation, so we
can use it to compile in only evsel__fprintf from evsel_fprintf.c
object.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20201226232038.390883-3-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-12-27 07:20:36 +08:00
|
|
|
#define EVLIST_CTL_CMD_EVLIST_TAG "evlist"
|
2020-12-27 07:20:37 +08:00
|
|
|
#define EVLIST_CTL_CMD_STOP_TAG "stop"
|
2020-12-27 07:20:38 +08:00
|
|
|
#define EVLIST_CTL_CMD_PING_TAG "ping"
|
2020-07-17 15:01:33 +08:00
|
|
|
|
|
|
|
#define EVLIST_CTL_CMD_MAX_LEN 64
|
|
|
|
|
|
|
|
enum evlist_ctl_cmd {
|
|
|
|
EVLIST_CTL_CMD_UNSUPPORTED = 0,
|
|
|
|
EVLIST_CTL_CMD_ENABLE,
|
|
|
|
EVLIST_CTL_CMD_DISABLE,
|
2020-09-01 17:37:57 +08:00
|
|
|
EVLIST_CTL_CMD_ACK,
|
|
|
|
EVLIST_CTL_CMD_SNAPSHOT,
|
perf tools: Add 'evlist' control command
Add a new 'evlist' control command to display all the evlist events.
When it is received, perf will scan and print current evlist into perf
record terminal.
The interface string for control file is:
evlist [-v|-g|-F]
The syntax follows perf evlist command:
-F Show just the sample frequency used for each event.
-v Show all fields.
-g Show event group information.
Example session:
terminal 1:
# mkfifo control ack
# perf record --control=fifo:control,ack -e '{cycles,instructions}'
terminal 2:
# echo evlist > control
terminal 1:
cycles
instructions
dummy:HG
terminal 2:
# echo 'evlist -v' > control
terminal 1:
cycles: size: 120, { sample_period, sample_freq }: 4000, sample_type: \
IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, inherit: 1, freq: 1, \
sample_id_all: 1, exclude_guest: 1
instructions: size: 120, config: 0x1, { sample_period, sample_freq }: 4000, \
sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, inherit: 1, freq: 1, \
sample_id_all: 1, exclude_guest: 1
dummy:HG: type: 1, size: 120, config: 0x9, { sample_period, sample_freq }: 4000, \
sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, inherit: 1, mmap: 1, \
comm: 1, freq: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, \
bpf_event: 1
terminal 2:
# echo 'evlist -g' > control
terminal 1:
{cycles,instructions}
dummy:HG
terminal 2:
# echo 'evlist -F' > control
terminal 1:
cycles: sample_freq=4000
instructions: sample_freq=4000
dummy:HG: sample_freq=4000
This new evlist command is handy to get real event names when
wildcards are used.
Adding evsel_fprintf.c object to python/perf.so build, because
it's now evlist.c dependency.
Adding PYTHON_PERF define for python/perf.so compilation, so we
can use it to compile in only evsel__fprintf from evsel_fprintf.c
object.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20201226232038.390883-3-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-12-27 07:20:36 +08:00
|
|
|
EVLIST_CTL_CMD_EVLIST,
|
2020-12-27 07:20:37 +08:00
|
|
|
EVLIST_CTL_CMD_STOP,
|
2020-12-27 07:20:38 +08:00
|
|
|
EVLIST_CTL_CMD_PING,
|
2020-07-17 15:01:33 +08:00
|
|
|
};
|
|
|
|
|
2020-09-02 18:57:07 +08:00
|
|
|
int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close);
|
2020-09-03 20:29:37 +08:00
|
|
|
void evlist__close_control(int ctl_fd, int ctl_fd_ack, bool *ctl_fd_close);
|
2020-07-17 15:01:33 +08:00
|
|
|
int evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack);
|
|
|
|
int evlist__finalize_ctlfd(struct evlist *evlist);
|
|
|
|
bool evlist__ctlfd_initialized(struct evlist *evlist);
|
2022-01-18 02:34:24 +08:00
|
|
|
int evlist__ctlfd_update(struct evlist *evlist, struct pollfd *update);
|
2020-07-17 15:01:33 +08:00
|
|
|
int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd);
|
2020-09-01 17:37:57 +08:00
|
|
|
int evlist__ctlfd_ack(struct evlist *evlist);
|
2020-07-17 15:01:33 +08:00
|
|
|
|
2020-07-17 15:04:33 +08:00
|
|
|
#define EVLIST_ENABLED_MSG "Events enabled\n"
|
|
|
|
#define EVLIST_DISABLED_MSG "Events disabled\n"
|
|
|
|
|
2020-09-24 20:44:53 +08:00
|
|
|
struct evsel *evlist__find_evsel(struct evlist *evlist, int idx);
|
2021-04-14 21:08:16 +08:00
|
|
|
|
|
|
|
int evlist__scnprintf_evsels(struct evlist *evlist, size_t size, char *bf);
|
2021-05-27 08:16:09 +08:00
|
|
|
void evlist__check_mem_load_aux(struct evlist *evlist);
|
2011-01-12 06:56:53 +08:00
|
|
|
#endif /* __PERF_EVLIST_H */
|