Skip to contentSkip to conversation

oprofile, x86: Move memory allocation to init

PATCH In review Maarten Lankhorst 1 participant 2 messages Jul 31, 2011 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oprofile, x86: Move memory allocation to init

ppro_setup_ctrs is called on all cpu's, while init is only called once.

---
Fixes oprofile on 3.0 rt6.

arch/x86/oprofile/op_model_ppro.c +8 -10
index 94b7450..53a84fc 100644
@@ -79,13 +79,6 @@ static void ppro_setup_ctrs(struct op_x86_model_spec const *model,
 	u64 val;
 	int i;
 
-	if (!reset_value) {
-		reset_value = kzalloc(sizeof(reset_value[0]) * num_counters,
-					GFP_ATOMIC);
-		if (!reset_value)
-			return;
-	}
-
 	if (cpu_has_arch_perfmon) {
 		union cpuid10_eax eax;
 		eax.full = cpuid_eax(0xa);
@@ -228,7 +221,7 @@ struct op_x86_model_spec op_ppro_spec = {
  * the specific CPU.
  */
 
-static void arch_perfmon_setup_counters(void)
+static int arch_perfmon_setup_counters(void)
 {
 	union cpuid10_eax eax;
 
@@ -246,12 +239,17 @@ static void arch_perfmon_setup_counters(void)
 
 	op_arch_perfmon_spec.num_counters = num_counters;
 	op_arch_perfmon_spec.num_controls = num_counters;
+
+	reset_value = kzalloc(sizeof(reset_value[0]) * num_counters,
+				GFP_KERNEL);
+	if (!reset_value)
+		return -ENOMEM;
+	return 0;
 }
 
 static int arch_perfmon_init(struct oprofile_operations *ignore)
 {
-	arch_perfmon_setup_counters();
-	return 0;
+	return arch_perfmon_setup_counters();
 }
 
 struct op_x86_model_spec op_arch_perfmon_spec = {
#1 lore raw
Quoted 7 lines · Maarten Lankhorst

ppro_setup_ctrs is called on all cpu's, while init is only called once.

---
Fixes oprofile on 3.0 rt6.

Not correct for the PPRO case, will send a revised patch shortly. Also seems I cant do kfree on shutdown, so I'll do it on exit.