perf/x86/intel: Make cpuc allocations consistent
[muen/linux.git] / arch / x86 / events / core.c
index b684f0294f35d93bb5e7367a7d7903719c25c6a6..e2b1447192a888ffafb2883ddbdfbbd37c1e9315 100644 (file)
@@ -1995,7 +1995,7 @@ static int x86_pmu_commit_txn(struct pmu *pmu)
  */
 static void free_fake_cpuc(struct cpu_hw_events *cpuc)
 {
-       kfree(cpuc->shared_regs);
+       intel_cpuc_finish(cpuc);
        kfree(cpuc);
 }
 
@@ -2007,14 +2007,11 @@ static struct cpu_hw_events *allocate_fake_cpuc(void)
        cpuc = kzalloc(sizeof(*cpuc), GFP_KERNEL);
        if (!cpuc)
                return ERR_PTR(-ENOMEM);
-
-       /* only needed, if we have extra_regs */
-       if (x86_pmu.extra_regs) {
-               cpuc->shared_regs = allocate_shared_regs(cpu);
-               if (!cpuc->shared_regs)
-                       goto error;
-       }
        cpuc->is_fake = 1;
+
+       if (intel_cpuc_prepare(cpuc, cpu))
+               goto error;
+
        return cpuc;
 error:
        free_fake_cpuc(cpuc);