perf: add struct hw_perf_event

Change-Id: I0938e2b18064ad805a9edb6e15d26cf438bf0a59
This commit is contained in:
TOIDA,Suguru
2019-11-19 09:31:49 +09:00
parent 767792808a
commit 86c45484e3
5 changed files with 81 additions and 0 deletions

View File

@ -4519,6 +4519,7 @@ static int mc_perf_event_alloc(struct mc_perf_event **out,
unsigned long val = 0, extra_config = 0;
struct mc_perf_event *event = NULL;
int ereg_id;
struct hw_perf_event *hwc;
if (!attr) {
ret = -EINVAL;
@ -4542,6 +4543,21 @@ static int mc_perf_event_alloc(struct mc_perf_event **out,
event->child_count_total = 0;
event->parent = NULL;
hwc = &event->hw;
hwc->sample_period = attr->sample_period;
if (attr->freq && attr->sample_freq) {
/*
* Mark struct perf_event_attr::sample_freq is set by user.
* Note that it's okay to use
* struct hw_perf_event::sample_period for this purpose
* because it's not union and not used when
* struct perf_event_attr::freq is one.
*/
hwc->sample_period = 1;
}
hwc->last_period = hwc->sample_period;
ihk_atomic64_set(&hwc->period_left, hwc->sample_period);
if (attr->type == PERF_TYPE_HARDWARE &&
attr->config == PERF_COUNT_HW_REF_CPU_CYCLES) {
event->use_invariant_tsc = 1;
@ -4588,6 +4604,8 @@ static int mc_perf_event_alloc(struct mc_perf_event **out,
event->extra_reg.idx = ihk_mc_get_extra_reg_idx(ereg_id);
}
ret = hw_perf_event_init(event);
*out = event;
out:
@ -4646,6 +4664,14 @@ SYSCALL_DECLARE(perf_event_open)
not_supported_flag = 1;
}
if (attr->freq) {
not_supported_flag = 1;
} else {
if (attr->sample_period & (1ULL << 63)) {
return -EINVAL;
}
}
if (not_supported_flag) {
return -ENOENT;
}