17 #include <linux/kernel.h> 18 #include <linux/types.h> 19 #include <linux/bitops.h> 20 #include <linux/log2.h> 22 #include "../../util/cpumap.h" 23 #include "../../util/evsel.h" 24 #include "../../util/evlist.h" 25 #include "../../util/session.h" 26 #include "../../util/util.h" 27 #include "../../util/pmu.h" 28 #include "../../util/debug.h" 29 #include "../../util/tsc.h" 30 #include "../../util/auxtrace.h" 31 #include "../../util/intel-bts.h" 33 #define KiB(x) ((x) * 1024) 34 #define MiB(x) ((x) * 1024 * 1024) 35 #define KiB_MASK(x) (KiB(x) - 1) 36 #define MiB_MASK(x) (MiB(x) - 1) 75 struct perf_event_mmap_page *pc;
77 bool cap_user_time_zero =
false;
90 if (err != -EOPNOTSUPP)
95 if (!cap_user_time_zero)
117 struct perf_evsel *evsel, *intel_bts_evsel = NULL;
125 if (evsel->
attr.type == intel_bts_pmu->
type) {
126 if (intel_bts_evsel) {
130 evsel->
attr.freq = 0;
131 evsel->
attr.sample_period = 1;
132 intel_bts_evsel = evsel;
175 pr_err(
"Snapshot size %zu must not be greater than AUX area tracing mmap size %zu\n",
181 pr_err(
"Failed to calculate default snapshot size and/or AUX area tracing mmap pages\n");
184 pr_debug2(
"Intel BTS snapshot size: %zu\n",
209 if (sz < min_sz || !is_power_of_2(sz)) {
210 pr_err(
"Invalid mmap size for Intel BTS: must be at least %zuKiB and a power of 2\n",
216 if (intel_bts_evsel) {
243 tracking_evsel->
attr.freq = 0;
244 tracking_evsel->
attr.sample_period = 1;
260 snapshot_size = strtoull(str, &endptr, 0);
261 if (*endptr || snapshot_size > SIZE_MAX)
288 while (new_cnt <= idx)
291 refs = calloc(new_cnt, sz);
356 for (i = a; i < b; i++) {
373 pr_debug3(
"%s: mmap index %d old head %zu new head %zu\n",
374 __func__, idx, (
size_t)*old, (
size_t)*head);
406 pr_debug3(
"%s: wrap-around %sdetected, adjusted old head %zu adjusted new head %zu\n",
407 __func__, wrapped ?
"" :
"not ", (
size_t)*old, (
size_t)*head);
412 pr_err(
"%s: failed, error %d\n", __func__, err);
438 if (setenv(
"JITDUMP_USE_ARCH_TIMESTAMP",
"1", 1)) {
size_t auxtrace_snapshot_size
#define INTEL_BTS_PMU_NAME
struct perf_evlist * evlist
int(* snapshot_start)(struct auxtrace_record *itr)
static int intel_bts_find_snapshot(struct auxtrace_record *itr, int idx, struct auxtrace_mmap *mm, unsigned char *data, u64 *head, u64 *old)
static void intel_bts_recording_free(struct auxtrace_record *itr)
int ui__warning(const char *format,...)
int(* snapshot_finish)(struct auxtrace_record *itr)
#define pr_debug2(fmt,...)
size_t(* info_priv_size)(struct auxtrace_record *itr, struct perf_evlist *evlist)
static void intel_bts_free_snapshot_refs(struct intel_bts_recording *btsr)
#define perf_evsel__set_sample_bit(evsel, bit)
struct perf_evlist * evlist
static u64 intel_bts_reference(struct auxtrace_record *itr __maybe_unused)
int perf_evsel__disable(struct perf_evsel *evsel)
int parse_events(struct perf_evlist *evlist, const char *str, struct parse_events_error *err)
void perf_evlist__set_tracking_event(struct perf_evlist *evlist, struct perf_evsel *tracking_evsel)
int(* read_finish)(struct auxtrace_record *itr, int idx)
static bool intel_bts_first_wrap(u64 *data, size_t buf_size)
static size_t intel_bts_info_priv_size(struct auxtrace_record *itr __maybe_unused, struct perf_evlist *evlist __maybe_unused)
u64(* reference)(struct auxtrace_record *itr)
static int intel_bts_snapshot_start(struct auxtrace_record *itr)
static struct perf_session * session
#define evlist__for_each_entry(evlist, evsel)
static bool cpu_map__empty(const struct cpu_map *map)
void(* free)(struct auxtrace_record *itr)
static int intel_bts_recording_options(struct auxtrace_record *itr, struct perf_evlist *evlist, struct record_opts *opts)
int(* recording_options)(struct auxtrace_record *itr, struct perf_evlist *evlist, struct record_opts *opts)
static int intel_bts_snapshot_finish(struct auxtrace_record *itr)
static int str(yyscan_t scanner, int token)
static int intel_bts_read_finish(struct auxtrace_record *itr, int idx)
void perf_evlist__to_front(struct perf_evlist *evlist, struct perf_evsel *move_evsel)
x86 movsq based memcpy() in arch/x86/lib/memcpy_64.S") MEMCPY_FN(memcpy_erms
int(* parse_snapshot_options)(struct auxtrace_record *itr, struct record_opts *opts, const char *str)
int perf_event_paranoid(void)
int(* find_snapshot)(struct auxtrace_record *itr, int idx, struct auxtrace_mmap *mm, unsigned char *data, u64 *head, u64 *old)
bool auxtrace_snapshot_mode
struct perf_pmu * perf_pmu__find(const char *name)
static int intel_bts_alloc_snapshot_refs(struct intel_bts_recording *btsr, int idx)
int perf_evsel__enable(struct perf_evsel *evsel)
struct auxtrace_record * intel_bts_recording_init(int *err)
struct intel_bts_snapshot_ref * snapshot_refs
static int intel_bts_info_fill(struct auxtrace_record *itr, struct perf_session *session, struct auxtrace_info_event *auxtrace_info, size_t priv_size)
struct auxtrace_record itr
static struct perf_evsel * perf_evlist__last(struct perf_evlist *evlist)
#define INTEL_BTS_AUXTRACE_PRIV_SIZE
struct perf_pmu * intel_bts_pmu
static int intel_bts_parse_snapshot_options(struct auxtrace_record *itr, struct record_opts *opts, const char *str)
unsigned int auxtrace_mmap_pages
int(* info_fill)(struct auxtrace_record *itr, struct perf_session *session, struct auxtrace_info_event *auxtrace_info, size_t priv_size)
#define pr_debug3(fmt,...)
int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, struct perf_tsc_conversion *tc)
struct perf_event_attr attr
int perf_evlist__enable_event_idx(struct perf_evlist *evlist, struct perf_evsel *evsel, int idx)
void static void * zalloc(size_t size)