COMPARE_EVENT_KEY(count, stats.n);
COMPARE_EVENT_KEY(mean, stats.mean);
-#define DEF_SORT_NAME_KEY(name, compare_key) \
- { #name, cmp_event_ ## compare_key }
-
-static struct kvm_event_key keys[] = {
- DEF_SORT_NAME_KEY(sample, count),
- DEF_SORT_NAME_KEY(time, mean),
- { NULL, NULL }
-};
-
struct kvm_hists {
struct hists hists;
struct perf_hpp_list list;
return true;
}
-static bool select_key(struct perf_kvm_stat *kvm)
+static bool is_valid_key(struct perf_kvm_stat *kvm)
{
- int i;
+ static const char *key_array[] = {
+ "ev_name", "sample", "time", "max_t", "min_t", "mean_t",
+ };
+ unsigned int i;
- for (i = 0; keys[i].name; i++) {
- if (!strcmp(keys[i].name, kvm->sort_key)) {
- kvm->compare = keys[i].key;
+ for (i = 0; i < ARRAY_SIZE(key_array); i++)
+ if (!strcmp(key_array[i], kvm->sort_key))
return true;
- }
- }
- pr_err("Unknown compare key:%s\n", kvm->sort_key);
+ pr_err("Unsupported sort key: %s\n", kvm->sort_key);
return false;
}
return ret;
if (!verify_vcpu(kvm->trace_vcpu) ||
- !select_key(kvm) ||
+ !is_valid_key(kvm) ||
!register_kvm_events_ops(kvm)) {
goto out;
}
if (!verify_vcpu(vcpu))
goto exit;
- if (!select_key(kvm))
+ if (!is_valid_key(kvm))
goto exit;
if (!register_kvm_events_ops(kvm))
struct hist_entry he;
};
-typedef int64_t (*key_cmp_fun)(struct kvm_event*, struct kvm_event*, int);
-
-struct kvm_event_key {
- const char *name;
- key_cmp_fun key;
-};
-
struct child_event_ops {
void (*get_key)(struct evsel *evsel,
struct perf_sample *sample,
const char *exit_reasons_isa;
struct kvm_events_ops *events_ops;
- key_cmp_fun compare;
u64 total_time;
u64 total_count;