2019-08-22 21:40:29 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _PERF_RECORD_H
|
|
|
|
#define _PERF_RECORD_H
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/perf_event.h>
|
|
|
|
#include "util/target.h"
|
|
|
|
|
|
|
|
struct option;
|
|
|
|
|
|
|
|
struct record_opts {
|
|
|
|
struct target target;
|
|
|
|
bool inherit_stat;
|
|
|
|
bool no_buffering;
|
|
|
|
bool no_inherit;
|
|
|
|
bool no_inherit_set;
|
|
|
|
bool no_samples;
|
|
|
|
bool raw_samples;
|
|
|
|
bool sample_address;
|
|
|
|
bool sample_phys_addr;
|
2020-11-30 20:27:53 +03:00
|
|
|
bool sample_data_page_size;
|
2021-01-05 22:57:49 +03:00
|
|
|
bool sample_code_page_size;
|
2019-08-22 21:40:29 +03:00
|
|
|
bool sample_weight;
|
|
|
|
bool sample_time;
|
|
|
|
bool sample_time_set;
|
|
|
|
bool sample_cpu;
|
perf record: Add new option to sample identifier
In preparation for recording sideband events in a virtual machine guest so
that they can be injected into a host perf.data file.
Add an option to always include sample type PERF_SAMPLE_IDENTIFIER.
Committer testing:
# perf record sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.020 MB perf.data (7 samples) ]
# perf evlist -v
cycles: size: 128, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
#
#
# perf record --sample-identifier sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.022 MB perf.data (7 samples) ]
# perf evlist -v
cycles: size: 128, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
#
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220615052511.4441-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-06-15 08:25:11 +03:00
|
|
|
bool sample_identifier;
|
2019-08-22 21:40:29 +03:00
|
|
|
bool period;
|
|
|
|
bool period_set;
|
|
|
|
bool running_time;
|
|
|
|
bool full_auxtrace;
|
|
|
|
bool auxtrace_snapshot_mode;
|
|
|
|
bool auxtrace_snapshot_on_exit;
|
2019-11-15 15:42:15 +03:00
|
|
|
bool auxtrace_sample_mode;
|
2019-08-22 21:40:29 +03:00
|
|
|
bool record_namespaces;
|
2020-03-25 15:45:34 +03:00
|
|
|
bool record_cgroup;
|
2019-08-22 21:40:29 +03:00
|
|
|
bool record_switch_events;
|
2020-05-28 15:08:58 +03:00
|
|
|
bool record_switch_events_set;
|
2019-08-22 21:40:29 +03:00
|
|
|
bool all_kernel;
|
|
|
|
bool all_user;
|
|
|
|
bool kernel_callchains;
|
|
|
|
bool user_callchains;
|
|
|
|
bool tail_synthesize;
|
|
|
|
bool overwrite;
|
|
|
|
bool ignore_missing_thread;
|
|
|
|
bool strict_freq;
|
|
|
|
bool sample_id;
|
|
|
|
bool no_bpf_event;
|
perf record: Put a copy of kcore into the perf.data directory
Add a new 'perf record' option '--kcore' which will put a copy of
/proc/kcore, kallsyms and modules into a perf.data directory. Note, that
without the --kcore option, output goes to a file as previously. The
tools' -o and -i options work with either a file name or directory name.
Example:
$ sudo perf record --kcore uname
$ sudo tree perf.data
perf.data
├── kcore_dir
│ ├── kallsyms
│ ├── kcore
│ └── modules
└── data
$ sudo perf script -v
build id event received for vmlinux: 1eaa285996affce2d74d8e66dcea09a80c9941de
build id event received for [vdso]: 8bbaf5dc62a9b644b4d4e4539737e104e4a84541
Samples for 'cycles' event do not have CPU attribute set. Skipping 'cpu' field.
Using CPUID GenuineIntel-6-8E-A
Using perf.data/kcore_dir/kcore for kernel data
Using perf.data/kcore_dir/kallsyms for symbols
perf 19058 506778.423729: 1 cycles: ffffffffa2caa548 native_write_msr+0x8 (vmlinux)
perf 19058 506778.423733: 1 cycles: ffffffffa2caa548 native_write_msr+0x8 (vmlinux)
perf 19058 506778.423734: 7 cycles: ffffffffa2caa548 native_write_msr+0x8 (vmlinux)
perf 19058 506778.423736: 117 cycles: ffffffffa2caa54a native_write_msr+0xa (vmlinux)
perf 19058 506778.423738: 2092 cycles: ffffffffa2c9b7b0 native_apic_msr_write+0x0 (vmlinux)
perf 19058 506778.423740: 37380 cycles: ffffffffa2f121d0 perf_event_addr_filters_exec+0x0 (vmlinux)
uname 19058 506778.423751: 582673 cycles: ffffffffa303a407 propagate_protected_usage+0x147 (vmlinux)
uname 19058 506778.423892: 2241841 cycles: ffffffffa2cae0c9 unwind_next_frame.part.5+0x79 (vmlinux)
uname 19058 506778.424430: 2457397 cycles: ffffffffa3019232 check_memory_region+0x52 (vmlinux)
Committer testing:
# rm -rf perf.data*
# perf record sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.024 MB perf.data (7 samples) ]
# ls -l perf.data
-rw-------. 1 root root 34772 Oct 21 11:08 perf.data
# perf record --kcore uname
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.024 MB perf.data (7 samples) ]
ls[root@quaco ~]# ls -lad perf.data*
drwx------. 3 root root 4096 Oct 21 11:08 perf.data
-rw-------. 1 root root 34772 Oct 21 11:08 perf.data.old
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
# perf evlist -v -i perf.data/data
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
#
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: http://lore.kernel.org/lkml/20191004083121.12182-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-10-04 11:31:21 +03:00
|
|
|
bool kcore;
|
2020-05-12 15:19:18 +03:00
|
|
|
bool text_poke;
|
perf record: Add --buildid-mmap option to enable PERF_RECORD_MMAP2's build id
Add --buildid-mmap option to enable build id in PERF_RECORD_MMAP2 events.
It will only work if there's kernel support for that and it disables
build id cache (implies --no-buildid).
It's also possible to enable it permanently via config option in
~/.perfconfig file:
[record]
build-id=mmap
Also added build_id bit in the verbose output for perf_event_attr:
# perf record --buildid-mmap -vv
...
perf_event_attr:
type 1
size 120
...
build_id 1
Adding also missing text_poke bit.
Committer testing:
$ perf record -h build
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-B, --no-buildid do not collect buildids in perf.data
-N, --no-buildid-cache
do not update the buildid cache
--buildid-all Record build-id of all DSOs regardless of hits
--buildid-mmap Record build-id in map events
$
$ perf record --buildid-mmap sleep 1
Failed: no support to record build id in mmap events, update your kernel.
$
After adding the needed kernel bits in a test kernel:
$ perf record -vv --buildid-mmap sleep 1 |& grep -m1 build
Enabling build id in mmap2 events.
$ perf evlist -v
cycles:u: size: 120, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 1, exclude_kernel: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, build_id: 1
$
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20201214105457.543111-16-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-12-14 13:54:57 +03:00
|
|
|
bool build_id;
|
2019-08-22 21:40:29 +03:00
|
|
|
unsigned int freq;
|
|
|
|
unsigned int mmap_pages;
|
|
|
|
unsigned int auxtrace_mmap_pages;
|
|
|
|
unsigned int user_freq;
|
|
|
|
u64 branch_stack;
|
|
|
|
u64 sample_intr_regs;
|
|
|
|
u64 sample_user_regs;
|
|
|
|
u64 default_interval;
|
|
|
|
u64 user_interval;
|
|
|
|
size_t auxtrace_snapshot_size;
|
|
|
|
const char *auxtrace_snapshot_opts;
|
2019-11-15 15:42:15 +03:00
|
|
|
const char *auxtrace_sample_opts;
|
2019-08-22 21:40:29 +03:00
|
|
|
bool sample_transaction;
|
2020-07-17 10:07:03 +03:00
|
|
|
int initial_delay;
|
2019-08-22 21:40:29 +03:00
|
|
|
bool use_clockid;
|
|
|
|
clockid_t clockid;
|
|
|
|
u64 clockid_res_ns;
|
|
|
|
int nr_cblocks;
|
|
|
|
int affinity;
|
|
|
|
int mmap_flush;
|
|
|
|
unsigned int comp_level;
|
2020-04-22 18:50:38 +03:00
|
|
|
unsigned int nr_threads_synthesize;
|
2020-07-17 10:08:23 +03:00
|
|
|
int ctl_fd;
|
|
|
|
int ctl_fd_ack;
|
2020-09-02 13:57:07 +03:00
|
|
|
bool ctl_fd_close;
|
2021-08-11 07:46:58 +03:00
|
|
|
int synth;
|
2022-01-17 21:34:27 +03:00
|
|
|
int threads_spec;
|
2022-01-17 21:34:33 +03:00
|
|
|
const char *threads_user_spec;
|
2019-08-22 21:40:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const char * const *record_usage;
|
|
|
|
extern struct option *record_options;
|
|
|
|
|
|
|
|
int record__parse_freq(const struct option *opt, const char *str, int unset);
|
|
|
|
|
2020-05-28 15:08:58 +03:00
|
|
|
static inline bool record_opts__no_switch_events(const struct record_opts *opts)
|
|
|
|
{
|
|
|
|
return opts->record_switch_events_set && !opts->record_switch_events;
|
|
|
|
}
|
|
|
|
|
2019-08-22 21:40:29 +03:00
|
|
|
#endif // _PERF_RECORD_H
|