Lines Matching +full:sample +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0
5 #include "util/build-id.h"
16 #include <subcmd/parse-options.h>
17 #include "util/trace-event.h"
21 #include "util/synthetic-events.h"
24 #include "util/ordered-events.h"
25 #include "util/kvm-stat.h"
36 #include <sys/time.h>
59 if (vcpu == -1) \
60 return event->total.field; \
62 if (vcpu >= event->max_vcpu) \
65 return event->vcpu[vcpu].field; \
73 return get_event_ ##func(one, vcpu) - \
77 COMPARE_EVENT_KEY(time, time);
110 return -strcmp(left->kvm_info->name, right->kvm_info->name); in ev_name_cmp()
120 int width = fmt_width(fmt, hpp, he->hists); in ev_name_entry()
122 return scnprintf(hpp->buf, hpp->size, "%*s", width, he->kvm_info->name); in ev_name_entry()
145 perf_kvm = event_left->perf_kvm; \
147 perf_kvm->trace_vcpu); \
150 EV_METRIC_CMP(time)
162 int width = fmt_width(fmt, hpp, he->hists); \
166 perf_kvm = event->perf_kvm; \
167 return scnprintf(hpp->buf, hpp->size, "%*lu", width, \
168 get_event_##metric(event, perf_kvm->trace_vcpu)); \
171 EV_METRIC_ENTRY(time)
177 .header = "Time (ns)",
178 .name = "time",
186 .name = "sample",
193 .header = "Max Time (ns)",
201 .header = "Min Time (ns)",
212 int width = fmt_width(fmt, hpp, he->hists); in ev_entry_mean()
216 perf_kvm = event->perf_kvm; in ev_entry_mean()
217 return scnprintf(hpp->buf, hpp->size, "%*lu", width, in ev_entry_mean()
218 get_event_mean(event, perf_kvm->trace_vcpu)); in ev_entry_mean()
222 .header = "Mean Time (ns)",
247 perf_kvm = event->perf_kvm; \
249 return percent(get_event_##metric(event, perf_kvm->trace_vcpu), \
250 perf_kvm->total_##metric); \
253 EV_METRIC_PERCENT(time)
260 int width = fmt_width(fmt, hpp, he->hists); in EV_METRIC_PERCENT()
265 return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per)); in EV_METRIC_PERCENT()
278 return per_left - per_right; in ev_cmp_time_precent()
282 .header = "Time%",
293 int width = fmt_width(fmt, hpp, he->hists); in ev_entry_count_precent()
298 return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per)); in ev_entry_count_precent()
311 return per_left - per_right; in ev_cmp_count_precent()
315 .header = "Sample%",
341 return kvm_fmt->dim->width; in fmt_width()
353 dim = kvm_fmt->dim; in fmt_header()
355 return scnprintf(hpp->buf, hpp->size, "%*s", width, dim->header); in fmt_header()
363 return kvm_fmt_a->dim == kvm_fmt_b->dim; in fmt_equal()
379 if (!strcmp(dimensions[i]->name, name)) in get_dimension()
399 kvm_fmt->dim = dim; in get_format()
401 fmt = &kvm_fmt->fmt; in get_format()
402 INIT_LIST_HEAD(&fmt->list); in get_format()
403 INIT_LIST_HEAD(&fmt->sort_list); in get_format()
404 fmt->cmp = dim->cmp; in get_format()
405 fmt->sort = dim->cmp; in get_format()
406 fmt->color = NULL; in get_format()
407 fmt->entry = dim->entry; in get_format()
408 fmt->header = fmt_header; in get_format()
409 fmt->width = fmt_width; in get_format()
410 fmt->collapse = dim->cmp; in get_format()
411 fmt->equal = fmt_equal; in get_format()
412 fmt->free = fmt_free; in get_format()
423 return -EINVAL; in kvm_hists__init_output()
426 perf_hpp_list__column_register(hpp_list, &kvm_fmt->fmt); in kvm_hists__init_output()
436 return -EINVAL; in kvm_hists__init_sort()
439 perf_hpp_list__register_sort_field(hpp_list, &kvm_fmt->fmt); in kvm_hists__init_sort()
461 if (ret == -EINVAL) in kvm_hpp_list__init()
463 else if (ret == -ESRCH) in kvm_hpp_list__init()
518 struct rb_node *nd = rb_first_cached(&hb->hists->entries); in kvm_browser__update_nr_entries()
525 if (!he->filtered) in kvm_browser__update_nr_entries()
529 hb->nr_non_filtered_entries = nr_entries; in kvm_browser__update_nr_entries()
536 browser->nr_non_filtered_entries); in kvm_browser__title()
546 browser->title = kvm_browser__title; in perf_kvm_browser__new()
554 int key = -1; in kvm__hists_browse()
558 return -1; in kvm__hists_browse()
560 /* reset abort key so that it can get Ctrl-C as a key */ in kvm__hists_browse()
567 key = hist_browser__run(browser, "? - help", true, 0); in kvm__hists_browse()
619 struct perf_sample *sample, in exit_event_get_key() argument
622 key->info = 0; in exit_event_get_key()
623 key->key = evsel__intval(evsel, sample, kvm_exit_reason); in exit_event_get_key()
632 struct perf_sample *sample, struct event_key *key) in exit_event_begin() argument
635 exit_event_get_key(evsel, sample, key); in exit_event_begin()
648 struct perf_sample *sample __maybe_unused, in exit_event_end()
658 while (tbl->reason != NULL) { in get_exit_reason()
659 if (tbl->exit_code == exit_code) in get_exit_reason()
660 return tbl->reason; in get_exit_reason()
665 (unsigned long long)exit_code, kvm->exit_reasons_isa); in get_exit_reason()
673 const char *exit_reason = get_exit_reason(kvm, key->exit_reasons, in exit_event_decode_key()
674 key->key); in exit_event_decode_key()
683 for (events_ops = kvm_reg_events_ops; events_ops->name; events_ops++) { in register_kvm_events_ops()
684 if (!strcmp(events_ops->name, kvm->report_event)) { in register_kvm_events_ops()
685 kvm->events_ops = events_ops->ops; in register_kvm_events_ops()
719 event->total.time = 0; in clear_events_cache_stats()
720 init_stats(&event->total.stats); in clear_events_cache_stats()
722 for (i = 0; i < event->max_vcpu; ++i) { in clear_events_cache_stats()
723 event->vcpu[i].time = 0; in clear_events_cache_stats()
724 init_stats(&event->vcpu[i].stats); in clear_events_cache_stats()
732 int old_max_vcpu = event->max_vcpu; in kvm_event_expand()
735 if (vcpu_id < event->max_vcpu) in kvm_event_expand()
738 while (event->max_vcpu <= vcpu_id) in kvm_event_expand()
739 event->max_vcpu += DEFAULT_VCPU_NUM; in kvm_event_expand()
741 prev = event->vcpu; in kvm_event_expand()
742 event->vcpu = realloc(event->vcpu, in kvm_event_expand()
743 event->max_vcpu * sizeof(*event->vcpu)); in kvm_event_expand()
744 if (!event->vcpu) { in kvm_event_expand()
750 memset(event->vcpu + old_max_vcpu, 0, in kvm_event_expand()
751 (event->max_vcpu - old_max_vcpu) * sizeof(*event->vcpu)); in kvm_event_expand()
763 init_stats(&kvm_ev->total.stats); in kvm_he_zalloc()
765 return &kvm_ev->he; in kvm_he_zalloc()
783 struct perf_sample *sample) in find_create_kvm_event() argument
789 BUG_ON(key->key == INVALID_KEY); in find_create_kvm_event()
797 kvm->events_ops->decode_key(kvm, key, ki->name); in find_create_kvm_event()
799 &kvm->al, NULL, NULL, NULL, ki, sample, true); in find_create_kvm_event()
807 if (!event->perf_kvm) { in find_create_kvm_event()
808 event->perf_kvm = kvm; in find_create_kvm_event()
809 event->key = *key; in find_create_kvm_event()
818 struct perf_sample *sample) in handle_begin_event() argument
822 if (key->key != INVALID_KEY) in handle_begin_event()
823 event = find_create_kvm_event(kvm, key, sample); in handle_begin_event()
825 vcpu_record->last_event = event; in handle_begin_event()
826 vcpu_record->start_time = sample->time; in handle_begin_event()
833 kvm_stats->time += time_diff; in kvm_update_event_stats()
834 update_stats(&kvm_stats->stats, time_diff); in kvm_update_event_stats()
839 struct kvm_event_stats *kvm_stats = &event->total; in kvm_event_rel_stddev()
841 if (vcpu_id != -1) in kvm_event_rel_stddev()
842 kvm_stats = &event->vcpu[vcpu_id]; in kvm_event_rel_stddev()
844 return rel_stddev_stats(stddev_stats(&kvm_stats->stats), in kvm_event_rel_stddev()
845 avg_stats(&kvm_stats->stats)); in kvm_event_rel_stddev()
853 kvm->total_count++; in update_kvm_event()
854 kvm->total_time += time_diff; in update_kvm_event()
856 if (vcpu_id == -1) { in update_kvm_event()
857 kvm_update_event_stats(&event->total, time_diff); in update_kvm_event()
864 kvm_update_event_stats(&event->vcpu[vcpu_id], time_diff); in update_kvm_event()
870 struct perf_sample *sample, in is_child_event() argument
875 child_ops = kvm->events_ops->child_ops; in is_child_event()
880 for (; child_ops->name; child_ops++) { in is_child_event()
881 if (evsel__name_is(evsel, child_ops->name)) { in is_child_event()
882 child_ops->get_key(evsel, sample, key); in is_child_event()
893 struct perf_sample *sample) in handle_child_event() argument
897 if (key->key != INVALID_KEY) in handle_child_event()
898 event = find_create_kvm_event(kvm, key, sample); in handle_child_event()
900 vcpu_record->last_event = event; in handle_child_event()
919 struct perf_sample *sample) in handle_end_event() argument
925 if (kvm->trace_vcpu == -1) in handle_end_event()
926 vcpu = -1; in handle_end_event()
928 vcpu = vcpu_record->vcpu_id; in handle_end_event()
930 event = vcpu_record->last_event; in handle_end_event()
931 time_begin = vcpu_record->start_time; in handle_end_event()
939 * the actual event is recognized in the 'end event' (e.g. mmio-event). in handle_end_event()
943 if (!event && key->key == INVALID_KEY) in handle_end_event()
947 event = find_create_kvm_event(kvm, key, sample); in handle_end_event()
952 vcpu_record->last_event = NULL; in handle_end_event()
953 vcpu_record->start_time = 0; in handle_end_event()
956 if (sample->time < time_begin) { in handle_end_event()
957 pr_debug("End time before begin time; skipping event.\n"); in handle_end_event()
961 time_diff = sample->time - time_begin; in handle_end_event()
963 if (kvm->duration && time_diff > kvm->duration) { in handle_end_event()
966 kvm->events_ops->decode_key(kvm, &event->key, decode); in handle_end_event()
969 sample->time, sample->pid, vcpu_record->vcpu_id, in handle_end_event()
980 struct perf_sample *sample) in per_vcpu_record() argument
992 vcpu_record->vcpu_id = evsel__intval(evsel, sample, vcpu_id_str); in per_vcpu_record()
1002 struct perf_sample *sample) in handle_kvm_event() argument
1006 .exit_reasons = kvm->exit_reasons }; in handle_kvm_event()
1008 vcpu_record = per_vcpu_record(thread, evsel, sample); in handle_kvm_event()
1013 if ((kvm->trace_vcpu != -1) && in handle_kvm_event()
1014 (kvm->trace_vcpu != vcpu_record->vcpu_id)) in handle_kvm_event()
1017 if (kvm->events_ops->is_begin_event(evsel, sample, &key)) in handle_kvm_event()
1018 return handle_begin_event(kvm, vcpu_record, &key, sample); in handle_kvm_event()
1020 if (is_child_event(kvm, evsel, sample, &key)) in handle_kvm_event()
1021 return handle_child_event(kvm, vcpu_record, &key, sample); in handle_kvm_event()
1023 if (kvm->events_ops->is_end_event(evsel, sample, &key)) in handle_kvm_event()
1024 return handle_end_event(kvm, vcpu_record, &key, sample); in handle_kvm_event()
1032 "ev_name", "sample", "time", "max_t", "min_t", "mean_t", in is_valid_key()
1037 if (!strcmp(key_array[i], kvm->sort_key)) in is_valid_key()
1040 pr_err("Unsupported sort key: %s\n", kvm->sort_key); in is_valid_key()
1055 perf_kvm = event->perf_kvm; in filter_cb()
1056 if (!event_is_valid(event, perf_kvm->trace_vcpu)) in filter_cb()
1057 he->filtered = 1; in filter_cb()
1059 he->filtered = 0; in filter_cb()
1066 const char *output_columns = "ev_name,sample,percent_sample," in sort_result()
1067 "time,percent_time,max_t,min_t,mean_t"; in sort_result()
1069 kvm_hists__reinit(output_columns, kvm->sort_key); in sort_result()
1078 int vcpu = kvm->trace_vcpu; in print_vcpu_info()
1082 if (kvm->opts.target.system_wide) in print_vcpu_info()
1084 else if (kvm->opts.target.pid) in print_vcpu_info()
1085 pr_info("pid(s) %s, ", kvm->opts.target.pid); in print_vcpu_info()
1089 if (vcpu == -1) in print_vcpu_info()
1115 int vcpu = kvm->trace_vcpu; in print_result()
1118 if (kvm->live) { in print_result()
1125 pr_info("%*s ", KVM_EVENT_NAME_LEN, kvm->events_ops->name); in print_result()
1129 pr_info("%9s ", "Time%"); in print_result()
1130 pr_info("%11s ", "Min Time"); in print_result()
1131 pr_info("%11s ", "Max Time"); in print_result()
1132 pr_info("%16s ", "Avg time"); in print_result()
1140 if (he->filtered) in print_result()
1149 kvm->events_ops->decode_key(kvm, &event->key, decode); in print_result()
1152 pr_info("%8.2f%% ", (double)ecount / kvm->total_count * 100); in print_result()
1153 pr_info("%8.2f%% ", (double)etime / kvm->total_time * 100); in print_result()
1156 pr_info("%9.2fus ( +-%7.2f%% )", (double)etime / ecount / NSEC_PER_USEC, in print_result()
1161 pr_info("\nTotal Samples:%" PRIu64 ", Total events handled time:%.2fus.\n\n", in print_result()
1162 kvm->total_count, kvm->total_time / (double)NSEC_PER_USEC); in print_result()
1164 if (kvm->lost_events) in print_result()
1165 pr_info("\nLost events: %" PRIu64 "\n\n", kvm->lost_events); in print_result()
1171 struct perf_sample *sample __maybe_unused, in process_lost_event()
1176 kvm->lost_events++; in process_lost_event()
1182 struct perf_sample *sample) in skip_sample() argument
1184 if (kvm->pid_list && intlist__find(kvm->pid_list, sample->pid) == NULL) in skip_sample()
1192 struct perf_sample *sample, in process_sample_event() argument
1201 if (skip_sample(kvm, sample)) in process_sample_event()
1204 if (machine__resolve(machine, &kvm->al, sample) < 0) { in process_sample_event()
1205 pr_warning("Fail to resolve address location, skip sample.\n"); in process_sample_event()
1209 thread = machine__findnew_thread(machine, sample->pid, sample->tid); in process_sample_event()
1212 event->header.type); in process_sample_event()
1213 return -1; in process_sample_event()
1216 if (!handle_kvm_event(kvm, thread, evsel, sample)) in process_sample_event()
1217 err = -1; in process_sample_event()
1228 if (kvm->live) { in cpu_isa_config()
1233 return -err; in cpu_isa_config()
1237 cpuid = kvm->session->header.env.cpuid; in cpu_isa_config()
1241 return -EINVAL; in cpu_isa_config()
1245 if (err == -ENOTSUP) in cpu_isa_config()
1253 if (vcpu != -1 && vcpu < 0) { in verify_vcpu()
1270 struct evlist *evlist = kvm->evlist; in perf_kvm__mmap_read_idx()
1278 md = &evlist->mmap[idx]; in perf_kvm__mmap_read_idx()
1279 err = perf_mmap__read_init(&md->core); in perf_kvm__mmap_read_idx()
1281 return (err == -EAGAIN) ? 0 : -1; in perf_kvm__mmap_read_idx()
1283 while ((event = perf_mmap__read_event(&md->core)) != NULL) { in perf_kvm__mmap_read_idx()
1286 perf_mmap__consume(&md->core); in perf_kvm__mmap_read_idx()
1287 pr_err("Failed to parse sample\n"); in perf_kvm__mmap_read_idx()
1288 return -1; in perf_kvm__mmap_read_idx()
1291 err = perf_session__queue_event(kvm->session, event, timestamp, 0, NULL); in perf_kvm__mmap_read_idx()
1296 perf_mmap__consume(&md->core); in perf_kvm__mmap_read_idx()
1299 pr_err("Failed to enqueue sample: %d\n", err); in perf_kvm__mmap_read_idx()
1300 return -1; in perf_kvm__mmap_read_idx()
1303 /* save time stamp of our first sample for this mmap */ in perf_kvm__mmap_read_idx()
1313 perf_mmap__read_done(&md->core); in perf_kvm__mmap_read_idx()
1323 for (i = 0; i < kvm->evlist->core.nr_mmaps; i++) { in perf_kvm__mmap_read()
1326 return -1; in perf_kvm__mmap_read()
1328 /* flush time is going to be the minimum of all the individual in perf_kvm__mmap_read()
1330 * from the last pass under our minimal start time -- that leaves in perf_kvm__mmap_read()
1345 struct ordered_events *oe = &kvm->session->ordered_events; in perf_kvm__mmap_read()
1347 oe->next_flush = flush_time; in perf_kvm__mmap_read()
1350 if (kvm->lost_events) in perf_kvm__mmap_read()
1352 kvm->lost_events); in perf_kvm__mmap_read()
1370 int rc = -1; in perf_kvm__timerfd_create()
1372 kvm->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); in perf_kvm__timerfd_create()
1373 if (kvm->timerfd < 0) { in perf_kvm__timerfd_create()
1378 new_value.it_value.tv_sec = kvm->display_time; in perf_kvm__timerfd_create()
1380 new_value.it_interval.tv_sec = kvm->display_time; in perf_kvm__timerfd_create()
1383 if (timerfd_settime(kvm->timerfd, 0, &new_value, NULL) != 0) { in perf_kvm__timerfd_create()
1385 close(kvm->timerfd); in perf_kvm__timerfd_create()
1399 rc = read(kvm->timerfd, &c, sizeof(uint64_t)); in perf_kvm__handle_timerfd()
1405 return -1; in perf_kvm__handle_timerfd()
1409 pr_err("Error reading timer fd - invalid size returned\n"); in perf_kvm__handle_timerfd()
1410 return -1; in perf_kvm__handle_timerfd()
1414 pr_debug("Missed timer beats: %" PRIu64 "\n", c-1); in perf_kvm__handle_timerfd()
1425 kvm->total_count = 0; in perf_kvm__handle_timerfd()
1426 kvm->total_time = 0; in perf_kvm__handle_timerfd()
1427 kvm->lost_events = 0; in perf_kvm__handle_timerfd()
1439 return -1; in fd_set_nonblock()
1443 pr_err("Failed to set non-block option on fd %d\n", fd); in fd_set_nonblock()
1444 return -1; in fd_set_nonblock()
1463 int nr_stdin, ret, err = -EINVAL; in kvm_events_live_report()
1467 kvm->live = true; in kvm_events_live_report()
1473 if (!verify_vcpu(kvm->trace_vcpu) || in kvm_events_live_report()
1488 err = -1; in kvm_events_live_report()
1492 if (evlist__add_pollfd(kvm->evlist, kvm->timerfd) < 0) in kvm_events_live_report()
1495 nr_stdin = evlist__add_pollfd(kvm->evlist, fileno(stdin)); in kvm_events_live_report()
1502 /* everything is good - enable the events and process */ in kvm_events_live_report()
1503 evlist__enable(kvm->evlist); in kvm_events_live_report()
1506 struct fdarray *fda = &kvm->evlist->core.pollfd; in kvm_events_live_report()
1517 if (fda->entries[nr_stdin].revents & POLLIN) in kvm_events_live_report()
1521 err = evlist__poll(kvm->evlist, 100); in kvm_events_live_report()
1524 evlist__disable(kvm->evlist); in kvm_events_live_report()
1534 if (kvm->timerfd >= 0) in kvm_events_live_report()
1535 close(kvm->timerfd); in kvm_events_live_report()
1543 int err, rc = -1; in kvm_live_open_events()
1545 struct evlist *evlist = kvm->evlist; in kvm_live_open_events()
1548 evlist__config(evlist, &kvm->opts, NULL); in kvm_live_open_events()
1555 struct perf_event_attr *attr = &pos->core.attr; in kvm_live_open_events()
1559 evsel__set_sample_bit(pos, TIME); in kvm_live_open_events()
1562 /* make sure these are *not*; want as small a sample as possible */ in kvm_live_open_events()
1568 attr->mmap = 0; in kvm_live_open_events()
1569 attr->comm = 0; in kvm_live_open_events()
1570 attr->task = 0; in kvm_live_open_events()
1572 attr->sample_period = 1; in kvm_live_open_events()
1574 attr->watermark = 0; in kvm_live_open_events()
1575 attr->wakeup_events = 1000; in kvm_live_open_events()
1578 attr->disabled = 1; in kvm_live_open_events()
1588 if (evlist__mmap(evlist, kvm->opts.mmap_pages) < 0) { in kvm_live_open_events()
1607 .path = kvm->file_name, in read_events()
1609 .force = kvm->force, in read_events()
1612 perf_tool__init(&kvm->tool, /*ordered_events=*/true); in read_events()
1613 kvm->tool.sample = process_sample_event; in read_events()
1614 kvm->tool.comm = perf_event__process_comm; in read_events()
1615 kvm->tool.namespaces = perf_event__process_namespaces; in read_events()
1617 kvm->session = perf_session__new(&file, &kvm->tool); in read_events()
1618 if (IS_ERR(kvm->session)) { in read_events()
1620 return PTR_ERR(kvm->session); in read_events()
1623 symbol__init(&kvm->session->header.env); in read_events()
1625 if (!perf_session__has_traces(kvm->session, "kvm record")) { in read_events()
1626 ret = -EINVAL; in read_events()
1638 ret = perf_session__process_events(kvm->session); in read_events()
1641 perf_session__delete(kvm->session); in read_events()
1647 if (kvm->opts.target.pid) { in parse_target_str()
1648 kvm->pid_list = intlist__new(kvm->opts.target.pid); in parse_target_str()
1649 if (kvm->pid_list == NULL) { in parse_target_str()
1651 return -EINVAL; in parse_target_str()
1660 int ret = -EINVAL; in kvm_events_report_vcpu()
1661 int vcpu = kvm->trace_vcpu; in kvm_events_report_vcpu()
1675 if (kvm->use_stdio) { in kvm_events_report_vcpu()
1702 return -ENOMEM; \
1718 "-R", in kvm_events_record()
1719 "-m", "1024", in kvm_events_record()
1720 "-c", "1", in kvm_events_record()
1744 return -ENOMEM; in kvm_events_record()
1750 rec_argv[i++] = "-e"; in kvm_events_record()
1754 rec_argv[i++] = STRDUP_FAIL_EXIT("-o"); in kvm_events_record()
1755 rec_argv[i++] = STRDUP_FAIL_EXIT(kvm->file_name); in kvm_events_record()
1762 set_option_flag(record_options, 'R', "raw-samples", PARSE_OPT_HIDDEN); in kvm_events_record()
1767 set_option_flag(record_options, 0, "call-graph", PARSE_OPT_DISABLED); in kvm_events_record()
1771 set_option_flag(record_options, 'n', "no-samples", PARSE_OPT_DISABLED); in kvm_events_record()
1772 set_option_flag(record_options, 'N', "no-buildid-cache", PARSE_OPT_DISABLED); in kvm_events_record()
1773 set_option_flag(record_options, 'B', "no-buildid", PARSE_OPT_DISABLED); in kvm_events_record()
1775 set_option_flag(record_options, 'b', "branch-any", PARSE_OPT_DISABLED); in kvm_events_record()
1776 set_option_flag(record_options, 'j', "branch-filter", PARSE_OPT_DISABLED); in kvm_events_record()
1788 OPT_STRING(0, "event", &kvm->report_event, "report event", in kvm_events_report()
1791 OPT_INTEGER(0, "vcpu", &kvm->trace_vcpu, in kvm_events_report()
1793 OPT_STRING('k', "key", &kvm->sort_key, "sort-key", in kvm_events_report()
1794 "key for sorting: sample(sort by samples number)" in kvm_events_report()
1795 " time (sort by avg time)"), in kvm_events_report()
1796 OPT_STRING('p', "pid", &kvm->opts.target.pid, "pid", in kvm_events_report()
1798 OPT_BOOLEAN('f', "force", &kvm->force, "don't complain, do it"), in kvm_events_report()
1799 OPT_BOOLEAN(0, "stdio", &kvm->use_stdio, "use the stdio interface"), in kvm_events_report()
1818 kvm->use_stdio = true; in kvm_events_report()
1821 if (!kvm->opts.target.pid) in kvm_events_report()
1822 kvm->opts.target.system_wide = true; in kvm_events_report()
1832 int err = -1; in kvm_live_event_list()
1884 OPT_STRING('p', "pid", &kvm->opts.target.pid, "pid", in kvm_events_live()
1886 OPT_CALLBACK('m', "mmap-pages", &kvm->opts.mmap_pages, "pages", in kvm_events_live()
1890 OPT_BOOLEAN('a', "all-cpus", &kvm->opts.target.system_wide, in kvm_events_live()
1891 "system-wide collection from all CPUs"), in kvm_events_live()
1892 OPT_UINTEGER('d', "display", &kvm->display_time, in kvm_events_live()
1893 "time in seconds between display updates"), in kvm_events_live()
1894 OPT_STRING(0, "event", &kvm->report_event, "report event", in kvm_events_live()
1897 OPT_INTEGER(0, "vcpu", &kvm->trace_vcpu, in kvm_events_live()
1899 OPT_STRING('k', "key", &kvm->sort_key, "sort-key", in kvm_events_live()
1900 "key for sorting: sample(sort by samples number)" in kvm_events_live()
1901 " time (sort by avg time)"), in kvm_events_live()
1902 OPT_U64(0, "duration", &kvm->duration, in kvm_events_live()
1906 OPT_UINTEGER(0, "proc-map-timeout", &proc_map_timeout, in kvm_events_live()
1920 perf_tool__init(&kvm->tool, /*ordered_events=*/true); in kvm_events_live()
1921 kvm->tool.sample = process_sample_event; in kvm_events_live()
1922 kvm->tool.comm = perf_event__process_comm; in kvm_events_live()
1923 kvm->tool.exit = perf_event__process_exit; in kvm_events_live()
1924 kvm->tool.fork = perf_event__process_fork; in kvm_events_live()
1925 kvm->tool.lost = process_lost_event; in kvm_events_live()
1926 kvm->tool.namespaces = perf_event__process_namespaces; in kvm_events_live()
1929 kvm->display_time = 1; in kvm_events_live()
1930 kvm->opts.user_interval = 1; in kvm_events_live()
1931 kvm->opts.mmap_pages = 512; in kvm_events_live()
1932 kvm->opts.target.uses_mmap = false; in kvm_events_live()
1933 kvm->opts.target.uid_str = NULL; in kvm_events_live()
1934 kvm->opts.target.uid = UINT_MAX; in kvm_events_live()
1948 kvm->duration *= NSEC_PER_USEC; /* convert usec to nsec */ in kvm_events_live()
1953 err = target__validate(&kvm->opts.target); in kvm_events_live()
1955 target__strerror(&kvm->opts.target, err, errbuf, BUFSIZ); in kvm_events_live()
1959 if (target__none(&kvm->opts.target)) in kvm_events_live()
1960 kvm->opts.target.system_wide = true; in kvm_events_live()
1972 kvm->evlist = kvm_live_event_list(); in kvm_events_live()
1973 if (kvm->evlist == NULL) { in kvm_events_live()
1974 err = -1; in kvm_events_live()
1978 if (evlist__create_maps(kvm->evlist, &kvm->opts.target) < 0) in kvm_events_live()
1984 kvm->session = perf_session__new(&data, &kvm->tool); in kvm_events_live()
1985 if (IS_ERR(kvm->session)) { in kvm_events_live()
1986 err = PTR_ERR(kvm->session); in kvm_events_live()
1989 kvm->session->evlist = kvm->evlist; in kvm_events_live()
1990 perf_session__set_id_hdr_size(kvm->session); in kvm_events_live()
1991 ordered_events__set_copy_on_queue(&kvm->session->ordered_events, true); in kvm_events_live()
1992 machine__synthesize_threads(&kvm->session->machines.host, &kvm->opts.target, in kvm_events_live()
1993 kvm->evlist->core.threads, true, false, 1); in kvm_events_live()
2001 perf_session__delete(kvm->session); in kvm_events_live()
2002 kvm->session = NULL; in kvm_events_live()
2003 evlist__delete(kvm->evlist); in kvm_events_live()
2026 .trace_vcpu = -1, in kvm_cmd_stat()
2028 .sort_key = "sample", in kvm_cmd_stat()
2038 return kvm_events_record(&kvm, argc - 1, argv + 1); in kvm_cmd_stat()
2041 return kvm_events_report(&kvm, argc - 1 , argv + 1); in kvm_cmd_stat()
2045 return kvm_events_live(&kvm, argc - 1 , argv + 1); in kvm_cmd_stat()
2066 return -EINVAL; in __cmd_record()
2071 rec_argv[i++] = strdup("-o"); in __cmd_record()
2089 rec_argv[i++] = strdup("-i"); in __cmd_report()
2107 rec_argv[i++] = strdup("buildid-list"); in __cmd_buildid_list()
2108 rec_argv[i++] = strdup("-i"); in __cmd_buildid_list()
2139 OPT_BOOLEAN(0, "guest-code", &symbol_conf.guest_code, in cmd_kvm()
2147 "buildid-list", "stat", NULL }; in cmd_kvm()
2166 return -ENOMEM; in cmd_kvm()
2178 else if (strlen(argv[0]) > 2 && strstarts("buildid-list", argv[0])) in cmd_kvm()