linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] x86, perf, uncore: Add support for ARB uncore PMU on Sandy/IvyBridge
@ 2015-06-15  5:57 Andi Kleen
  2015-06-15  5:57 ` [PATCH 2/3] x86, perf, uncore: Use Sandy Bridge client PMU on Haswell/Broadwell Andi Kleen
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Andi Kleen @ 2015-06-15  5:57 UTC (permalink / raw)
  To: peterz; +Cc: eranian, linux-kernel, kan.liang, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Add a new "ARB" uncore PMU that is used to monitor the uncore queue
arbiter. This is useful to measure uncore queue occupancy and similar
statistics. The registers all have the same format as the
existing CBOX PMU.

Also move the event constraints from the CBOX to ARB. The 0x80+
events are ARB events and cannot be scheduled on a CBOX PMU.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
index 4562e9e..3eff721 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
@@ -44,6 +44,11 @@
 #define SNB_UNC_CBO_0_PER_CTR0                  0x706
 #define SNB_UNC_CBO_MSR_OFFSET                  0x10
 
+/* SNB ARB register */
+#define SNB_UNC_ARB_PER_CTR0			0x3b0
+#define SNB_UNC_ARB_PERFEVTSEL0			0x3b2
+#define SNB_UNC_ARB_MSR_OFFSET			0x10
+
 /* NHM global control register */
 #define NHM_UNC_PERF_GLOBAL_CTL                 0x391
 #define NHM_UNC_FIXED_CTR                       0x394
@@ -114,7 +119,7 @@ static struct intel_uncore_ops snb_uncore_msr_ops = {
 	.read_counter	= uncore_msr_read_counter,
 };
 
-static struct event_constraint snb_uncore_cbox_constraints[] = {
+static struct event_constraint snb_uncore_arb_constraints[] = {
 	UNCORE_EVENT_CONSTRAINT(0x80, 0x1),
 	UNCORE_EVENT_CONSTRAINT(0x83, 0x1),
 	EVENT_CONSTRAINT_END
@@ -133,14 +138,28 @@ static struct intel_uncore_type snb_uncore_cbox = {
 	.single_fixed	= 1,
 	.event_mask	= SNB_UNC_RAW_EVENT_MASK,
 	.msr_offset	= SNB_UNC_CBO_MSR_OFFSET,
-	.constraints	= snb_uncore_cbox_constraints,
 	.ops		= &snb_uncore_msr_ops,
 	.format_group	= &snb_uncore_format_group,
 	.event_descs	= snb_uncore_events,
 };
 
+static struct intel_uncore_type snb_uncore_arb = {
+	.name		= "arb",
+	.num_counters   = 2,
+	.num_boxes	= 1,
+	.perf_ctr_bits	= 44,
+	.perf_ctr	= SNB_UNC_ARB_PER_CTR0,
+	.event_ctl	= SNB_UNC_ARB_PERFEVTSEL0,
+	.event_mask	= SNB_UNC_RAW_EVENT_MASK,
+	.msr_offset	= SNB_UNC_ARB_MSR_OFFSET,
+	.constraints	= snb_uncore_arb_constraints,
+	.ops		= &snb_uncore_msr_ops,
+	.format_group	= &snb_uncore_format_group,
+};
+
 static struct intel_uncore_type *snb_msr_uncores[] = {
 	&snb_uncore_cbox,
+	&snb_uncore_arb,
 	NULL,
 };
 
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/3] x86, perf, uncore: Use Sandy Bridge client PMU on Haswell/Broadwell
  2015-06-15  5:57 [PATCH 1/3] x86, perf, uncore: Add support for ARB uncore PMU on Sandy/IvyBridge Andi Kleen
@ 2015-06-15  5:57 ` Andi Kleen
  2015-08-04  8:52   ` [tip:perf/core] perf/x86/intel/uncore: " tip-bot for Andi Kleen
  2015-06-15  5:57 ` [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore Andi Kleen
  2015-08-04  8:52 ` [tip:perf/core] perf/x86/intel/uncore: Add support for ARB uncore PMU on Sandy/IvyBridge tip-bot for Andi Kleen
  2 siblings, 1 reply; 11+ messages in thread
From: Andi Kleen @ 2015-06-15  5:57 UTC (permalink / raw)
  To: peterz; +Cc: eranian, linux-kernel, kan.liang, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Haswell and Broadwell have the same uncore CBOX/ARB PMU as Sandy Bridge.
Add the respective model numbers to enable the SNB uncore PMU.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index dd319e5..b57a09d 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -1202,6 +1202,11 @@ static int __init uncore_cpu_init(void)
 		break;
 	case 42: /* Sandy Bridge */
 	case 58: /* Ivy Bridge */
+	case 60: /* Haswell */
+	case 69: /* Haswell */
+	case 70: /* Haswell */
+	case 61: /* Broadwell */
+	case 71: /* Broadwell */
 		snb_uncore_cpu_init();
 		break;
 	case 45: /* Sandy Bridge-EP */
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore
  2015-06-15  5:57 [PATCH 1/3] x86, perf, uncore: Add support for ARB uncore PMU on Sandy/IvyBridge Andi Kleen
  2015-06-15  5:57 ` [PATCH 2/3] x86, perf, uncore: Use Sandy Bridge client PMU on Haswell/Broadwell Andi Kleen
@ 2015-06-15  5:57 ` Andi Kleen
  2015-06-16 12:06   ` Thomas Gleixner
  2015-08-04  8:52 ` [tip:perf/core] perf/x86/intel/uncore: Add support for ARB uncore PMU on Sandy/IvyBridge tip-bot for Andi Kleen
  2 siblings, 1 reply; 11+ messages in thread
From: Andi Kleen @ 2015-06-15  5:57 UTC (permalink / raw)
  To: peterz; +Cc: eranian, linux-kernel, kan.liang, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Several sytems, such as my laptop, don't expose the PCI devices
for the PCI uncore measurements. But the MSRs for the CBOX and ARB
uncores are always available. Currently the init code doesn't
initialize the MSR uncores when the PCI uncore registration fails.
Stop it from doing that and always try to register the MSR uncores.

This makes the pci uncore exit function unused. We'll need it later
when the uncore becomes modular, so instead of removing it I just
marked it with module_exit right now (which discards it)

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index b57a09d..6359309 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -952,6 +952,8 @@ static void __init uncore_pci_exit(void)
 		uncore_types_exit(uncore_pci_uncores);
 	}
 }
+module_exit(uncore_pci_exit);
+/* XXX: need exit code for MSR uncores too */
 
 /* CPU hot plug/unplug are serialized by cpu_add_remove_lock mutex */
 static LIST_HEAD(boxes_to_free);
@@ -1287,27 +1289,17 @@ static void __init uncore_cpumask_init(void)
 
 static int __init intel_uncore_init(void)
 {
-	int ret;
-
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
 		return -ENODEV;
 
 	if (cpu_has_hypervisor)
 		return -ENODEV;
 
-	ret = uncore_pci_init();
-	if (ret)
-		goto fail;
-	ret = uncore_cpu_init();
-	if (ret) {
-		uncore_pci_exit();
-		goto fail;
-	}
+	uncore_pci_init();
+	uncore_cpu_init();
 	uncore_cpumask_init();
 
 	uncore_pmus_register();
 	return 0;
-fail:
-	return ret;
 }
 device_initcall(intel_uncore_init);
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore
  2015-06-15  5:57 ` [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore Andi Kleen
@ 2015-06-16 12:06   ` Thomas Gleixner
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Gleixner @ 2015-06-16 12:06 UTC (permalink / raw)
  To: Andi Kleen; +Cc: peterz, eranian, linux-kernel, kan.liang, Andi Kleen

On Sun, 14 Jun 2015, Andi Kleen wrote:
> @@ -1287,27 +1289,17 @@ static void __init uncore_cpumask_init(void)
>  
>  static int __init intel_uncore_init(void)
>  {
> -	int ret;
> -
>  	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
>  		return -ENODEV;
>  
>  	if (cpu_has_hypervisor)
>  		return -ENODEV;
>  
> -	ret = uncore_pci_init();
> -	if (ret)
> -		goto fail;
> -	ret = uncore_cpu_init();
> -	if (ret) {
> -		uncore_pci_exit();
> -		goto fail;
> -	}
> +	uncore_pci_init();
> +	uncore_cpu_init();
>  	uncore_cpumask_init();

So, even if the cpu does not support that, we install a completely
useless cpu notifier and invoke equally pointless init code on all
cores.

Sigh,


	tglx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tip:perf/core] perf/x86/intel/uncore: Add support for ARB uncore PMU on Sandy/IvyBridge
  2015-06-15  5:57 [PATCH 1/3] x86, perf, uncore: Add support for ARB uncore PMU on Sandy/IvyBridge Andi Kleen
  2015-06-15  5:57 ` [PATCH 2/3] x86, perf, uncore: Use Sandy Bridge client PMU on Haswell/Broadwell Andi Kleen
  2015-06-15  5:57 ` [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore Andi Kleen
@ 2015-08-04  8:52 ` tip-bot for Andi Kleen
  2 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Andi Kleen @ 2015-08-04  8:52 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, tglx, mingo, hpa, ak, peterz, torvalds

Commit-ID:  e3a13192d86048e91a2a1d534abe5ac2397d9113
Gitweb:     http://git.kernel.org/tip/e3a13192d86048e91a2a1d534abe5ac2397d9113
Author:     Andi Kleen <ak@linux.intel.com>
AuthorDate: Sun, 14 Jun 2015 22:57:40 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 4 Aug 2015 10:16:52 +0200

perf/x86/intel/uncore: Add support for ARB uncore PMU on Sandy/IvyBridge

Add a new "ARB" uncore PMU that is used to monitor the uncore queue
arbiter. This is useful to measure uncore queue occupancy and similar
statistics. The registers all have the same format as the
existing CBOX PMU.

Also move the event constraints from the CBOX to ARB. The 0x80+
events are ARB events and cannot be scheduled on a CBOX PMU.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: eranian@google.com
Cc: kan.liang@intel.com
Link: http://lkml.kernel.org/r/1434347862-28490-1-git-send-email-andi@firstfloor.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
index b005a78..f78574b 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
@@ -45,6 +45,11 @@
 #define SNB_UNC_CBO_0_PER_CTR0                  0x706
 #define SNB_UNC_CBO_MSR_OFFSET                  0x10
 
+/* SNB ARB register */
+#define SNB_UNC_ARB_PER_CTR0			0x3b0
+#define SNB_UNC_ARB_PERFEVTSEL0			0x3b2
+#define SNB_UNC_ARB_MSR_OFFSET			0x10
+
 /* NHM global control register */
 #define NHM_UNC_PERF_GLOBAL_CTL                 0x391
 #define NHM_UNC_FIXED_CTR                       0x394
@@ -115,7 +120,7 @@ static struct intel_uncore_ops snb_uncore_msr_ops = {
 	.read_counter	= uncore_msr_read_counter,
 };
 
-static struct event_constraint snb_uncore_cbox_constraints[] = {
+static struct event_constraint snb_uncore_arb_constraints[] = {
 	UNCORE_EVENT_CONSTRAINT(0x80, 0x1),
 	UNCORE_EVENT_CONSTRAINT(0x83, 0x1),
 	EVENT_CONSTRAINT_END
@@ -134,14 +139,28 @@ static struct intel_uncore_type snb_uncore_cbox = {
 	.single_fixed	= 1,
 	.event_mask	= SNB_UNC_RAW_EVENT_MASK,
 	.msr_offset	= SNB_UNC_CBO_MSR_OFFSET,
-	.constraints	= snb_uncore_cbox_constraints,
 	.ops		= &snb_uncore_msr_ops,
 	.format_group	= &snb_uncore_format_group,
 	.event_descs	= snb_uncore_events,
 };
 
+static struct intel_uncore_type snb_uncore_arb = {
+	.name		= "arb",
+	.num_counters   = 2,
+	.num_boxes	= 1,
+	.perf_ctr_bits	= 44,
+	.perf_ctr	= SNB_UNC_ARB_PER_CTR0,
+	.event_ctl	= SNB_UNC_ARB_PERFEVTSEL0,
+	.event_mask	= SNB_UNC_RAW_EVENT_MASK,
+	.msr_offset	= SNB_UNC_ARB_MSR_OFFSET,
+	.constraints	= snb_uncore_arb_constraints,
+	.ops		= &snb_uncore_msr_ops,
+	.format_group	= &snb_uncore_format_group,
+};
+
 static struct intel_uncore_type *snb_msr_uncores[] = {
 	&snb_uncore_cbox,
+	&snb_uncore_arb,
 	NULL,
 };
 

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [tip:perf/core] perf/x86/intel/uncore: Use Sandy Bridge client PMU on Haswell/Broadwell
  2015-06-15  5:57 ` [PATCH 2/3] x86, perf, uncore: Use Sandy Bridge client PMU on Haswell/Broadwell Andi Kleen
@ 2015-08-04  8:52   ` tip-bot for Andi Kleen
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Andi Kleen @ 2015-08-04  8:52 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, ak, torvalds, tglx, hpa, mingo, peterz

Commit-ID:  3a999587b4a1815cf4dadddf6b5aad470f048239
Gitweb:     http://git.kernel.org/tip/3a999587b4a1815cf4dadddf6b5aad470f048239
Author:     Andi Kleen <ak@linux.intel.com>
AuthorDate: Sun, 14 Jun 2015 22:57:41 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 4 Aug 2015 10:16:53 +0200

perf/x86/intel/uncore: Use Sandy Bridge client PMU on Haswell/Broadwell

Haswell and Broadwell have the same uncore CBOX/ARB PMU as Sandy Bridge.
Add the respective model numbers to enable the SNB uncore PMU.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: eranian@google.com
Cc: kan.liang@intel.com
Link: http://lkml.kernel.org/r/1434347862-28490-2-git-send-email-andi@firstfloor.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 21b5e38..c2af967 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -1209,6 +1209,11 @@ static int __init uncore_cpu_init(void)
 		break;
 	case 42: /* Sandy Bridge */
 	case 58: /* Ivy Bridge */
+	case 60: /* Haswell */
+	case 69: /* Haswell */
+	case 70: /* Haswell */
+	case 61: /* Broadwell */
+	case 71: /* Broadwell */
 		snb_uncore_cpu_init();
 		break;
 	case 45: /* Sandy Bridge-EP */

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore
  2015-06-18 23:02 Another Haswell uncore patchkit Andi Kleen
@ 2015-06-18 23:02 ` Andi Kleen
  0 siblings, 0 replies; 11+ messages in thread
From: Andi Kleen @ 2015-06-18 23:02 UTC (permalink / raw)
  To: peterz; +Cc: linux-kernel, tglx, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Several sytems, such as my laptop, don't expose the PCI devices
for the PCI uncore measurements. But the MSRs for the CBOX and ARB
uncores are always available. Currently the init code doesn't
initialize the MSR uncores when the PCI uncore registration fails.
Stop it from doing that and always try to register the MSR uncores.

This makes the pci uncore exit function unused. We'll need it later
when the uncore becomes modular, so instead of removing it I just
marked it with module_exit right now (which discards it)

v2: Avoid registering notifier when both initialization calls fail
v3: Return error when both registrations fail.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index b57a09d..31ac78b 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -952,6 +952,8 @@ static void __init uncore_pci_exit(void)
 		uncore_types_exit(uncore_pci_uncores);
 	}
 }
+module_exit(uncore_pci_exit);
+/* XXX: need exit code for rest of intel_uncore_init too */
 
 /* CPU hot plug/unplug are serialized by cpu_add_remove_lock mutex */
 static LIST_HEAD(boxes_to_free);
@@ -1287,7 +1289,7 @@ static void __init uncore_cpumask_init(void)
 
 static int __init intel_uncore_init(void)
 {
-	int ret;
+	int ret1, ret2;
 
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
 		return -ENODEV;
@@ -1295,19 +1297,13 @@ static int __init intel_uncore_init(void)
 	if (cpu_has_hypervisor)
 		return -ENODEV;
 
-	ret = uncore_pci_init();
-	if (ret)
-		goto fail;
-	ret = uncore_cpu_init();
-	if (ret) {
-		uncore_pci_exit();
-		goto fail;
-	}
-	uncore_cpumask_init();
-
-	uncore_pmus_register();
+	ret1 = uncore_pci_init();
+	ret2 = uncore_cpu_init();
+	if (!ret1 || !ret2) {
+		uncore_cpumask_init();
+		uncore_pmus_register();
+	} else
+		return -ENODEV;
 	return 0;
-fail:
-	return ret;
 }
 device_initcall(intel_uncore_init);
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore
  2015-06-18 22:48     ` Andi Kleen
@ 2015-06-18 22:57       ` Thomas Gleixner
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Gleixner @ 2015-06-18 22:57 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Andi Kleen, peterz, linux-kernel

On Thu, 18 Jun 2015, Andi Kleen wrote:
> > One possible solution is to split the initcall and have one
> > for uncore_pci and one for uncode_msr, but that does not work well if
> > you want to make it a module.
> > 
> > But we should at least have some indication, what worked and what went
> > wrong instead of unconditionally returning success.
> 
> Nobody uses the return value for builtin drivers (short of one
> debug printk).

Which is a valuable tool to figure out WHY stuff does not work, which
you broke for a particular case.

> It would not load the module, but right now we don't have a module.

Though you keep the exit function around for making this modular. So
your argumentation does not make any sense at all.

Make it sloppy first, so it's more work to convert it to a module.
 
> Generally it's a bad idea to print something when a probe doesn't work,
> as that just leads to lots of dmesg spam for large monolithic kernels.

Generally it's bad to just hack stuff into submission and leave the
mess created for others to clean up.

You've been told that a gazillion times in the past, and I tell it
another time, even if I realized long ago, that you are completely
advisory resistant.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore
  2015-06-18 21:12   ` Thomas Gleixner
@ 2015-06-18 22:48     ` Andi Kleen
  2015-06-18 22:57       ` Thomas Gleixner
  0 siblings, 1 reply; 11+ messages in thread
From: Andi Kleen @ 2015-06-18 22:48 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Andi Kleen, peterz, linux-kernel

> So now we return success, if nothing is there or stuff failed?

Right.

> 
> One possible solution is to split the initcall and have one
> for uncore_pci and one for uncode_msr, but that does not work well if
> you want to make it a module.
> 
> But we should at least have some indication, what worked and what went
> wrong instead of unconditionally returning success.

Nobody uses the return value for builtin drivers (short of one
debug printk). It would not load the module, but right now we don't
have a module.

Generally it's a bad idea to print something when a probe doesn't work,
as that just leads to lots of dmesg spam for large monolithic kernels.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore
  2015-06-18 20:46 ` [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore Andi Kleen
@ 2015-06-18 21:12   ` Thomas Gleixner
  2015-06-18 22:48     ` Andi Kleen
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas Gleixner @ 2015-06-18 21:12 UTC (permalink / raw)
  To: Andi Kleen; +Cc: peterz, linux-kernel, Andi Kleen

On Thu, 18 Jun 2015, Andi Kleen wrote:
>  static int __init intel_uncore_init(void)
>  {
> -	int ret;
> +	int ret1, ret2;
>  
>  	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
>  		return -ENODEV;
> @@ -1295,19 +1297,12 @@ static int __init intel_uncore_init(void)
>  	if (cpu_has_hypervisor)
>  		return -ENODEV;
>  
> -	ret = uncore_pci_init();
> -	if (ret)
> -		goto fail;
> -	ret = uncore_cpu_init();
> -	if (ret) {
> -		uncore_pci_exit();
> -		goto fail;
> +	ret1 = uncore_pci_init();
> +	ret2 = uncore_cpu_init();
> +	if (!ret1 || !ret2) {
> +		uncore_cpumask_init();
> +		uncore_pmus_register();
>  	}
> -	uncore_cpumask_init();
> -
> -	uncore_pmus_register();
>  	return 0;

So now we return success, if nothing is there or stuff failed?

One possible solution is to split the initcall and have one
for uncore_pci and one for uncode_msr, but that does not work well if
you want to make it a module.

But we should at least have some indication, what worked and what went
wrong instead of unconditionally returning success.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore
  2015-06-18 20:45 Updated Haswell uncore PMU patchkit Andi Kleen
@ 2015-06-18 20:46 ` Andi Kleen
  2015-06-18 21:12   ` Thomas Gleixner
  0 siblings, 1 reply; 11+ messages in thread
From: Andi Kleen @ 2015-06-18 20:46 UTC (permalink / raw)
  To: peterz; +Cc: linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Several sytems, such as my laptop, don't expose the PCI devices
for the PCI uncore measurements. But the MSRs for the CBOX and ARB
uncores are always available. Currently the init code doesn't
initialize the MSR uncores when the PCI uncore registration fails.
Stop it from doing that and always try to register the MSR uncores.

This makes the pci uncore exit function unused. We'll need it later
when the uncore becomes modular, so instead of removing it I just
marked it with module_exit right now (which discards it)

v2: Avoid registering notifier when both initialization calls fail
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index b57a09d..cb1428f 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -952,6 +952,8 @@ static void __init uncore_pci_exit(void)
 		uncore_types_exit(uncore_pci_uncores);
 	}
 }
+module_exit(uncore_pci_exit);
+/* XXX: need exit code for rest of intel_uncore_init too */
 
 /* CPU hot plug/unplug are serialized by cpu_add_remove_lock mutex */
 static LIST_HEAD(boxes_to_free);
@@ -1287,7 +1289,7 @@ static void __init uncore_cpumask_init(void)
 
 static int __init intel_uncore_init(void)
 {
-	int ret;
+	int ret1, ret2;
 
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
 		return -ENODEV;
@@ -1295,19 +1297,12 @@ static int __init intel_uncore_init(void)
 	if (cpu_has_hypervisor)
 		return -ENODEV;
 
-	ret = uncore_pci_init();
-	if (ret)
-		goto fail;
-	ret = uncore_cpu_init();
-	if (ret) {
-		uncore_pci_exit();
-		goto fail;
+	ret1 = uncore_pci_init();
+	ret2 = uncore_cpu_init();
+	if (!ret1 || !ret2) {
+		uncore_cpumask_init();
+		uncore_pmus_register();
 	}
-	uncore_cpumask_init();
-
-	uncore_pmus_register();
 	return 0;
-fail:
-	return ret;
 }
 device_initcall(intel_uncore_init);
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-08-04  8:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15  5:57 [PATCH 1/3] x86, perf, uncore: Add support for ARB uncore PMU on Sandy/IvyBridge Andi Kleen
2015-06-15  5:57 ` [PATCH 2/3] x86, perf, uncore: Use Sandy Bridge client PMU on Haswell/Broadwell Andi Kleen
2015-08-04  8:52   ` [tip:perf/core] perf/x86/intel/uncore: " tip-bot for Andi Kleen
2015-06-15  5:57 ` [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore Andi Kleen
2015-06-16 12:06   ` Thomas Gleixner
2015-08-04  8:52 ` [tip:perf/core] perf/x86/intel/uncore: Add support for ARB uncore PMU on Sandy/IvyBridge tip-bot for Andi Kleen
2015-06-18 20:45 Updated Haswell uncore PMU patchkit Andi Kleen
2015-06-18 20:46 ` [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore Andi Kleen
2015-06-18 21:12   ` Thomas Gleixner
2015-06-18 22:48     ` Andi Kleen
2015-06-18 22:57       ` Thomas Gleixner
2015-06-18 23:02 Another Haswell uncore patchkit Andi Kleen
2015-06-18 23:02 ` [PATCH 3/3] x86, perf, uncore: Don't make MSR uncore depend on PCI uncore Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).