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 07:07:57 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2011-01-11 15:56:53 -07:00
|
|
|
#ifndef __PERF_EVLIST_H
|
|
|
|
#define __PERF_EVLIST_H 1
|
|
|
|
|
2017-06-16 07:39:15 -07:00
|
|
|
#include <linux/compiler.h>
|
2017-04-17 07:39:06 -07:00
|
|
|
#include <linux/kernel.h>
|
2017-02-21 08:35:01 -07:00
|
|
|
#include <linux/refcount.h>
|
2011-01-11 15:56:53 -07:00
|
|
|
#include <linux/list.h>
|
2014-09-03 14:02:59 -07:00
|
|
|
#include <api/fd/array.h>
|
2019-07-21 04:24:23 -07:00
|
|
|
#include <internal/evlist.h>
|
2019-09-03 01:39:52 -07:00
|
|
|
#include <internal/evsel.h>
|
2023-03-11 19:15:42 -07:00
|
|
|
#include <perf/evlist.h>
|
2019-08-30 07:44:32 -07:00
|
|
|
#include "events_stats.h"
|
2012-08-14 12:42:15 -07:00
|
|
|
#include "evsel.h"
|
2019-09-23 08:20:38 -07:00
|
|
|
#include <pthread.h>
|
2017-04-19 11:49:18 -07:00
|
|
|
#include <signal.h>
|
2011-11-09 03:47:15 -07:00
|
|
|
#include <unistd.h>
|
2011-01-11 15:56:53 -07:00
|
|
|
|
2011-01-11 17:30:02 -07:00
|
|
|
struct pollfd;
|
2011-01-30 05:46:46 -07:00
|
|
|
struct thread_map;
|
2019-07-21 04:23:49 -07:00
|
|
|
struct perf_cpu_map;
|
2013-12-19 10:43:45 -07:00
|
|
|
struct record_opts;
|
2024-07-03 15:30:29 -07:00
|
|
|
struct target;
|
2011-01-11 17:30:02 -07:00
|
|
|
|
2019-09-23 08:20:38 -07: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,
|
|
|
|
};
|
|
|
|
|
perf record: Allow multiple recording time ranges
AUX area traces can produce too much data to record successfully or
analyze subsequently. Add another means to reduce data collection by
allowing multiple recording time ranges.
This is useful, for instance, in cases where a workload produces
predictably reproducible events in specific time ranges.
Today we only have perf record -D <msecs> to start at a specific region, or
some complicated approach using snapshot mode and external scripts sending
signals or using the fifos. But these approaches are difficult to set up
compared with simply having perf do it.
Extend perf record option -D/--delay option to specifying relative time
stamps for start stop controlled by perf with the right time offset, for
instance:
perf record -e intel_pt// -D 10-20,30-40
to record 10ms to 20ms into the trace and 30ms to 40ms.
Example:
The example workload is:
$ cat repeat-usleep.c
int usleep(useconds_t usec);
int usage(int ret, const char *msg)
{
if (msg)
fprintf(stderr, "%s\n", msg);
fprintf(stderr, "Usage is: repeat-usleep <microseconds>\n");
return ret;
}
int main(int argc, char *argv[])
{
unsigned long usecs;
char *end_ptr;
if (argc != 2)
return usage(1, "Error: Wrong number of arguments!");
errno = 0;
usecs = strtoul(argv[1], &end_ptr, 0);
if (errno || *end_ptr || usecs > UINT_MAX)
return usage(1, "Error: Invalid argument!");
while (1) {
int ret = usleep(usecs);
if (ret & errno != EINTR)
return usage(1, "Error: usleep() failed!");
}
return 0;
}
$ perf record -e intel_pt//u --delay 10-20,40-70,110-160 -- ./repeat-usleep 500
Events disabled
Events enabled
Events disabled
Events enabled
Events disabled
Events enabled
Events disabled
[ perf record: Woken up 5 times to write data ]
[ perf record: Captured and wrote 0.204 MB perf.data ]
Terminated
A dlfilter is used to determine continuous data collection (timestamps
less than 1ms apart):
$ cat dlfilter-show-delays.c
static __u64 start_time;
static __u64 last_time;
int start(void **data, void *ctx)
{
printf("%-17s\t%-9s\t%-6s\n", " Time", " Duration", " Delay");
return 0;
}
int filter_event_early(void *data, const struct perf_dlfilter_sample *sample, void *ctx)
{
__u64 delta;
if (!sample->time)
return 1;
if (!last_time)
goto out;
delta = sample->time - last_time;
if (delta < 1000000)
goto out2;;
printf("%17.9f\t%9.1f\t%6.1f\n", start_time / 1000000000.0, (last_time - start_time) / 1000000.0, delta / 1000000.0);
out:
start_time = sample->time;
out2:
last_time = sample->time;
return 1;
}
int stop(void *data, void *ctx)
{
printf("%17.9f\t%9.1f\n", start_time / 1000000000.0, (last_time - start_time) / 1000000.0);
return 0;
}
The result shows the times roughly match the --delay option:
$ perf script --itrace=qb --dlfilter dlfilter-show-delays.so
Time Duration Delay
39215.302317300 9.7 20.5
39215.332480217 30.4 40.9
39215.403837717 49.8
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220824072814.16422-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-08-24 00:28:14 -07:00
|
|
|
struct event_enable_timer;
|
|
|
|
|
2019-07-21 04:23:52 -07:00
|
|
|
struct evlist {
|
2019-07-21 04:24:23 -07:00
|
|
|
struct perf_evlist core;
|
2015-06-17 12:40:26 -07:00
|
|
|
bool enabled;
|
2013-08-27 01:23:09 -07:00
|
|
|
int id_pos;
|
|
|
|
int is_pos;
|
2024-08-13 09:02:02 -07:00
|
|
|
int nr_br_cntr;
|
2013-08-27 01:23:09 -07:00
|
|
|
u64 combined_sample_type;
|
2016-07-14 01:34:42 -07:00
|
|
|
enum bkw_mmap_state bkw_mmap_state;
|
2011-11-09 03:47:15 -07:00
|
|
|
struct {
|
|
|
|
int cork_fd;
|
|
|
|
pid_t pid;
|
|
|
|
} workload;
|
2019-07-27 11:30:53 -07:00
|
|
|
struct mmap *mmap;
|
|
|
|
struct mmap *overwrite_mmap;
|
2019-07-21 04:23:51 -07:00
|
|
|
struct evsel *selected;
|
2015-02-14 10:50:11 -07:00
|
|
|
struct events_stats stats;
|
2015-08-28 02:48:05 -07:00
|
|
|
struct perf_env *env;
|
2019-07-21 04:23:52 -07:00
|
|
|
void (*trace_event_sample_raw)(struct evlist *evlist,
|
2019-01-17 06:37:17 -07: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 06:13:41 -07:00
|
|
|
u64 first_sample_time;
|
|
|
|
u64 last_sample_time;
|
2019-03-11 22:30:50 -07:00
|
|
|
struct {
|
|
|
|
pthread_t th;
|
|
|
|
volatile int done;
|
|
|
|
} thread;
|
2020-07-17 00:00:47 -07: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;
|
perf record: Allow multiple recording time ranges
AUX area traces can produce too much data to record successfully or
analyze subsequently. Add another means to reduce data collection by
allowing multiple recording time ranges.
This is useful, for instance, in cases where a workload produces
predictably reproducible events in specific time ranges.
Today we only have perf record -D <msecs> to start at a specific region, or
some complicated approach using snapshot mode and external scripts sending
signals or using the fifos. But these approaches are difficult to set up
compared with simply having perf do it.
Extend perf record option -D/--delay option to specifying relative time
stamps for start stop controlled by perf with the right time offset, for
instance:
perf record -e intel_pt// -D 10-20,30-40
to record 10ms to 20ms into the trace and 30ms to 40ms.
Example:
The example workload is:
$ cat repeat-usleep.c
int usleep(useconds_t usec);
int usage(int ret, const char *msg)
{
if (msg)
fprintf(stderr, "%s\n", msg);
fprintf(stderr, "Usage is: repeat-usleep <microseconds>\n");
return ret;
}
int main(int argc, char *argv[])
{
unsigned long usecs;
char *end_ptr;
if (argc != 2)
return usage(1, "Error: Wrong number of arguments!");
errno = 0;
usecs = strtoul(argv[1], &end_ptr, 0);
if (errno || *end_ptr || usecs > UINT_MAX)
return usage(1, "Error: Invalid argument!");
while (1) {
int ret = usleep(usecs);
if (ret & errno != EINTR)
return usage(1, "Error: usleep() failed!");
}
return 0;
}
$ perf record -e intel_pt//u --delay 10-20,40-70,110-160 -- ./repeat-usleep 500
Events disabled
Events enabled
Events disabled
Events enabled
Events disabled
Events enabled
Events disabled
[ perf record: Woken up 5 times to write data ]
[ perf record: Captured and wrote 0.204 MB perf.data ]
Terminated
A dlfilter is used to determine continuous data collection (timestamps
less than 1ms apart):
$ cat dlfilter-show-delays.c
static __u64 start_time;
static __u64 last_time;
int start(void **data, void *ctx)
{
printf("%-17s\t%-9s\t%-6s\n", " Time", " Duration", " Delay");
return 0;
}
int filter_event_early(void *data, const struct perf_dlfilter_sample *sample, void *ctx)
{
__u64 delta;
if (!sample->time)
return 1;
if (!last_time)
goto out;
delta = sample->time - last_time;
if (delta < 1000000)
goto out2;;
printf("%17.9f\t%9.1f\t%6.1f\n", start_time / 1000000000.0, (last_time - start_time) / 1000000.0, delta / 1000000.0);
out:
start_time = sample->time;
out2:
last_time = sample->time;
return 1;
}
int stop(void *data, void *ctx)
{
printf("%17.9f\t%9.1f\n", start_time / 1000000000.0, (last_time - start_time) / 1000000.0);
return 0;
}
The result shows the times roughly match the --delay option:
$ perf script --itrace=qb --dlfilter dlfilter-show-delays.so
Time Duration Delay
39215.302317300 9.7 20.5
39215.332480217 30.4 40.9
39215.403837717 49.8
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220824072814.16422-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-08-24 00:28:14 -07:00
|
|
|
struct event_enable_timer *eet;
|
2011-01-11 15:56:53 -07:00
|
|
|
};
|
|
|
|
|
2019-07-21 04:23:51 -07: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-28 12:57:40 -07:00
|
|
|
const char *name;
|
|
|
|
void *handler;
|
|
|
|
};
|
|
|
|
|
2019-07-21 04:23:55 -07:00
|
|
|
struct evlist *evlist__new(void);
|
2020-11-30 11:04:05 -07:00
|
|
|
struct evlist *evlist__new_default(void);
|
|
|
|
struct evlist *evlist__new_dummy(void);
|
2019-07-21 04:23:54 -07:00
|
|
|
void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
|
|
|
|
struct perf_thread_map *threads);
|
2019-09-02 05:34:52 -07:00
|
|
|
void evlist__exit(struct evlist *evlist);
|
2019-07-21 04:23:56 -07:00
|
|
|
void evlist__delete(struct evlist *evlist);
|
2011-01-11 15:56:53 -07:00
|
|
|
|
2019-07-21 04:23:59 -07:00
|
|
|
void evlist__add(struct evlist *evlist, struct evsel *entry);
|
2019-07-21 04:24:00 -07:00
|
|
|
void evlist__remove(struct evlist *evlist, struct evsel *evsel);
|
2017-07-03 09:10:20 -07:00
|
|
|
|
perf x86 evlist: Add default hybrid events for perf stat
Provide a new solution to replace the reverted commit ac2dc29edd21f9ec
("perf stat: Add default hybrid events")
For the default software attrs, nothing is changed.
For the default hardware attrs, create a new evsel for each hybrid pmu.
With the new solution, adding a new default attr will not require the
special support for the hybrid platform anymore.
Also, the "--detailed" is supported on the hybrid platform
With the patch,
$ perf stat -a -ddd sleep 1
Performance counter stats for 'system wide':
32,231.06 msec cpu-clock # 32.056 CPUs utilized
529 context-switches # 16.413 /sec
32 cpu-migrations # 0.993 /sec
69 page-faults # 2.141 /sec
176,754,151 cpu_core/cycles/ # 5.484 M/sec (41.65%)
161,695,280 cpu_atom/cycles/ # 5.017 M/sec (49.92%)
48,595,992 cpu_core/instructions/ # 1.508 M/sec (49.98%)
32,363,337 cpu_atom/instructions/ # 1.004 M/sec (58.26%)
10,088,639 cpu_core/branches/ # 313.010 K/sec (58.31%)
6,390,582 cpu_atom/branches/ # 198.274 K/sec (58.26%)
846,201 cpu_core/branch-misses/ # 26.254 K/sec (66.65%)
676,477 cpu_atom/branch-misses/ # 20.988 K/sec (58.27%)
14,290,070 cpu_core/L1-dcache-loads/ # 443.363 K/sec (66.66%)
9,983,532 cpu_atom/L1-dcache-loads/ # 309.749 K/sec (58.27%)
740,725 cpu_core/L1-dcache-load-misses/ # 22.982 K/sec (66.66%)
<not supported> cpu_atom/L1-dcache-load-misses/
480,441 cpu_core/LLC-loads/ # 14.906 K/sec (66.67%)
326,570 cpu_atom/LLC-loads/ # 10.132 K/sec (58.27%)
329 cpu_core/LLC-load-misses/ # 10.208 /sec (66.68%)
0 cpu_atom/LLC-load-misses/ # 0.000 /sec (58.32%)
<not supported> cpu_core/L1-icache-loads/
21,982,491 cpu_atom/L1-icache-loads/ # 682.028 K/sec (58.43%)
4,493,189 cpu_core/L1-icache-load-misses/ # 139.406 K/sec (33.34%)
4,711,404 cpu_atom/L1-icache-load-misses/ # 146.176 K/sec (50.08%)
13,713,090 cpu_core/dTLB-loads/ # 425.462 K/sec (33.34%)
9,384,727 cpu_atom/dTLB-loads/ # 291.170 K/sec (50.08%)
157,387 cpu_core/dTLB-load-misses/ # 4.883 K/sec (33.33%)
108,328 cpu_atom/dTLB-load-misses/ # 3.361 K/sec (50.08%)
<not supported> cpu_core/iTLB-loads/
<not supported> cpu_atom/iTLB-loads/
37,655 cpu_core/iTLB-load-misses/ # 1.168 K/sec (33.32%)
61,661 cpu_atom/iTLB-load-misses/ # 1.913 K/sec (50.03%)
<not supported> cpu_core/L1-dcache-prefetches/
<not supported> cpu_atom/L1-dcache-prefetches/
<not supported> cpu_core/L1-dcache-prefetch-misses/
<not supported> cpu_atom/L1-dcache-prefetch-misses/
1.005466919 seconds time elapsed
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220721065706.2886112-5-zhengjun.xing@linux.intel.com
Signed-off-by: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-07-20 23:57:05 -07:00
|
|
|
int evlist__add_attrs(struct evlist *evlist, struct perf_event_attr *attrs, size_t nr_attrs);
|
|
|
|
|
2020-06-17 05:16:20 -07: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-30 09:53:54 -07:00
|
|
|
struct perf_event_attr *attrs, size_t nr_attrs);
|
2012-10-03 07:50:55 -07:00
|
|
|
|
2022-07-20 23:57:04 -07:00
|
|
|
int arch_evlist__add_default_attrs(struct evlist *evlist,
|
|
|
|
struct perf_event_attr *attrs,
|
|
|
|
size_t nr_attrs);
|
|
|
|
|
2020-06-17 05:16:20 -07:00
|
|
|
#define evlist__add_default_attrs(evlist, array) \
|
2022-07-20 23:57:04 -07:00
|
|
|
arch_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
|
2011-01-11 15:56:53 -07:00
|
|
|
|
perf parse-events: Sort and group parsed events
This change is intended to be a no-op for most current cases, the
default sort order is the order the events were parsed. Where it
varies is in how groups are handled. Previously an uncore and core
event that are grouped would most often cause the group to be removed:
```
$ perf stat -e '{instructions,uncore_imc_free_running_0/data_total/}' -a sleep 1
WARNING: grouped events cpus do not match, disabling group:
anon group { instructions, uncore_imc_free_running_0/data_total/ }
...
```
However, when wildcards are used the events should be re-sorted and
re-grouped in parse_events__set_leader, but this currently fails for
simple examples:
```
$ perf stat -e '{uncore_imc_free_running/data_read/,uncore_imc_free_running/data_write/}' -a sleep 1
Performance counter stats for 'system wide':
<not counted> MiB uncore_imc_free_running/data_read/
<not counted> MiB uncore_imc_free_running/data_write/
1.000996992 seconds time elapsed
```
A futher failure mode, fixed in this patch, is to force topdown events
into a group.
This change moves sorting the evsels in the evlist after parsing. It
requires parsing to set up groups. First the evsels are sorted
respecting the existing groupings and parse order, but also reordering
to ensure evsels of the same PMU and group appear together. So that
software and aux events respect groups, their pmu_name is taken from
the group leader. The sorting is done with list_sort removing a memory
allocation.
After sorting a pass is done to correct the group leaders and for
topdown events ensuring they have a group leader.
This fixes the problems seen before:
```
$ perf stat -e '{uncore_imc_free_running/data_read/,uncore_imc_free_running/data_write/}' -a sleep 1
Performance counter stats for 'system wide':
727.42 MiB uncore_imc_free_running/data_read/
81.84 MiB uncore_imc_free_running/data_write/
1.000948615 seconds time elapsed
```
As well as making groups not fail for cases like:
```
$ perf stat -e '{imc_free_running_0/data_total/,imc_free_running_1/data_total/}' -a sleep 1
Performance counter stats for 'system wide':
256.47 MiB imc_free_running_0/data_total/
256.48 MiB imc_free_running_1/data_total/
1.001165442 seconds time elapsed
```
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Steinar H. Gunderson <sesse@google.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-03-11 19:15:40 -07:00
|
|
|
int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs);
|
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 06:37:52 -07:00
|
|
|
|
2020-06-17 05:16:20 -07:00
|
|
|
int evlist__add_dummy(struct evlist *evlist);
|
2022-05-24 00:54:26 -07: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);
|
|
|
|
}
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-05 15:59:39 -07:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2022-10-03 13:46:46 -07:00
|
|
|
struct evsel *evlist__add_sched_switch(struct evlist *evlist, bool system_wide);
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-05 15:59:39 -07:00
|
|
|
#endif
|
2016-01-07 09:14:56 -07:00
|
|
|
|
2020-11-30 05:40:10 -07:00
|
|
|
int evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr,
|
|
|
|
evsel__sb_cb_t cb, void *data);
|
2020-04-29 11:42:16 -07:00
|
|
|
void evlist__set_cb(struct evlist *evlist, evsel__sb_cb_t cb, void *data);
|
2020-11-30 05:40:10 -07:00
|
|
|
int evlist__start_sb_thread(struct evlist *evlist, struct target *target);
|
|
|
|
void evlist__stop_sb_thread(struct evlist *evlist);
|
2019-03-11 22:30:50 -07:00
|
|
|
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-05 15:59:39 -07:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2020-06-17 05:16:20 -07:00
|
|
|
int evlist__add_newtp(struct evlist *evlist, const char *sys, const char *name, void *handler);
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-05 15:59:39 -07:00
|
|
|
#endif
|
2012-10-03 07:40:22 -07:00
|
|
|
|
2019-10-01 07:14:26 -07: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 05:38:02 -07: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-26 11:07:39 -07:00
|
|
|
|
2020-11-30 05:38:02 -07:00
|
|
|
int evlist__append_tp_filter(struct evlist *evlist, const char *filter);
|
2019-10-07 12:52:17 -07:00
|
|
|
|
2020-11-30 05:38:02 -07: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-07 13:00:34 -07:00
|
|
|
|
2020-11-30 05:48:07 -07: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-28 21:29:51 -07:00
|
|
|
|
2019-08-16 07:00:45 -07:00
|
|
|
int evlist__add_pollfd(struct evlist *evlist, int fd);
|
|
|
|
int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask);
|
2014-08-12 19:04:11 -07:00
|
|
|
|
2021-02-04 23:50:01 -07:00
|
|
|
#ifdef HAVE_EVENTFD_SUPPORT
|
|
|
|
int evlist__add_wakeup_eventfd(struct evlist *evlist, int fd);
|
|
|
|
#endif
|
|
|
|
|
2019-08-31 13:48:33 -07:00
|
|
|
int evlist__poll(struct evlist *evlist, int timeout);
|
2014-08-18 13:25:59 -07:00
|
|
|
|
2020-11-30 10:17:57 -07:00
|
|
|
struct evsel *evlist__id2evsel(struct evlist *evlist, u64 id);
|
|
|
|
struct evsel *evlist__id2evsel_strict(struct evlist *evlist, u64 id);
|
2011-01-12 17:39:13 -07:00
|
|
|
|
2020-11-30 10:17:57 -07:00
|
|
|
struct perf_sample_id *evlist__id2sid(struct evlist *evlist, u64 id);
|
2012-10-11 05:10:35 -07:00
|
|
|
|
2020-11-30 05:33:55 -07:00
|
|
|
void evlist__toggle_bkw_mmap(struct evlist *evlist, enum bkw_mmap_state state);
|
2016-07-14 01:34:42 -07:00
|
|
|
|
2019-07-28 03:45:35 -07:00
|
|
|
void evlist__mmap_consume(struct evlist *evlist, int idx);
|
2013-10-24 00:43:33 -07:00
|
|
|
|
2019-07-21 04:24:06 -07:00
|
|
|
int evlist__open(struct evlist *evlist);
|
2019-07-21 04:24:07 -07:00
|
|
|
void evlist__close(struct evlist *evlist);
|
2011-10-25 05:42:19 -07:00
|
|
|
|
2016-04-11 14:15:29 -07:00
|
|
|
struct callchain_param;
|
|
|
|
|
2020-11-30 10:44:40 -07:00
|
|
|
void evlist__set_id_pos(struct evlist *evlist);
|
2020-11-30 11:07:49 -07:00
|
|
|
void evlist__config(struct evlist *evlist, struct record_opts *opts, struct callchain_param *callchain);
|
2013-12-19 10:43:45 -07:00
|
|
|
int record_opts__config(struct record_opts *opts);
|
2011-11-08 09:41:57 -07:00
|
|
|
|
2020-11-30 05:26:54 -07: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 03:47:15 -07:00
|
|
|
|
2014-10-17 08:16:00 -07:00
|
|
|
struct option;
|
|
|
|
|
2020-11-30 11:09:45 -07: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 03:36:12 -07:00
|
|
|
|
2016-04-15 13:46:31 -07:00
|
|
|
unsigned long perf_event_mlock_kb_in_pages(void);
|
|
|
|
|
2019-07-28 03:45:35 -07:00
|
|
|
int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
|
2017-12-02 19:00:38 -07: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-18 10:40:26 -07:00
|
|
|
bool auxtrace_overwrite, int nr_cblocks,
|
2019-03-18 10:42:19 -07:00
|
|
|
int affinity, int flush, int comp_level);
|
2019-07-28 03:45:35 -07:00
|
|
|
int evlist__mmap(struct evlist *evlist, unsigned int pages);
|
2019-08-16 07:19:55 -07:00
|
|
|
void evlist__munmap(struct evlist *evlist);
|
2011-01-30 06:59:43 -07:00
|
|
|
|
2019-07-28 03:45:35 -07:00
|
|
|
size_t evlist__mmap_size(unsigned long pages);
|
2017-01-09 02:51:59 -07:00
|
|
|
|
2019-07-21 04:24:09 -07:00
|
|
|
void evlist__disable(struct evlist *evlist);
|
2019-07-21 04:24:08 -07:00
|
|
|
void evlist__enable(struct evlist *evlist);
|
2020-11-30 05:33:55 -07:00
|
|
|
void evlist__toggle_enable(struct evlist *evlist);
|
2020-12-10 13:43:28 -07:00
|
|
|
void evlist__disable_evsel(struct evlist *evlist, char *evsel_name);
|
|
|
|
void evlist__enable_evsel(struct evlist *evlist, char *evsel_name);
|
2022-08-24 00:28:13 -07:00
|
|
|
void evlist__disable_non_dummy(struct evlist *evlist);
|
|
|
|
void evlist__enable_non_dummy(struct evlist *evlist);
|
2011-07-25 07:06:19 -07:00
|
|
|
|
2020-11-30 11:01:08 -07:00
|
|
|
void evlist__set_selected(struct evlist *evlist, struct evsel *evsel);
|
2011-10-05 15:11:32 -07:00
|
|
|
|
2020-11-30 10:56:52 -07:00
|
|
|
int evlist__create_maps(struct evlist *evlist, struct target *target);
|
2024-07-03 15:30:29 -07:00
|
|
|
int evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel,
|
|
|
|
struct target *target);
|
2011-01-30 05:46:46 -07:00
|
|
|
|
2020-06-17 05:24:21 -07:00
|
|
|
u64 __evlist__combined_sample_type(struct evlist *evlist);
|
|
|
|
u64 evlist__combined_sample_type(struct evlist *evlist);
|
2020-06-17 05:31:25 -07:00
|
|
|
u64 evlist__combined_branch_type(struct evlist *evlist);
|
2024-08-13 09:02:02 -07:00
|
|
|
void evlist__update_br_cntr(struct evlist *evlist);
|
2020-06-17 05:29:48 -07:00
|
|
|
bool evlist__sample_id_all(struct evlist *evlist);
|
2020-11-30 11:13:12 -07:00
|
|
|
u16 evlist__id_hdr_size(struct evlist *evlist);
|
2011-05-21 08:49:00 -07:00
|
|
|
|
2020-11-30 05:43:07 -07: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 04:10:28 -07:00
|
|
|
|
2020-06-17 05:24:21 -07:00
|
|
|
bool evlist__valid_sample_type(struct evlist *evlist);
|
2020-06-17 05:29:48 -07:00
|
|
|
bool evlist__valid_sample_id_all(struct evlist *evlist);
|
2020-11-30 11:07:49 -07:00
|
|
|
bool evlist__valid_read_format(struct evlist *evlist);
|
2012-01-27 07:34:20 -07:00
|
|
|
|
2020-11-30 10:52:44 -07:00
|
|
|
void evlist__splice_list_tail(struct evlist *evlist, struct list_head *list);
|
2012-08-14 12:42:15 -07:00
|
|
|
|
2020-11-30 10:52:44 -07:00
|
|
|
static inline bool evlist__empty(struct evlist *evlist)
|
2017-07-20 22:11:57 -07:00
|
|
|
{
|
2019-07-21 04:24:23 -07:00
|
|
|
return list_empty(&evlist->core.entries);
|
2017-07-20 22:11:57 -07:00
|
|
|
}
|
|
|
|
|
2019-09-03 01:39:52 -07:00
|
|
|
static inline struct evsel *evlist__first(struct evlist *evlist)
|
2012-08-14 12:42:15 -07:00
|
|
|
{
|
2019-09-03 01:39:52 -07:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(&evlist->core);
|
|
|
|
|
|
|
|
return container_of(evsel, struct evsel, core);
|
2012-08-14 12:42:15 -07:00
|
|
|
}
|
|
|
|
|
2019-09-03 01:39:52 -07:00
|
|
|
static inline struct evsel *evlist__last(struct evlist *evlist)
|
2012-08-14 12:42:15 -07:00
|
|
|
{
|
2019-09-03 01:39:52 -07:00
|
|
|
struct perf_evsel *evsel = perf_evlist__last(&evlist->core);
|
|
|
|
|
|
|
|
return container_of(evsel, struct evsel, core);
|
2012-08-14 12:42:15 -07:00
|
|
|
}
|
2012-09-06 10:54:11 -07:00
|
|
|
|
2023-03-11 19:15:42 -07:00
|
|
|
static inline int evlist__nr_groups(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
return perf_evlist__nr_groups(&evlist->core);
|
|
|
|
}
|
|
|
|
|
2020-06-17 05:19:46 -07: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 08:07:58 -07:00
|
|
|
|
2020-11-30 11:01:08 -07:00
|
|
|
bool evlist__can_select_event(struct evlist *evlist, const char *str);
|
2020-11-30 10:52:44 -07:00
|
|
|
void evlist__to_front(struct evlist *evlist, struct evsel *move_evsel);
|
2013-12-11 05:36:35 -07:00
|
|
|
|
2014-01-10 06:37:27 -07:00
|
|
|
/**
|
2016-06-23 07:26:15 -07:00
|
|
|
* __evlist__for_each_entry - iterate thru all the evsels
|
2014-01-10 06:37:27 -07:00
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 07:26:15 -07:00
|
|
|
#define __evlist__for_each_entry(list, evsel) \
|
2019-07-21 04:24:22 -07:00
|
|
|
list_for_each_entry(evsel, list, core.node)
|
2014-01-10 06:37:27 -07:00
|
|
|
|
|
|
|
/**
|
2016-06-23 07:26:15 -07:00
|
|
|
* evlist__for_each_entry - iterate thru all the evsels
|
2014-01-10 06:37:27 -07:00
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 07:26:15 -07:00
|
|
|
#define evlist__for_each_entry(evlist, evsel) \
|
2019-07-21 04:24:23 -07:00
|
|
|
__evlist__for_each_entry(&(evlist)->core.entries, evsel)
|
2014-01-10 06:37:27 -07:00
|
|
|
|
|
|
|
/**
|
2016-06-23 07:26:15 -07:00
|
|
|
* __evlist__for_each_entry_continue - continue iteration thru all the evsels
|
2014-01-10 06:37:27 -07:00
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 07:26:15 -07:00
|
|
|
#define __evlist__for_each_entry_continue(list, evsel) \
|
2019-07-21 04:24:22 -07:00
|
|
|
list_for_each_entry_continue(evsel, list, core.node)
|
2014-01-10 06:37:27 -07:00
|
|
|
|
|
|
|
/**
|
2016-06-23 07:26:15 -07:00
|
|
|
* evlist__for_each_entry_continue - continue iteration thru all the evsels
|
2014-01-10 06:37:27 -07:00
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 07:26:15 -07:00
|
|
|
#define evlist__for_each_entry_continue(evlist, evsel) \
|
2019-07-21 04:24:23 -07:00
|
|
|
__evlist__for_each_entry_continue(&(evlist)->core.entries, evsel)
|
2014-01-10 06:37:27 -07:00
|
|
|
|
2021-08-21 02:19:33 -07: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 06:37:27 -07:00
|
|
|
/**
|
2016-06-23 07:26:15 -07:00
|
|
|
* __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
|
2014-01-10 06:37:27 -07:00
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 07:26:15 -07:00
|
|
|
#define __evlist__for_each_entry_reverse(list, evsel) \
|
2019-07-21 04:24:22 -07:00
|
|
|
list_for_each_entry_reverse(evsel, list, core.node)
|
2014-01-10 06:37:27 -07:00
|
|
|
|
|
|
|
/**
|
2016-06-23 07:26:15 -07:00
|
|
|
* evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
|
2014-01-10 06:37:27 -07:00
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 07:26:15 -07:00
|
|
|
#define evlist__for_each_entry_reverse(evlist, evsel) \
|
2019-07-21 04:24:23 -07:00
|
|
|
__evlist__for_each_entry_reverse(&(evlist)->core.entries, evsel)
|
2014-01-10 06:37:27 -07:00
|
|
|
|
|
|
|
/**
|
2016-06-23 07:26:15 -07:00
|
|
|
* __evlist__for_each_entry_safe - safely iterate thru all the evsels
|
2014-01-10 06:37:27 -07:00
|
|
|
* @list: list_head instance to iterate
|
|
|
|
* @tmp: struct evsel temp iterator
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
*/
|
2016-06-23 07:26:15 -07:00
|
|
|
#define __evlist__for_each_entry_safe(list, tmp, evsel) \
|
2019-07-21 04:24:22 -07:00
|
|
|
list_for_each_entry_safe(evsel, tmp, list, core.node)
|
2014-01-10 06:37:27 -07:00
|
|
|
|
|
|
|
/**
|
2016-06-23 07:26:15 -07:00
|
|
|
* evlist__for_each_entry_safe - safely iterate thru all the evsels
|
2014-01-10 06:37:27 -07:00
|
|
|
* @evlist: evlist instance to iterate
|
|
|
|
* @evsel: struct evsel iterator
|
|
|
|
* @tmp: struct evsel temp iterator
|
|
|
|
*/
|
2016-06-23 07:26:15 -07:00
|
|
|
#define evlist__for_each_entry_safe(evlist, tmp, evsel) \
|
2019-07-21 04:24:23 -07:00
|
|
|
__evlist__for_each_entry_safe(&(evlist)->core.entries, tmp, evsel)
|
2013-12-11 05:36:29 -07:00
|
|
|
|
2022-01-04 23:13:37 -07: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-04 23:13:51 -07:00
|
|
|
struct perf_cpu cpu;
|
2022-01-04 23:13:37 -07: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-20 17:15:15 -07:00
|
|
|
|
2020-11-30 10:39:41 -07:00
|
|
|
struct evsel *evlist__get_tracking_event(struct evlist *evlist);
|
|
|
|
void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_evsel);
|
2023-09-03 19:33:36 -07:00
|
|
|
struct evsel *evlist__findnew_tracking_event(struct evlist *evlist, bool system_wide);
|
2015-10-05 11:06:04 -07:00
|
|
|
|
2020-11-30 05:48:07 -07:00
|
|
|
struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
|
2016-07-10 04:07:53 -07:00
|
|
|
|
2020-11-30 10:17:57 -07:00
|
|
|
struct evsel *evlist__event2evsel(struct evlist *evlist, union perf_event *event);
|
2017-11-14 07:01:06 -07:00
|
|
|
|
2020-11-30 11:07:49 -07:00
|
|
|
bool evlist__exclude_kernel(struct evlist *evlist);
|
2018-05-21 07:57:44 -07:00
|
|
|
|
2020-11-30 10:58:32 -07: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 07:57:44 -07:00
|
|
|
|
2020-07-17 00:01:33 -07: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 02:37:57 -07: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-26 16:20:36 -07:00
|
|
|
#define EVLIST_CTL_CMD_EVLIST_TAG "evlist"
|
2020-12-26 16:20:37 -07:00
|
|
|
#define EVLIST_CTL_CMD_STOP_TAG "stop"
|
2020-12-26 16:20:38 -07:00
|
|
|
#define EVLIST_CTL_CMD_PING_TAG "ping"
|
2020-07-17 00:01:33 -07: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 02:37:57 -07: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-26 16:20:36 -07:00
|
|
|
EVLIST_CTL_CMD_EVLIST,
|
2020-12-26 16:20:37 -07:00
|
|
|
EVLIST_CTL_CMD_STOP,
|
2020-12-26 16:20:38 -07:00
|
|
|
EVLIST_CTL_CMD_PING,
|
2020-07-17 00:01:33 -07:00
|
|
|
};
|
|
|
|
|
2020-09-02 03:57:07 -07:00
|
|
|
int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close);
|
2020-09-03 05:29:37 -07:00
|
|
|
void evlist__close_control(int ctl_fd, int ctl_fd_ack, bool *ctl_fd_close);
|
2020-07-17 00:01:33 -07: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);
|
|
|
|
int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd);
|
2020-09-01 02:37:57 -07:00
|
|
|
int evlist__ctlfd_ack(struct evlist *evlist);
|
2020-07-17 00:01:33 -07:00
|
|
|
|
2020-07-17 00:04:33 -07:00
|
|
|
#define EVLIST_ENABLED_MSG "Events enabled\n"
|
|
|
|
#define EVLIST_DISABLED_MSG "Events disabled\n"
|
|
|
|
|
perf record: Allow multiple recording time ranges
AUX area traces can produce too much data to record successfully or
analyze subsequently. Add another means to reduce data collection by
allowing multiple recording time ranges.
This is useful, for instance, in cases where a workload produces
predictably reproducible events in specific time ranges.
Today we only have perf record -D <msecs> to start at a specific region, or
some complicated approach using snapshot mode and external scripts sending
signals or using the fifos. But these approaches are difficult to set up
compared with simply having perf do it.
Extend perf record option -D/--delay option to specifying relative time
stamps for start stop controlled by perf with the right time offset, for
instance:
perf record -e intel_pt// -D 10-20,30-40
to record 10ms to 20ms into the trace and 30ms to 40ms.
Example:
The example workload is:
$ cat repeat-usleep.c
int usleep(useconds_t usec);
int usage(int ret, const char *msg)
{
if (msg)
fprintf(stderr, "%s\n", msg);
fprintf(stderr, "Usage is: repeat-usleep <microseconds>\n");
return ret;
}
int main(int argc, char *argv[])
{
unsigned long usecs;
char *end_ptr;
if (argc != 2)
return usage(1, "Error: Wrong number of arguments!");
errno = 0;
usecs = strtoul(argv[1], &end_ptr, 0);
if (errno || *end_ptr || usecs > UINT_MAX)
return usage(1, "Error: Invalid argument!");
while (1) {
int ret = usleep(usecs);
if (ret & errno != EINTR)
return usage(1, "Error: usleep() failed!");
}
return 0;
}
$ perf record -e intel_pt//u --delay 10-20,40-70,110-160 -- ./repeat-usleep 500
Events disabled
Events enabled
Events disabled
Events enabled
Events disabled
Events enabled
Events disabled
[ perf record: Woken up 5 times to write data ]
[ perf record: Captured and wrote 0.204 MB perf.data ]
Terminated
A dlfilter is used to determine continuous data collection (timestamps
less than 1ms apart):
$ cat dlfilter-show-delays.c
static __u64 start_time;
static __u64 last_time;
int start(void **data, void *ctx)
{
printf("%-17s\t%-9s\t%-6s\n", " Time", " Duration", " Delay");
return 0;
}
int filter_event_early(void *data, const struct perf_dlfilter_sample *sample, void *ctx)
{
__u64 delta;
if (!sample->time)
return 1;
if (!last_time)
goto out;
delta = sample->time - last_time;
if (delta < 1000000)
goto out2;;
printf("%17.9f\t%9.1f\t%6.1f\n", start_time / 1000000000.0, (last_time - start_time) / 1000000.0, delta / 1000000.0);
out:
start_time = sample->time;
out2:
last_time = sample->time;
return 1;
}
int stop(void *data, void *ctx)
{
printf("%17.9f\t%9.1f\n", start_time / 1000000000.0, (last_time - start_time) / 1000000.0);
return 0;
}
The result shows the times roughly match the --delay option:
$ perf script --itrace=qb --dlfilter dlfilter-show-delays.so
Time Duration Delay
39215.302317300 9.7 20.5
39215.332480217 30.4 40.9
39215.403837717 49.8
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220824072814.16422-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-08-24 00:28:14 -07:00
|
|
|
int evlist__parse_event_enable_time(struct evlist *evlist, struct record_opts *opts,
|
|
|
|
const char *str, int unset);
|
|
|
|
int event_enable_timer__start(struct event_enable_timer *eet);
|
|
|
|
void event_enable_timer__exit(struct event_enable_timer **ep);
|
|
|
|
int event_enable_timer__process(struct event_enable_timer *eet);
|
|
|
|
|
2020-09-24 05:44:53 -07:00
|
|
|
struct evsel *evlist__find_evsel(struct evlist *evlist, int idx);
|
2021-04-14 06:08:16 -07:00
|
|
|
|
|
|
|
int evlist__scnprintf_evsels(struct evlist *evlist, size_t size, char *bf);
|
2021-05-26 17:16:09 -07:00
|
|
|
void evlist__check_mem_load_aux(struct evlist *evlist);
|
2023-05-27 00:21:47 -07:00
|
|
|
void evlist__warn_user_requested_cpus(struct evlist *evlist, const char *cpu_list);
|
2023-12-14 07:46:12 -07:00
|
|
|
void evlist__uniquify_name(struct evlist *evlist);
|
2024-08-14 18:36:17 -07:00
|
|
|
bool evlist__has_bpf_output(struct evlist *evlist);
|
2023-05-27 00:21:47 -07:00
|
|
|
|
2011-01-11 15:56:53 -07:00
|
|
|
#endif /* __PERF_EVLIST_H */
|