Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1339993 > unrolled thread
| Started by | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| First post | 2016-02-22 23:30 +0100 |
| Last post | 2016-02-29 12:20 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[patch V3 19/28] x86/perf/intel/rapl: Add proper error handling Thomas Gleixner <tglx@linutronix.de> - 2016-02-22 23:30 +0100
[tip:perf/core] perf/x86/intel/rapl: Add proper error handling tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-02-29 12:20 +0100
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-02-22 23:30 +0100 |
| Subject | [patch V3 19/28] x86/perf/intel/rapl: Add proper error handling |
| Message-ID | <r579p-4ce-35@gated-at.bofh.it> |
Like uncore the rapl driver lacks error handling. It leaks memory and leaves
the hotplug notifier registered.
Add the proper error checks, cleanup the memory and register the hotplug
notifier only on success.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/kernel/cpu/perf_event_intel_rapl.c | 29 ++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
Index: b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
===================================================================
--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
@@ -686,6 +686,14 @@ static int rapl_check_hw_unit(void)
return 0;
}
+static void __init cleanup_rapl_pmus(void)
+{
+ int cpu;
+
+ for_each_online_cpu(cpu)
+ kfree(per_cpu(rapl_pmu, cpu));
+}
+
static const struct x86_cpu_id rapl_cpu_match[] = {
[0] = { .vendor = X86_VENDOR_INTEL, .family = 6 },
[1] = {},
@@ -702,7 +710,7 @@ static int __init rapl_pmu_init(void)
* check for Intel processor family 6
*/
if (!x86_match_cpu(rapl_cpu_match))
- return 0;
+ return -ENODEV;
/* check supported CPU */
switch (boot_cpu_data.x86_model) {
@@ -734,8 +742,9 @@ static int __init rapl_pmu_init(void)
break;
default:
/* unsupported */
- return 0;
+ return -ENODEV;
}
+
ret = rapl_check_hw_unit();
if (ret)
return ret;
@@ -743,6 +752,7 @@ static int __init rapl_pmu_init(void)
/* run cpu model quirks */
for (quirk = rapl_quirks; quirk; quirk = quirk->next)
quirk->func();
+
cpu_notifier_register_begin();
for_each_online_cpu(cpu) {
@@ -752,15 +762,14 @@ static int __init rapl_pmu_init(void)
rapl_cpu_init(cpu);
}
- __perf_cpu_notifier(rapl_cpu_notifier);
-
ret = perf_pmu_register(&rapl_pmu_class, "power", -1);
if (WARN_ON(ret)) {
pr_info("RAPL PMU detected, registration failed (%d), RAPL PMU disabled\n", ret);
- cpu_notifier_register_done();
- return -1;
+ goto out;
}
+ __perf_cpu_notifier(rapl_cpu_notifier);
+
pmu = __this_cpu_read(rapl_pmu);
pr_info("RAPL PMU detected,"
@@ -775,9 +784,13 @@ static int __init rapl_pmu_init(void)
rapl_domain_names[i], rapl_hw_unit[i]);
}
}
-out:
- cpu_notifier_register_done();
+ cpu_notifier_register_done();
return 0;
+
+out:
+ cleanup_rapl_pmus();
+ cpu_notifier_register_done();
+ return ret;
}
device_initcall(rapl_pmu_init);
[toc] | [next] | [standalone]
| From | tip-bot for Thomas Gleixner <tipbot@zytor.com> |
|---|---|
| Date | 2016-02-29 12:20 +0100 |
| Subject | [tip:perf/core] perf/x86/intel/rapl: Add proper error handling |
| Message-ID | <r7u1S-2ia-47@gated-at.bofh.it> |
| In reply to | #1339993 |
Commit-ID: 55f2890f0726fe4a1f41a3a0e72ca1a263f095c3
Gitweb: http://git.kernel.org/tip/55f2890f0726fe4a1f41a3a0e72ca1a263f095c3
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Mon, 22 Feb 2016 22:19:21 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 29 Feb 2016 09:35:22 +0100
perf/x86/intel/rapl: Add proper error handling
Like uncore the rapl driver lacks error handling. It leaks memory and leaves
the hotplug notifier registered.
Add the proper error checks, cleanup the memory and register the hotplug
notifier only on success.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Harish Chegondi <harish.chegondi@intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/20160222221012.231222076@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/events/intel/rapl.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index 536f0ce..98b04d2 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -686,6 +686,14 @@ static int rapl_check_hw_unit(void)
return 0;
}
+static void __init cleanup_rapl_pmus(void)
+{
+ int cpu;
+
+ for_each_online_cpu(cpu)
+ kfree(per_cpu(rapl_pmu, cpu));
+}
+
static const struct x86_cpu_id rapl_cpu_match[] = {
[0] = { .vendor = X86_VENDOR_INTEL, .family = 6 },
[1] = {},
@@ -702,7 +710,7 @@ static int __init rapl_pmu_init(void)
* check for Intel processor family 6
*/
if (!x86_match_cpu(rapl_cpu_match))
- return 0;
+ return -ENODEV;
/* check supported CPU */
switch (boot_cpu_data.x86_model) {
@@ -734,8 +742,9 @@ static int __init rapl_pmu_init(void)
break;
default:
/* unsupported */
- return 0;
+ return -ENODEV;
}
+
ret = rapl_check_hw_unit();
if (ret)
return ret;
@@ -743,6 +752,7 @@ static int __init rapl_pmu_init(void)
/* run cpu model quirks */
for (quirk = rapl_quirks; quirk; quirk = quirk->next)
quirk->func();
+
cpu_notifier_register_begin();
for_each_online_cpu(cpu) {
@@ -752,15 +762,14 @@ static int __init rapl_pmu_init(void)
rapl_cpu_init(cpu);
}
- __perf_cpu_notifier(rapl_cpu_notifier);
-
ret = perf_pmu_register(&rapl_pmu_class, "power", -1);
if (WARN_ON(ret)) {
pr_info("RAPL PMU detected, registration failed (%d), RAPL PMU disabled\n", ret);
- cpu_notifier_register_done();
- return -1;
+ goto out;
}
+ __perf_cpu_notifier(rapl_cpu_notifier);
+
pmu = __this_cpu_read(rapl_pmu);
pr_info("RAPL PMU detected,"
@@ -775,9 +784,13 @@ static int __init rapl_pmu_init(void)
rapl_domain_names[i], rapl_hw_unit[i]);
}
}
-out:
- cpu_notifier_register_done();
+ cpu_notifier_register_done();
return 0;
+
+out:
+ cleanup_rapl_pmus();
+ cpu_notifier_register_done();
+ return ret;
}
device_initcall(rapl_pmu_init);
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web