Skip to contentSkip to conversation

x86/perf_count: update x86_pmu after WARN

PATCH Superseded Yinghai Lu 1 participant 5 messages Jun 28, 2009 – Jun 29, 2009 x86

lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/1 x86/perf_count: update x86_pmu after WARN

should print out before changing the value

[Impact: get right print when clipping num_conunters]

---
 arch/x86/kernel/cpu/perf_counter.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +2 -2
Index: linux-2.6/arch/x86/kernel/cpu/perf_counter.c
===================================================================
@@ -1496,17 +1496,17 @@ void __init init_hw_perf_counters(void)
     pr_cont("%s PMU driver.\n", x86_pmu.name);
 
     if (x86_pmu.num_counters > X86_PMC_MAX_GENERIC) {
-        x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
         WARN(1, KERN_ERR "hw perf counters %d > max(%d), clipping!",
              x86_pmu.num_counters, X86_PMC_MAX_GENERIC);
+        x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
     }
     perf_counter_mask = (1 << x86_pmu.num_counters) - 1;
     perf_max_counters = x86_pmu.num_counters;
 
     if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) {
-        x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
         WARN(1, KERN_ERR "hw perf counters fixed %d > max(%d), clipping!",
              x86_pmu.num_counters_fixed, X86_PMC_MAX_FIXED);
+        x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
     }
 
     perf_counter_mask |=
author
#1 lore raw

PATCH 1/1 x86/perf_count: make perf_count_mask to local

only used in init_hw_per_counters

[Impact: cleanup]

---
 arch/x86/kernel/cpu/perf_counter.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +1 -2
Index: linux-2.6/arch/x86/kernel/cpu/perf_counter.c
===================================================================
@@ -25,8 +25,6 @@
 #include <asm/stacktrace.h>
 #include <asm/nmi.h>
 
-static u64 perf_counter_mask __read_mostly;
-
 struct cpu_hw_counters {
 	struct perf_counter	*counters[X86_PMC_IDX_MAX];
 	unsigned long		used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
@@ -1474,6 +1472,7 @@ static int amd_pmu_init(void)
 
 void __init init_hw_perf_counters(void)
 {
+	u64 perf_counter_mask;
 	int err;
 
 	pr_info("Performance Counters: ");
author
#2 lore raw

PATCH 1/1 x86/perf_count: change intel_pmu and amd_pmu to initdata

In reply to Yinghai Lu

it is assigned to x86_pmu aka copied to x86_pmu
so change it to __initdata

[Impact: cleanup]

---
 arch/x86/kernel/cpu/perf_counter.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +2 -2
Index: linux-2.6/arch/x86/kernel/cpu/perf_counter.c
===================================================================
@@ -1351,7 +1351,7 @@ static __read_mostly struct notifier_blo
 	.priority		= 1
 };
 
-static struct x86_pmu intel_pmu = {
+static __initdata struct x86_pmu intel_pmu = {
 	.name			= "Intel",
 	.handle_irq		= intel_pmu_handle_irq,
 	.disable_all		= intel_pmu_disable_all,
@@ -1371,7 +1371,7 @@ static struct x86_pmu intel_pmu = {
 	.max_period		= (1ULL << 31) - 1,
 };
 
-static struct x86_pmu amd_pmu = {
+static __initdata struct x86_pmu amd_pmu = {
 	.name			= "AMD",
 	.handle_irq		= amd_pmu_handle_irq,
 	.disable_all		= amd_pmu_disable_all,
author
#3 lore raw

PATCH RESEND 1/1 x86/perf_count: update x86_pmu after WARN

In reply to Yinghai Lu

should print out before changing the value

[Impact: get right print when clipping num_conunters]

---
 arch/x86/kernel/cpu/perf_counter.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +2 -2
Index: linux-2.6/arch/x86/kernel/cpu/perf_counter.c
===================================================================
@@ -1496,17 +1496,17 @@ void __init init_hw_perf_counters(void)
 	pr_cont("%s PMU driver.\n", x86_pmu.name);
 
 	if (x86_pmu.num_counters > X86_PMC_MAX_GENERIC) {
-		x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
 		WARN(1, KERN_ERR "hw perf counters %d > max(%d), clipping!",
 		     x86_pmu.num_counters, X86_PMC_MAX_GENERIC);
+		x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
 	}
 	perf_counter_mask = (1 << x86_pmu.num_counters) - 1;
 	perf_max_counters = x86_pmu.num_counters;
 
 	if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) {
-		x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
 		WARN(1, KERN_ERR "hw perf counters fixed %d > max(%d), clipping!",
 		     x86_pmu.num_counters_fixed, X86_PMC_MAX_FIXED);
+		x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
 	}
 
 	perf_counter_mask |=
#4 lore raw

[tip:perfcounters/urgent] perf_counter, x86: Update x86_pmu after WARN()

Commit-ID:  4078c444cf667f018c3fc7ebf141131a2b7c9480
Gitweb:     http://git.kernel.org/tip/4078c444cf667f018c3fc7ebf141131a2b7c9480
Author:     Yinghai Lu <[email protected]>
AuthorDate: Mon, 29 Jun 2009 00:41:11 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 29 Jun 2009 10:19:25 +0200

perf_counter, x86: Update x86_pmu after WARN()

The print out should read the value before changing the value.

Cc Peter Zijlstra <[email protected]>

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/cpu/perf_counter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +2 -2
index b83474b..d4cf4ce 100644
@@ -1496,17 +1496,17 @@ void __init init_hw_perf_counters(void)
 	pr_cont("%s PMU driver.\n", x86_pmu.name);
 
 	if (x86_pmu.num_counters > X86_PMC_MAX_GENERIC) {
-		x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
 		WARN(1, KERN_ERR "hw perf counters %d > max(%d), clipping!",
 		     x86_pmu.num_counters, X86_PMC_MAX_GENERIC);
+		x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
 	}
 	perf_counter_mask = (1 << x86_pmu.num_counters) - 1;
 	perf_max_counters = x86_pmu.num_counters;
 
 	if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) {
-		x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
 		WARN(1, KERN_ERR "hw perf counters fixed %d > max(%d), clipping!",
 		     x86_pmu.num_counters_fixed, X86_PMC_MAX_FIXED);
+		x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
 	}
 
 	perf_counter_mask |=