From 55baa2f831ae4a41da9617ab9e7cef5ebc991ec9 Mon Sep 17 00:00:00 2001 From: Hendrik Brueckner Date: Thu, 12 Dec 2013 16:47:00 +0100 Subject: [PATCH] s390/perf: Improve PMU selection for PERF_COUNT_HW_CPU_CYCLES events The cpum_cf (counter facility) PMU does not support sampling events. With cpum_sf (sampling facility), a PMU for sampling CPU cycles is available. Make cpum_sf the "default" PMU for PERF_COUNT_HW_CPU_CYCLES sampling events but use the more precise cpum_cf PMU for non-sampling events. Signed-off-by: Hendrik Brueckner Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/perf_cpum_sf.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c index 141eca0917f4..52bf36ee91aa 100644 --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -468,11 +468,29 @@ static int cpumsf_pmu_event_init(struct perf_event *event) { int err; - if (event->attr.type != PERF_TYPE_RAW) - return -ENOENT; + /* No support for taken branch sampling */ + if (has_branch_stack(event)) + return -EOPNOTSUPP; - if (event->attr.config != PERF_EVENT_CPUM_SF) + switch (event->attr.type) { + case PERF_TYPE_RAW: + if (event->attr.config != PERF_EVENT_CPUM_SF) + return -ENOENT; + break; + case PERF_TYPE_HARDWARE: + /* Support sampling of CPU cycles in addition to the + * counter facility. However, the counter facility + * is more precise and, hence, restrict this PMU to + * sampling events only. + */ + if (event->attr.config != PERF_COUNT_HW_CPU_CYCLES) + return -ENOENT; + if (!is_sampling_event(event)) + return -ENOENT; + break; + default: return -ENOENT; + } if (event->cpu >= nr_cpumask_bits || (event->cpu >= 0 && !cpu_online(event->cpu)))