summaryrefslogtreecommitdiff
path: root/arch/s390/kernel/perf_cpum_sf.c
diff options
context:
space:
mode:
authorHendrik Brueckner <brueckner@linux.vnet.ibm.com>2013-12-12 16:52:48 +0100
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-12-16 14:37:52 +0100
commite28bb79d9935293a8eea5f3c771fde89db645ba7 (patch)
tree0d552a218e87c70ca55b5b103b5ef2a71477d400 /arch/s390/kernel/perf_cpum_sf.c
parent55baa2f831ae4a41da9617ab9e7cef5ebc991ec9 (diff)
s390/perf,oprofile: Share sampling facility
Introduce reserve/release functions to share the sampling facility between perf and oprofile. Also improve error handling for the sampling facility support in perf. Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/perf_cpum_sf.c')
-rw-r--r--arch/s390/kernel/perf_cpum_sf.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index 52bf36ee91aa..ae5e0192160d 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -260,16 +260,12 @@ static int sf_disable(void)
#define PMC_INIT 0
#define PMC_RELEASE 1
+#define PMC_FAILURE 2
static void setup_pmc_cpu(void *flags)
{
int err;
struct cpu_hw_sf *cpusf = &__get_cpu_var(cpu_hw_sf);
- /* XXX Improve error handling and pass a flag in the *flags
- * variable to indicate failures. Alternatively, ignore
- * (print) errors here and let the PMU functions fail if
- * the per-cpu PMU_F_RESERVED flag is not.
- */
err = 0;
switch (*((int *) flags)) {
case PMC_INIT:
@@ -299,6 +295,8 @@ static void setup_pmc_cpu(void *flags)
"setup_pmc_cpu: released: cpuhw=%p\n", cpusf);
break;
}
+ if (err)
+ *((int *) flags) |= PMC_FAILURE;
}
static void release_pmc_hardware(void)
@@ -307,13 +305,22 @@ static void release_pmc_hardware(void)
irq_subclass_unregister(IRQ_SUBCLASS_MEASUREMENT_ALERT);
on_each_cpu(setup_pmc_cpu, &flags, 1);
+ perf_release_sampling();
}
static int reserve_pmc_hardware(void)
{
int flags = PMC_INIT;
+ int err;
+ err = perf_reserve_sampling();
+ if (err)
+ return err;
on_each_cpu(setup_pmc_cpu, &flags, 1);
+ if (flags & PMC_FAILURE) {
+ release_pmc_hardware();
+ return -ENODEV;
+ }
irq_subclass_register(IRQ_SUBCLASS_MEASUREMENT_ALERT);
return 0;