Skip to contentSkip to conversation

perf sysfs bits

RFC PATCH In review Peter Zijlstra 4 participants 22 messages Nov 17, 2010 – Dec 16, 2010

Subsystems (11)
Arm (32-bit) x86 PowerPC MIPS +7 more subsystems
lore
Share & tools
lore
#0 lore raw

cover perf sysfs bits

Another version of the perf sysfs bits.

Thanks to Kay for lots of help and feedback..

#1 lore raw

RFC PATCH 1/8 perf, x86: Fixup Kconfig deps

This leads to a Kconfig dep inversion, x86 selects PERF_EVENT (due to a hw_breakpoint dep) but doesn't unconditionally provide HAVE_PERF_EVENT.

---
 arch/x86/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Kconfig +1 -1
Index: linux-2.6/arch/x86/Kconfig
===================================================================
@@ -21,7 +21,7 @@ config X86
 	select HAVE_UNSTABLE_SCHED_CLOCK
 	select HAVE_IDE
 	select HAVE_OPROFILE
-	select HAVE_PERF_EVENTS if (!M386 && !M486)
+	select HAVE_PERF_EVENTS
 	select HAVE_IRQ_WORK
 	select HAVE_IOREMAP_PROT
 	select HAVE_KPROBES
#2 lore raw

[tip:perf/core] perf, x86: Fixup Kconfig deps

Commit-ID:  cc2067a51424dd25c10c1b1230b4222d8baec94d
Gitweb:     http://git.kernel.org/tip/cc2067a51424dd25c10c1b1230b4222d8baec94d
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Tue, 16 Nov 2010 21:49:01 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 26 Nov 2010 15:00:58 +0100

perf, x86: Fixup Kconfig deps

This leads to a Kconfig dep inversion, x86 selects PERF_EVENT (due to a hw_breakpoint dep) but doesn't unconditionally provide HAVE_PERF_EVENT.

(This can cause build failures on M386/M486 kernel .config's.)

LKML-Reference: <[email protected]>

---
 arch/x86/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/Kconfig +1 -1
index e832768..e330da2 100644
@@ -21,7 +21,7 @@ config X86
 	select HAVE_UNSTABLE_SCHED_CLOCK
 	select HAVE_IDE
 	select HAVE_OPROFILE
-	select HAVE_PERF_EVENTS if (!M386 && !M486)
+	select HAVE_PERF_EVENTS
 	select HAVE_IRQ_WORK
 	select HAVE_IOREMAP_PROT
 	select HAVE_KPROBES
#3 lore raw

RFC PATCH 2/8 perf, arch: Use early_initcall() for all arch pmu implementations

In reply to Peter Zijlstra

Currently architectures use various random locations to init the PMU driver, for some this happens before the perf core code is initialized.

In order to avoid calling perf_pmu_register() before the core code is up and running and able to deal with it, move all arch init to at least early_initcall (some archs use a later init, which is fine).

---
 arch/alpha/include/asm/perf_event.h |    6 ------
 arch/alpha/kernel/irq_alpha.c       |    2 --
 arch/alpha/kernel/perf_event.c      |    9 ++++++---
 arch/sparc/include/asm/perf_event.h |    4 ----
 arch/sparc/kernel/nmi.c             |    2 --
 arch/sparc/kernel/perf_event.c      |    7 +++++--
 arch/x86/include/asm/perf_event.h   |    2 --
 arch/x86/kernel/cpu/common.c        |    1 -
 arch/x86/kernel/cpu/perf_event.c    |    9 ++++++---
 9 files changed, 17 insertions(+), 25 deletions(-)
arch/alpha/include/asm/perf_event.h +0 -6
Index: linux-2.6/arch/alpha/include/asm/perf_event.h
===================================================================
@@ -1,10 +1,4 @@
 #ifndef __ASM_ALPHA_PERF_EVENT_H
 #define __ASM_ALPHA_PERF_EVENT_H
 
-#ifdef CONFIG_PERF_EVENTS
-extern void init_hw_perf_events(void);
-#else
-static inline void init_hw_perf_events(void)    { }
-#endif
-
 #endif /* __ASM_ALPHA_PERF_EVENT_H */
arch/alpha/kernel/irq_alpha.c +0 -2
Index: linux-2.6/arch/alpha/kernel/irq_alpha.c
===================================================================
@@ -112,8 +112,6 @@ init_IRQ(void)
 	wrent(entInt, 0);
 
 	alpha_mv.init_irq();
-
-	init_hw_perf_events();
 }
 
 /*
arch/alpha/kernel/perf_event.c +6 -3
Index: linux-2.6/arch/alpha/kernel/perf_event.c
===================================================================
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/kdebug.h>
 #include <linux/mutex.h>
+#include <linux/init.h>
 
 #include <asm/hwrpb.h>
 #include <asm/atomic.h>
@@ -863,13 +864,13 @@ static void alpha_perf_event_irq_handler
 /*
  * Init call to initialise performance events at kernel startup.
  */
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	pr_info("Performance events: ");
 
 	if (!supported_cpu()) {
 		pr_cont("No support for your CPU.\n");
-		return;
+		return 0;
 	}
 
 	pr_cont("Supported CPU type!\n");
@@ -882,5 +883,7 @@ void __init init_hw_perf_events(void)
 	alpha_pmu = &ev67_pmu;
 
 	perf_pmu_register(&pmu);
-}
 
+	return 0;
+}
+early_initcall(init_hw_perf_events);
arch/sparc/include/asm/perf_event.h +0 -4
Index: linux-2.6/arch/sparc/include/asm/perf_event.h
===================================================================
@@ -4,8 +4,6 @@
 #ifdef CONFIG_PERF_EVENTS
 #include <asm/ptrace.h>
 
-extern void init_hw_perf_events(void);
-
 #define perf_arch_fetch_caller_regs(regs, ip)		\
 do {							\
 	unsigned long _pstate, _asi, _pil, _i7, _fp;	\
@@ -26,8 +24,6 @@ do {							\
 	(regs)->u_regs[UREG_I6] = _fp;			\
 	(regs)->u_regs[UREG_I7] = _i7;			\
 } while (0)
-#else
-static inline void init_hw_perf_events(void)	{ }
 #endif
 
 #endif
arch/sparc/kernel/nmi.c +0 -2
Index: linux-2.6/arch/sparc/kernel/nmi.c
===================================================================
@@ -270,8 +270,6 @@ int __init nmi_init(void)
 			atomic_set(&nmi_active, -1);
 		}
 	}
-	if (!err)
-		init_hw_perf_events();
 
 	return err;
 }
arch/sparc/kernel/perf_event.c +5 -2
Index: linux-2.6/arch/sparc/kernel/perf_event.c
===================================================================
@@ -1307,20 +1307,23 @@ static bool __init supported_pmu(void)
 	return false;
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	pr_info("Performance events: ");
 
 	if (!supported_pmu()) {
 		pr_cont("No support for PMU type '%s'\n", sparc_pmu_type);
-		return;
+		return 0;
 	}
 
 	pr_cont("Supported PMU type is '%s'\n", sparc_pmu_type);
 
 	perf_pmu_register(&pmu);
 	register_die_notifier(&perf_event_nmi_notifier);
+
+	return 0;
 }
+early_initcall(init_hw_perf_event);
 
 void perf_callchain_kernel(struct perf_callchain_entry *entry,
 			   struct pt_regs *regs)
arch/x86/include/asm/perf_event.h +0 -2
Index: linux-2.6/arch/x86/include/asm/perf_event.h
===================================================================
@@ -125,7 +125,6 @@ union cpuid10_edx {
 #define IBS_OP_MAX_CNT_EXT	0x007FFFFFULL	/* not a register bit mask */
 
 #ifdef CONFIG_PERF_EVENTS
-extern void init_hw_perf_events(void);
 extern void perf_events_lapic_init(void);
 
 #define PERF_EVENT_INDEX_OFFSET			0
@@ -156,7 +155,6 @@ extern unsigned long perf_misc_flags(str
 }
 
 #else
-static inline void init_hw_perf_events(void)		{ }
 static inline void perf_events_lapic_init(void)	{ }
 #endif
 
arch/x86/kernel/cpu/common.c +0 -1
Index: linux-2.6/arch/x86/kernel/cpu/common.c
===================================================================
@@ -894,7 +894,6 @@ void __init identify_boot_cpu(void)
 #else
 	vgetcpu_set_mode();
 #endif
-	init_hw_perf_events();
 }
 
 void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/perf_event.c +6 -3
Index: linux-2.6/arch/x86/kernel/cpu/perf_event.c
===================================================================
@@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
 	pr_info("no hardware sampling interrupt available.\n");
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	struct event_constraint *c;
 	int err;
@@ -1363,11 +1363,11 @@ void __init init_hw_perf_events(void)
 		err = amd_pmu_init();
 		break;
 	default:
-		return;
+		return 0;
 	}
 	if (err != 0) {
 		pr_cont("no PMU driver, software events only.\n");
-		return;
+		return 0;
 	}
 
 	pmu_check_apic();
@@ -1420,7 +1420,10 @@ void __init init_hw_perf_events(void)
 
 	perf_pmu_register(&pmu);
 	perf_cpu_notifier(x86_pmu_notifier);
+
+	return 0;
 }
+early_initcall(init_hw_perf_events);
 
 static inline void x86_pmu_read(struct perf_event *event)
 {
#4 lore raw

Re: [RFC][PATCH 2/8] perf, arch: Use early_initcall() for all arch pmu implementations

Quoted 11 lines · Peter Zijlstra

plain text document attachment (perf-fix-hw-init.patch) Currently architectures use various random locations to init the PMU driver, for some this happens before the perf core code is initialized.

In order to avoid calling perf_pmu_register() before the core code is up and running and able to deal with it, move all arch init to at least early_initcall (some archs use a later init, which is fine).

---

<snip alpha,sparc bits>

Quoted 28 lines

Index: linux-2.6/arch/x86/kernel/cpu/perf_event.c
===================================================================

arch/x86/kernel/cpu/perf_event.c +3 -3
@@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
 	pr_info("no hardware sampling interrupt available.\n");
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	struct event_constraint *c;
 	int err;
@@ -1363,11 +1363,11 @@ void __init init_hw_perf_events(void)
 		err = amd_pmu_init();
 		break;
 	default:
-		return;
+		return 0;
 	}
 	if (err != 0) {
 		pr_cont("no PMU driver, software events only.\n");
-		return;
+		return 0;
 	}
 
 	pmu_check_apic();

arch/x86/kernel/cpu/perf_event.c void __init init_hw_perf_events(void) · line 1429

Quoted 10 lines
arch/x86/kernel/cpu/perf_event.c +3 -0
@@ -1420,7 +1420,10 @@ void __init init_hw_perf_events(void)
 
 	perf_pmu_register(&pmu);
 	perf_cpu_notifier(x86_pmu_notifier);
+
+	return 0;
 }
+early_initcall(init_hw_perf_events);
 
 static inline void x86_pmu_read(struct perf_event *event)
 {

Right, so hw perf init happens from (after this patch):

arch_initcall: powerpc, arm, sh, mips
early_initcall: x86, sparc, alpha

Now the problem is that the generic watchdog code (kernel/watchdog.c) tries to create hw perf events, and that too runs from early_initcall.

So my question is, how do we go about curing this, because powerpc, arm, sh and mips are too late and the rest depends on link order to work, not really a nice situation.

There's two categories of solutions:
- move the watchdog later, and
- move the hw perf init earlier.

The former is undesired because we want the watchdog as early as possible, the later needs new infrastructure (also, I don't know if the arch implementations can actually run this early).

So do I create a perf_initcall() or is there another solution that avoids things like calling the watchdog code from all arch init code?

maintainer
#5 lore raw

Re: [RFC][PATCH 2/8] perf, arch: Use early_initcall() for all arch pmu implementations

Quoted 18 lines · Peter Zijlstra

Right, so hw perf init happens from (after this patch):

arch_initcall: powerpc, arm, sh, mips
early_initcall: x86, sparc, alpha

Now the problem is that the generic watchdog code (kernel/watchdog.c) tries to create hw perf events, and that too runs from early_initcall.

So my question is, how do we go about curing this, because powerpc, arm, sh and mips are too late and the rest depends on link order to work, not really a nice situation.

There's two categories of solutions:
- move the watchdog later, and
- move the hw perf init earlier.

Quoted 6 lines

The former is undesired because we want the watchdog as early as possible, the later needs new infrastructure (also, I don't know if the arch implementations can actually run this early).

So do I create a perf_initcall() or is there another solution that avoids things like calling the watchdog code from all arch init code?

How about something like these? After this we could even look at making the watchdog code an explicit init in main.c right after do_perf_initcalls() (or later if it requires more to be up and running).

Hrm,. except that it all builds but doesn't seem to actually work, I guess I need more magics to make the perf_initcall() thing work.

/me goes investigate

Subject: perf, core: Introduce perf_initcall()
From: Peter Zijlstra <[email protected]>
Date: Thu Nov 25 15:27:49 CET 2010

In order to initialize the built-in hardware PMU drivers before early_initcall() -- which is used by the watchdog code and expects the hardware PMUs to be present.

LKML-Reference: <new-submission>

---
 include/asm-generic/vmlinux.lds.h |    2 +
 include/linux/init.h              |    7 +++++
 init/main.c                       |   53 ++++++++++++++++++++++----------------
 3 files changed, 40 insertions(+), 22 deletions(-)
include/asm-generic/vmlinux.lds.h +2 -0
Index: linux-2.6/include/asm-generic/vmlinux.lds.h
===================================================================
@@ -600,6 +600,8 @@
 		VMLINUX_SYMBOL(__setup_end) = .;
 
 #define INITCALLS							\
+	*(.initcallperf.init)						\
+	VMLINUX_SYMBOL(__perf_initcall_end) = .;			\
 	*(.initcallearly.init)						\
 	VMLINUX_SYMBOL(__early_initcall_end) = .;			\
   	*(.initcall0.init)						\
include/linux/init.h +7 -0
Index: linux-2.6/include/linux/init.h
===================================================================
@@ -179,6 +179,13 @@ extern int initcall_debug;
 	__attribute__((__section__(".initcall" level ".init"))) = fn
 
 /*
+ * Very early initcalls, run after the perf core is up.
+ *
+ * Only for build-in code, not modules.
+ */
+#define perf_initcall(fn)		__define_initcall("perf",fn,perf)
+
+/*
  * Early initcalls run before initializing SMP.
  *
  * Only for built-in code, not modules.
init/main.c +31 -22

77 lines not on this page · raw message

Subject: perf, arch: Use perf_initcall() for all arch pmu implementations
From: Peter Zijlstra <[email protected]>
Date: Tue Nov 16 22:08:28 CET 2010

Currently architectures use various random locations to init the PMU driver, for some this happens before the perf core code is initialized.

In order to avoid calling perf_pmu_register() before the core code is up and running and able to deal with it, move all arch pmu init calls to perf_initcall().

Cc Michael Cree <[email protected]>
Cc David Miller <[email protected]>
Cc Paul Mundt <[email protected]>
Cc Will Deacon <[email protected]>
Cc paulus <[email protected]>
Cc Deng-Cheng Zhu <[email protected]>

LKML-Reference: <[email protected]>

---
 arch/alpha/include/asm/perf_event.h  |    6 ------
 arch/alpha/kernel/irq_alpha.c        |    2 --
 arch/alpha/kernel/perf_event.c       |    9 ++++++---
 arch/arm/kernel/perf_event.c         |    2 +-
 arch/mips/kernel/perf_event_mipsxx.c |    2 +-
 arch/powerpc/kernel/e500-pmu.c       |    2 +-
 arch/powerpc/kernel/mpc7450-pmu.c    |    2 +-
 arch/powerpc/kernel/power4-pmu.c     |    2 +-
 arch/powerpc/kernel/power5+-pmu.c    |    2 +-
 arch/powerpc/kernel/power5-pmu.c     |    2 +-
 arch/powerpc/kernel/power6-pmu.c     |    2 +-
 arch/powerpc/kernel/power7-pmu.c     |    2 +-
 arch/powerpc/kernel/ppc970-pmu.c     |    2 +-
 arch/sh/kernel/cpu/sh4/perf_event.c  |    2 +-
 arch/sh/kernel/cpu/sh4a/perf_event.c |    2 +-
 arch/sparc/include/asm/perf_event.h  |    4 ----
 arch/sparc/kernel/nmi.c              |    2 --
 arch/sparc/kernel/perf_event.c       |    7 +++++--
 arch/x86/include/asm/perf_event.h    |    2 --
 arch/x86/kernel/cpu/common.c         |    1 -
 arch/x86/kernel/cpu/perf_event.c     |   11 +++++++----
 21 files changed, 30 insertions(+), 38 deletions(-)
arch/alpha/include/asm/perf_event.h +0 -6
Index: linux-2.6/arch/alpha/include/asm/perf_event.h
===================================================================
@@ -1,10 +1,4 @@
 #ifndef __ASM_ALPHA_PERF_EVENT_H
 #define __ASM_ALPHA_PERF_EVENT_H
 
-#ifdef CONFIG_PERF_EVENTS
-extern void init_hw_perf_events(void);
-#else
-static inline void init_hw_perf_events(void)    { }
-#endif
-
 #endif /* __ASM_ALPHA_PERF_EVENT_H */
arch/alpha/kernel/irq_alpha.c +0 -2
Index: linux-2.6/arch/alpha/kernel/irq_alpha.c
===================================================================
@@ -112,8 +112,6 @@ init_IRQ(void)
 	wrent(entInt, 0);
 
 	alpha_mv.init_irq();
-
-	init_hw_perf_events();
 }
 
 /*
arch/alpha/kernel/perf_event.c +6 -3
Index: linux-2.6/arch/alpha/kernel/perf_event.c
===================================================================
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/kdebug.h>
 #include <linux/mutex.h>
+#include <linux/init.h>
 
 #include <asm/hwrpb.h>
 #include <asm/atomic.h>
@@ -863,13 +864,13 @@ static void alpha_perf_event_irq_handler
 /*
  * Init call to initialise performance events at kernel startup.
  */
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	pr_info("Performance events: ");
 
 	if (!supported_cpu()) {
 		pr_cont("No support for your CPU.\n");
-		return;
+		return 0;
 	}
 
 	pr_cont("Supported CPU type!\n");
@@ -882,5 +883,7 @@ void __init init_hw_perf_events(void)
 	alpha_pmu = &ev67_pmu;
 
 	perf_pmu_register(&pmu);
-}
 
+	return 0;
+}
+perf_initcall(init_hw_perf_events);
arch/sparc/include/asm/perf_event.h +0 -4
Index: linux-2.6/arch/sparc/include/asm/perf_event.h
===================================================================
@@ -4,8 +4,6 @@
 #ifdef CONFIG_PERF_EVENTS
 #include <asm/ptrace.h>
 
-extern void init_hw_perf_events(void);
-
 #define perf_arch_fetch_caller_regs(regs, ip)		\
 do {							\
 	unsigned long _pstate, _asi, _pil, _i7, _fp;	\
@@ -26,8 +24,6 @@ do {							\
 	(regs)->u_regs[UREG_I6] = _fp;			\
 	(regs)->u_regs[UREG_I7] = _i7;			\
 } while (0)
-#else
-static inline void init_hw_perf_events(void)	{ }
 #endif
 
 #endif
arch/sparc/kernel/nmi.c +0 -2
Index: linux-2.6/arch/sparc/kernel/nmi.c
===================================================================
@@ -270,8 +270,6 @@ int __init nmi_init(void)
 			atomic_set(&nmi_active, -1);
 		}
 	}
-	if (!err)
-		init_hw_perf_events();
 
 	return err;
 }
arch/sparc/kernel/perf_event.c +5 -2
Index: linux-2.6/arch/sparc/kernel/perf_event.c
===================================================================
@@ -1307,20 +1307,23 @@ static bool __init supported_pmu(void)
 	return false;
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	pr_info("Performance events: ");
 
 	if (!supported_pmu()) {
 		pr_cont("No support for PMU type '%s'\n", sparc_pmu_type);
-		return;
+		return 0;
 	}
 
 	pr_cont("Supported PMU type is '%s'\n", sparc_pmu_type);
 
 	perf_pmu_register(&pmu);
 	register_die_notifier(&perf_event_nmi_notifier);
+
+	return 0;
 }
+perf_initcall(init_hw_perf_event);
 
 void perf_callchain_kernel(struct perf_callchain_entry *entry,
 			   struct pt_regs *regs)
arch/x86/include/asm/perf_event.h +0 -2
Index: linux-2.6/arch/x86/include/asm/perf_event.h
===================================================================
@@ -125,7 +125,6 @@ union cpuid10_edx {
 #define IBS_OP_MAX_CNT_EXT	0x007FFFFFULL	/* not a register bit mask */
 
 #ifdef CONFIG_PERF_EVENTS
-extern void init_hw_perf_events(void);
 extern void perf_events_lapic_init(void);
 
 #define PERF_EVENT_INDEX_OFFSET			0
@@ -156,7 +155,6 @@ extern unsigned long perf_misc_flags(str
 }
 
 #else
-static inline void init_hw_perf_events(void)		{ }
 static inline void perf_events_lapic_init(void)	{ }
 #endif
 
arch/x86/kernel/cpu/common.c +0 -1
Index: linux-2.6/arch/x86/kernel/cpu/common.c
===================================================================
@@ -894,7 +894,6 @@ void __init identify_boot_cpu(void)
 #else
 	vgetcpu_set_mode();
 #endif
-	init_hw_perf_events();
 }
 
 void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/perf_event.c +7 -4
Index: linux-2.6/arch/x86/kernel/cpu/perf_event.c
===================================================================
@@ -1423,7 +1423,7 @@ static void __init pmu_check_apic(void)
 	pr_info("no hardware sampling interrupt available.\n");
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	struct event_constraint *c;
 	int err;
@@ -1438,11 +1438,11 @@ void __init init_hw_perf_events(void)
 		err = amd_pmu_init();
 		break;
 	default:
-		return;
+		return 0;
 	}
 	if (err != 0) {
 		pr_cont("no PMU driver, software events only.\n");
-		return;
+		return 0;
 	}
 
 	pmu_check_apic();
@@ -1450,7 +1450,7 @@ void __init init_hw_perf_events(void)
 	/* sanity check that the hardware exists or is emulated */
 	if (!check_hw_exists()) {
 		pr_cont("Broken PMU hardware detected, software events only.\n");
-		return;
+		return 0;
 	}
 
 	pr_cont("%s PMU driver.\n", x86_pmu.name);
@@ -1501,7 +1501,10 @@ void __init init_hw_perf_events(void)
 
 	perf_pmu_register(&pmu);
 	perf_cpu_notifier(x86_pmu_notifier);
+
+	return 0;
 }
+perf_initcall(init_hw_perf_events);
 
 static inline void x86_pmu_read(struct perf_event *event)
 {
arch/arm/kernel/perf_event.c +1 -1
Index: linux-2.6/arch/arm/kernel/perf_event.c
===================================================================
@@ -3038,7 +3038,7 @@ init_hw_perf_events(void)
 
 	return 0;
 }
-arch_initcall(init_hw_perf_events);
+perf_initcall(init_hw_perf_events);
 
 /*
  * Callchain handling code.
arch/mips/kernel/perf_event_mipsxx.c +1 -1
Index: linux-2.6/arch/mips/kernel/perf_event_mipsxx.c
===================================================================
@@ -1047,6 +1047,6 @@ init_hw_perf_events(void)
 
 	return 0;
 }
-arch_initcall(init_hw_perf_events);
+perf_initcall(init_hw_perf_events);
 
 #endif /* defined(CONFIG_CPU_MIPS32)... */
arch/powerpc/kernel/e500-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/e500-pmu.c
===================================================================
@@ -126,4 +126,4 @@ static int init_e500_pmu(void)
 	return register_fsl_emb_pmu(&e500_pmu);
 }
 
-arch_initcall(init_e500_pmu);
+perf_initcall(init_e500_pmu);
arch/powerpc/kernel/mpc7450-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/mpc7450-pmu.c
===================================================================
@@ -414,4 +414,4 @@ static int init_mpc7450_pmu(void)
 	return register_power_pmu(&mpc7450_pmu);
 }
 
-arch_initcall(init_mpc7450_pmu);
+perf_initcall(init_mpc7450_pmu);
arch/powerpc/kernel/power4-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power4-pmu.c
===================================================================
@@ -613,4 +613,4 @@ static int init_power4_pmu(void)
 	return register_power_pmu(&power4_pmu);
 }
 
-arch_initcall(init_power4_pmu);
+perf_initcall(init_power4_pmu);
arch/powerpc/kernel/power5+-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power5+-pmu.c
===================================================================
@@ -682,4 +682,4 @@ static int init_power5p_pmu(void)
 	return register_power_pmu(&power5p_pmu);
 }
 
-arch_initcall(init_power5p_pmu);
+perf_initcall(init_power5p_pmu);
arch/powerpc/kernel/power5-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power5-pmu.c
===================================================================
@@ -621,4 +621,4 @@ static int init_power5_pmu(void)
 	return register_power_pmu(&power5_pmu);
 }
 
-arch_initcall(init_power5_pmu);
+perf_initcall(init_power5_pmu);
arch/powerpc/kernel/power6-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power6-pmu.c
===================================================================
@@ -544,4 +544,4 @@ static int init_power6_pmu(void)
 	return register_power_pmu(&power6_pmu);
 }
 
-arch_initcall(init_power6_pmu);
+perf_initcall(init_power6_pmu);
arch/powerpc/kernel/power7-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power7-pmu.c
===================================================================
@@ -369,4 +369,4 @@ static int init_power7_pmu(void)
 	return register_power_pmu(&power7_pmu);
 }
 
-arch_initcall(init_power7_pmu);
+perf_initcall(init_power7_pmu);
arch/powerpc/kernel/ppc970-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/ppc970-pmu.c
===================================================================
@@ -494,4 +494,4 @@ static int init_ppc970_pmu(void)
 	return register_power_pmu(&ppc970_pmu);
 }
 
-arch_initcall(init_ppc970_pmu);
+perf_initcall(init_ppc970_pmu);
arch/sh/kernel/cpu/sh4/perf_event.c +1 -1
Index: linux-2.6/arch/sh/kernel/cpu/sh4/perf_event.c
===================================================================
@@ -250,4 +250,4 @@ static int __init sh7750_pmu_init(void)
 
 	return register_sh_pmu(&sh7750_pmu);
 }
-arch_initcall(sh7750_pmu_init);
+perf_initcall(sh7750_pmu_init);
arch/sh/kernel/cpu/sh4a/perf_event.c +1 -1
Index: linux-2.6/arch/sh/kernel/cpu/sh4a/perf_event.c
===================================================================
@@ -284,4 +284,4 @@ static int __init sh4a_pmu_init(void)
 
 	return register_sh_pmu(&sh4a_pmu);
 }
-arch_initcall(sh4a_pmu_init);
+perf_initcall(sh4a_pmu_init);
#6 lore raw

Re: [RFC][PATCH 2/8] perf, arch: Use early_initcall() for all arch pmu implementations

Hi Peter,

Quoted 7 lines · Peter Zijlstra
Quoted 2 lines

So do I create a perf_initcall() or is there another solution that avoids things like calling the watchdog code from all arch init code?

How about something like these? After this we could even look at making the watchdog code an explicit init in main.c right after do_perf_initcalls() (or later if it requires more to be up and running).

What tree/branch are these patches taken against? They don't seem to apply against -rc3 or tip/master. Anyway, I currently have some pending patches to split up the monolithic perf_event.c we have for ARM so that different PMU implementations can live in different files (in the same way that x86 does it). This might mean that your initcall patch no longer applies because it will be a couple of thousand lines higher up in the file.

The patches are available here:

git://linux-arm.org/linux-2.6-wd.git perf-split

I'll put these into Russell's patch system today so they should be candidates for 2.6.38.

Quoted 5 lines

Hrm,. except that it all builds but doesn't seem to actually work, I guess I need more magics to make the perf_initcall() thing work.

/me goes investigate

Good luck!

Will

maintainer
#7 lore raw

Re: [RFC][PATCH 2/8] perf, arch: Use early_initcall() for all arch pmu implementations

Quoted 2 lines · Will Deacon

What tree/branch are these patches taken against? They don't seem to apply against -rc3 or tip/master.

tip/master + my quilt queue

Quoted 6 lines

Anyway, I currently have some
pending patches to split up the monolithic perf_event.c we have for ARM so that different PMU implementations can live in different files (in the same way that x86 does it). This might mean that your initcall patch no longer applies because it will be a couple of thousand lines higher up in the file.

That's ok, I'm sure we can sort that out when I've got stuff working ;-)

maintainer
#8 lore raw

Re: [RFC][PATCH 2/8] perf, arch: Use early_initcall() for all arch pmu implementations

In reply to Peter Zijlstra
Quoted 18 lines · Peter Zijlstra

Right, so hw perf init happens from (after this patch):

arch_initcall: powerpc, arm, sh, mips
early_initcall: x86, sparc, alpha

Now the problem is that the generic watchdog code (kernel/watchdog.c) tries to create hw perf events, and that too runs from early_initcall.

So my question is, how do we go about curing this, because powerpc, arm, sh and mips are too late and the rest depends on link order to work, not really a nice situation.

There's two categories of solutions:
- move the watchdog later, and
- move the hw perf init earlier.

Quoted 6 lines

The former is undesired because we want the watchdog as early as possible, the later needs new infrastructure (also, I don't know if the arch implementations can actually run this early).

So do I create a perf_initcall() or is there another solution that avoids things like calling the watchdog code from all arch init code?

So the perf_event_init() site is _waaay_ to early to init stuff.. I guess I'll move it all to early_initcall() and I'll move the watchdog to an explicit call right after it.

Something like the below,.. now I guess the question to all of you is, can your arch pmu code cope with early_initcall() or does it need to be some other place?

---
 arch/alpha/include/asm/perf_event.h  |    6 ------
 arch/alpha/kernel/irq_alpha.c        |    2 --
 arch/alpha/kernel/perf_event.c       |    9 ++++++---
 arch/arm/kernel/perf_event.c         |    2 +-
 arch/mips/kernel/perf_event_mipsxx.c |    2 +-
 arch/powerpc/kernel/e500-pmu.c       |    2 +-
 arch/powerpc/kernel/mpc7450-pmu.c    |    2 +-
 arch/powerpc/kernel/power4-pmu.c     |    2 +-
 arch/powerpc/kernel/power5+-pmu.c    |    2 +-
 arch/powerpc/kernel/power5-pmu.c     |    2 +-
 arch/powerpc/kernel/power6-pmu.c     |    2 +-
 arch/powerpc/kernel/power7-pmu.c     |    2 +-
 arch/powerpc/kernel/ppc970-pmu.c     |    2 +-
 arch/sh/kernel/cpu/sh4/perf_event.c  |    2 +-
 arch/sh/kernel/cpu/sh4a/perf_event.c |    2 +-
 arch/sparc/include/asm/perf_event.h  |    4 ----
 arch/sparc/kernel/nmi.c              |    2 --
 arch/sparc/kernel/perf_event.c       |    7 +++++--
 arch/x86/include/asm/perf_event.h    |    2 --
 arch/x86/kernel/cpu/common.c         |    1 -
 arch/x86/kernel/cpu/perf_event.c     |   11 +++++++----
 include/linux/sched.h                |    4 ++++
 init/main.c                          |    1 +
 kernel/watchdog.c                    |    7 +++----
 24 files changed, 38 insertions(+), 42 deletions(-)
include/linux/sched.h +4 -0
Index: linux-2.6/include/linux/sched.h
===================================================================
@@ -316,6 +316,7 @@ extern int proc_dowatchdog_thresh(struct
 				  size_t *lenp, loff_t *ppos);
 extern unsigned int  softlockup_panic;
 extern int softlockup_thresh;
+void lockup_detector_init(void);
 #else
 static inline void touch_softlockup_watchdog(void)
 {
@@ -326,6 +327,9 @@ static inline void touch_softlockup_watc
 static inline void touch_all_softlockup_watchdogs(void)
 {
 }
+static inline void lockup_detector_init(void)
+{
+}
 #endif
 
 #ifdef CONFIG_DETECT_HUNG_TASK
init/main.c +1 -0
Index: linux-2.6/init/main.c
===================================================================
@@ -884,6 +884,7 @@ static int __init kernel_init(void * unu
 	smp_prepare_cpus(setup_max_cpus);
 
 	do_pre_smp_initcalls();
+	lockup_detector_init();
 
 	smp_init();
 	sched_init_smp();
kernel/watchdog.c +3 -4
Index: linux-2.6/kernel/watchdog.c
===================================================================
@@ -547,13 +547,13 @@ static struct notifier_block __cpuinitda
 	.notifier_call = cpu_callback
 };
 
-static int __init spawn_watchdog_task(void)
+void __init lockup_detector_init(void)
 {
 	void *cpu = (void *)(long)smp_processor_id();
 	int err;
 
 	if (no_watchdog)
-		return 0;
+		return;
 
 	err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
 	WARN_ON(notifier_to_errno(err));
@@ -561,6 +561,5 @@ static int __init spawn_watchdog_task(vo
 	cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
 	register_cpu_notifier(&cpu_nfb);
 
-	return 0;
+	return;
 }
-early_initcall(spawn_watchdog_task);
arch/alpha/include/asm/perf_event.h +0 -6
Index: linux-2.6/arch/alpha/include/asm/perf_event.h
===================================================================
@@ -1,10 +1,4 @@
 #ifndef __ASM_ALPHA_PERF_EVENT_H
 #define __ASM_ALPHA_PERF_EVENT_H
 
-#ifdef CONFIG_PERF_EVENTS
-extern void init_hw_perf_events(void);
-#else
-static inline void init_hw_perf_events(void)    { }
-#endif
-
 #endif /* __ASM_ALPHA_PERF_EVENT_H */
arch/alpha/kernel/irq_alpha.c +0 -2
Index: linux-2.6/arch/alpha/kernel/irq_alpha.c
===================================================================
@@ -112,8 +112,6 @@ init_IRQ(void)
 	wrent(entInt, 0);
 
 	alpha_mv.init_irq();
-
-	init_hw_perf_events();
 }
 
 /*
arch/alpha/kernel/perf_event.c +6 -3
Index: linux-2.6/arch/alpha/kernel/perf_event.c
===================================================================
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/kdebug.h>
 #include <linux/mutex.h>
+#include <linux/init.h>
 
 #include <asm/hwrpb.h>
 #include <asm/atomic.h>
@@ -863,13 +864,13 @@ static void alpha_perf_event_irq_handler
 /*
  * Init call to initialise performance events at kernel startup.
  */
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	pr_info("Performance events: ");
 
 	if (!supported_cpu()) {
 		pr_cont("No support for your CPU.\n");
-		return;
+		return 0;
 	}
 
 	pr_cont("Supported CPU type!\n");
@@ -882,5 +883,7 @@ void __init init_hw_perf_events(void)
 	alpha_pmu = &ev67_pmu;
 
 	perf_pmu_register(&pmu);
-}
 
+	return 0;
+}
+early_initcall(init_hw_perf_events);
arch/arm/kernel/perf_event.c +1 -1
Index: linux-2.6/arch/arm/kernel/perf_event.c
===================================================================
@@ -3038,7 +3038,7 @@ init_hw_perf_events(void)
 
 	return 0;
 }
-arch_initcall(init_hw_perf_events);
+early_initcall(init_hw_perf_events);
 
 /*
  * Callchain handling code.
arch/mips/kernel/perf_event_mipsxx.c +1 -1
Index: linux-2.6/arch/mips/kernel/perf_event_mipsxx.c
===================================================================
@@ -1047,6 +1047,6 @@ init_hw_perf_events(void)
 
 	return 0;
 }
-arch_initcall(init_hw_perf_events);
+early_initcall(init_hw_perf_events);
 
 #endif /* defined(CONFIG_CPU_MIPS32)... */
arch/powerpc/kernel/e500-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/e500-pmu.c
===================================================================
@@ -126,4 +126,4 @@ static int init_e500_pmu(void)
 	return register_fsl_emb_pmu(&e500_pmu);
 }
 
-arch_initcall(init_e500_pmu);
+early_initcall(init_e500_pmu);
arch/powerpc/kernel/mpc7450-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/mpc7450-pmu.c
===================================================================
@@ -414,4 +414,4 @@ static int init_mpc7450_pmu(void)
 	return register_power_pmu(&mpc7450_pmu);
 }
 
-arch_initcall(init_mpc7450_pmu);
+early_initcall(init_mpc7450_pmu);
arch/powerpc/kernel/power4-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power4-pmu.c
===================================================================
@@ -613,4 +613,4 @@ static int init_power4_pmu(void)
 	return register_power_pmu(&power4_pmu);
 }
 
-arch_initcall(init_power4_pmu);
+early_initcall(init_power4_pmu);
arch/powerpc/kernel/power5+-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power5+-pmu.c
===================================================================
@@ -682,4 +682,4 @@ static int init_power5p_pmu(void)
 	return register_power_pmu(&power5p_pmu);
 }
 
-arch_initcall(init_power5p_pmu);
+early_initcall(init_power5p_pmu);
arch/powerpc/kernel/power5-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power5-pmu.c
===================================================================
@@ -621,4 +621,4 @@ static int init_power5_pmu(void)
 	return register_power_pmu(&power5_pmu);
 }
 
-arch_initcall(init_power5_pmu);
+early_initcall(init_power5_pmu);
arch/powerpc/kernel/power6-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power6-pmu.c
===================================================================
@@ -544,4 +544,4 @@ static int init_power6_pmu(void)
 	return register_power_pmu(&power6_pmu);
 }
 
-arch_initcall(init_power6_pmu);
+early_initcall(init_power6_pmu);
arch/powerpc/kernel/power7-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/power7-pmu.c
===================================================================
@@ -369,4 +369,4 @@ static int init_power7_pmu(void)
 	return register_power_pmu(&power7_pmu);
 }
 
-arch_initcall(init_power7_pmu);
+early_initcall(init_power7_pmu);
arch/powerpc/kernel/ppc970-pmu.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/ppc970-pmu.c
===================================================================
@@ -494,4 +494,4 @@ static int init_ppc970_pmu(void)
 	return register_power_pmu(&ppc970_pmu);
 }
 
-arch_initcall(init_ppc970_pmu);
+early_initcall(init_ppc970_pmu);
arch/sh/kernel/cpu/sh4/perf_event.c +1 -1
Index: linux-2.6/arch/sh/kernel/cpu/sh4/perf_event.c
===================================================================
@@ -250,4 +250,4 @@ static int __init sh7750_pmu_init(void)
 
 	return register_sh_pmu(&sh7750_pmu);
 }
-arch_initcall(sh7750_pmu_init);
+early_initcall(sh7750_pmu_init);
arch/sh/kernel/cpu/sh4a/perf_event.c +1 -1
Index: linux-2.6/arch/sh/kernel/cpu/sh4a/perf_event.c
===================================================================
@@ -284,4 +284,4 @@ static int __init sh4a_pmu_init(void)
 
 	return register_sh_pmu(&sh4a_pmu);
 }
-arch_initcall(sh4a_pmu_init);
+early_initcall(sh4a_pmu_init);
arch/sparc/include/asm/perf_event.h +0 -4
Index: linux-2.6/arch/sparc/include/asm/perf_event.h
===================================================================
@@ -4,8 +4,6 @@
 #ifdef CONFIG_PERF_EVENTS
 #include <asm/ptrace.h>
 
-extern void init_hw_perf_events(void);
-
 #define perf_arch_fetch_caller_regs(regs, ip)		\
 do {							\
 	unsigned long _pstate, _asi, _pil, _i7, _fp;	\
@@ -26,8 +24,6 @@ do {							\
 	(regs)->u_regs[UREG_I6] = _fp;			\
 	(regs)->u_regs[UREG_I7] = _i7;			\
 } while (0)
-#else
-static inline void init_hw_perf_events(void)	{ }
 #endif
 
 #endif
arch/sparc/kernel/nmi.c +0 -2
Index: linux-2.6/arch/sparc/kernel/nmi.c
===================================================================
@@ -270,8 +270,6 @@ int __init nmi_init(void)
 			atomic_set(&nmi_active, -1);
 		}
 	}
-	if (!err)
-		init_hw_perf_events();
 
 	return err;
 }
arch/sparc/kernel/perf_event.c +5 -2
Index: linux-2.6/arch/sparc/kernel/perf_event.c
===================================================================
@@ -1307,20 +1307,23 @@ static bool __init supported_pmu(void)
 	return false;
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	pr_info("Performance events: ");
 
 	if (!supported_pmu()) {
 		pr_cont("No support for PMU type '%s'\n", sparc_pmu_type);
-		return;
+		return 0;
 	}
 
 	pr_cont("Supported PMU type is '%s'\n", sparc_pmu_type);
 
 	perf_pmu_register(&pmu);
 	register_die_notifier(&perf_event_nmi_notifier);
+
+	return 0;
 }
+early_initcall(init_hw_perf_event);
 
 void perf_callchain_kernel(struct perf_callchain_entry *entry,
 			   struct pt_regs *regs)
arch/x86/include/asm/perf_event.h +0 -2
Index: linux-2.6/arch/x86/include/asm/perf_event.h
===================================================================
@@ -125,7 +125,6 @@ union cpuid10_edx {
 #define IBS_OP_MAX_CNT_EXT	0x007FFFFFULL	/* not a register bit mask */
 
 #ifdef CONFIG_PERF_EVENTS
-extern void init_hw_perf_events(void);
 extern void perf_events_lapic_init(void);
 
 #define PERF_EVENT_INDEX_OFFSET			0
@@ -156,7 +155,6 @@ extern unsigned long perf_misc_flags(str
 }
 
 #else
-static inline void init_hw_perf_events(void)		{ }
 static inline void perf_events_lapic_init(void)	{ }
 #endif
 
arch/x86/kernel/cpu/common.c +0 -1
Index: linux-2.6/arch/x86/kernel/cpu/common.c
===================================================================
@@ -894,7 +894,6 @@ void __init identify_boot_cpu(void)
 #else
 	vgetcpu_set_mode();
 #endif
-	init_hw_perf_events();
 }
 
 void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/perf_event.c +7 -4
Index: linux-2.6/arch/x86/kernel/cpu/perf_event.c
===================================================================
@@ -1423,7 +1423,7 @@ static void __init pmu_check_apic(void)
 	pr_info("no hardware sampling interrupt available.\n");
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	struct event_constraint *c;
 	int err;
@@ -1438,11 +1438,11 @@ void __init init_hw_perf_events(void)
 		err = amd_pmu_init();
 		break;
 	default:
-		return;
+		return 0;
 	}
 	if (err != 0) {
 		pr_cont("no PMU driver, software events only.\n");
-		return;
+		return 0;
 	}
 
 	pmu_check_apic();
@@ -1450,7 +1450,7 @@ void __init init_hw_perf_events(void)
 	/* sanity check that the hardware exists or is emulated */
 	if (!check_hw_exists()) {
 		pr_cont("Broken PMU hardware detected, software events only.\n");
-		return;
+		return 0;
 	}
 
 	pr_cont("%s PMU driver.\n", x86_pmu.name);
@@ -1501,7 +1501,10 @@ void __init init_hw_perf_events(void)
 
 	perf_pmu_register(&pmu);
 	perf_cpu_notifier(x86_pmu_notifier);
+
+	return 0;
 }
+early_initcall(init_hw_perf_events);
 
 static inline void x86_pmu_read(struct perf_event *event)
 {
#9 lore raw

Re: [RFC][PATCH 2/8] perf, arch: Use early_initcall() for all arch pmu implementations

Quoted 26 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra

Right, so hw perf init happens from (after this patch):

arch_initcall: powerpc, arm, sh, mips
early_initcall: x86, sparc, alpha

Now the problem is that the generic watchdog code (kernel/watchdog.c) tries to create hw perf events, and that too runs from early_initcall.

So my question is, how do we go about curing this, because powerpc, arm, sh and mips are too late and the rest depends on link order to work, not really a nice situation.

There's two categories of solutions:
- move the watchdog later, and
- move the hw perf init earlier.

Quoted 6 lines

The former is undesired because we want the watchdog as early as possible, the later needs new infrastructure (also, I don't know if the arch implementations can actually run this early).

So do I create a perf_initcall() or is there another solution that avoids things like calling the watchdog code from all arch init code?

Quoted 8 lines

So the perf_event_init() site is _waaay_ to early to init stuff.. I guess I'll move it all to early_initcall() and I'll move the watchdog to an explicit call right after it.

Something like the below,.. now I guess the question to all of you is, can your arch pmu code cope with early_initcall() or does it need to be some other place?

Any of the initcall levels are ok for SH at least. The only dependency we have for the perf code is the clock framework, which comes up during time_init().

#10 lore raw

Re: [RFC][PATCH 2/8] perf, arch: Use early_initcall() for all arch pmu implementations

In reply to Peter Zijlstra
Quoted 8 lines · Peter Zijlstra

So the perf_event_init() site is _waaay_ to early to init stuff.. I guess I'll move it all to early_initcall() and I'll move the watchdog to an explicit call right after it.

Something like the below,.. now I guess the question to all of you is, can your arch pmu code cope with early_initcall() or does it need to be some other place?

The ARM init code basically just parses the CPUID to work out what PMU is available, so it should be safe to call it as early as you like.

Will

#11 lore raw

[tip:perf/core] perf, arch: Cleanup perf-pmu init vs lockup-detector

In reply to Peter Zijlstra
Commit-ID:  004417a6d468e24399e383645c068b498eed84ad
Gitweb:     http://git.kernel.org/tip/004417a6d468e24399e383645c068b498eed84ad
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Thu, 25 Nov 2010 18:38:29 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 26 Nov 2010 15:14:56 +0100

perf, arch: Cleanup perf-pmu init vs lockup-detector

The perf hardware pmu got initialized at various points in the boot, some before early_initcall() some after (notably arch_initcall).

The problem is that the NMI lockup detector is ran from early_initcall() and expects the hardware pmu to be present.

Sanitize this by moving all architecture hardware pmu implementations to initialize at early_initcall() and move the lockup detector to an explicit initcall right after that.

LKML-Reference: <1290707759.2145.119.camel@laptop>

---
 arch/alpha/include/asm/perf_event.h  |    6 ------
 arch/alpha/kernel/irq_alpha.c        |    2 --
 arch/alpha/kernel/perf_event.c       |    9 ++++++---
 arch/arm/kernel/perf_event.c         |    2 +-
 arch/mips/kernel/perf_event_mipsxx.c |    2 +-
 arch/powerpc/kernel/e500-pmu.c       |    2 +-
 arch/powerpc/kernel/mpc7450-pmu.c    |    2 +-
 arch/powerpc/kernel/power4-pmu.c     |    2 +-
 arch/powerpc/kernel/power5+-pmu.c    |    2 +-
 arch/powerpc/kernel/power5-pmu.c     |    2 +-
 arch/powerpc/kernel/power6-pmu.c     |    2 +-
 arch/powerpc/kernel/power7-pmu.c     |    2 +-
 arch/powerpc/kernel/ppc970-pmu.c     |    2 +-
 arch/sh/kernel/cpu/sh4/perf_event.c  |    2 +-
 arch/sh/kernel/cpu/sh4a/perf_event.c |    2 +-
 arch/sparc/include/asm/perf_event.h  |    4 ----
 arch/sparc/kernel/nmi.c              |    2 --
 arch/sparc/kernel/perf_event.c       |    7 +++++--
 arch/x86/include/asm/perf_event.h    |    2 --
 arch/x86/kernel/cpu/common.c         |    1 -
 arch/x86/kernel/cpu/perf_event.c     |   11 +++++++----
 include/linux/sched.h                |    4 ++++
 init/main.c                          |    1 +
 kernel/watchdog.c                    |    7 +++----
 24 files changed, 38 insertions(+), 42 deletions(-)
arch/alpha/include/asm/perf_event.h +0 -6
index fe792ca..5996e7a 100644
@@ -1,10 +1,4 @@
 #ifndef __ASM_ALPHA_PERF_EVENT_H
 #define __ASM_ALPHA_PERF_EVENT_H
 
-#ifdef CONFIG_PERF_EVENTS
-extern void init_hw_perf_events(void);
-#else
-static inline void init_hw_perf_events(void)    { }
-#endif
-
 #endif /* __ASM_ALPHA_PERF_EVENT_H */
arch/alpha/kernel/irq_alpha.c +0 -2
index 5f77afb..4c8bb37 100644
@@ -112,8 +112,6 @@ init_IRQ(void)
 	wrent(entInt, 0);
 
 	alpha_mv.init_irq();
-
-	init_hw_perf_events();
 }
 
 /*
arch/alpha/kernel/perf_event.c +6 -3
index 1cc4968..3283059 100644
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/kdebug.h>
 #include <linux/mutex.h>
+#include <linux/init.h>
 
 #include <asm/hwrpb.h>
 #include <asm/atomic.h>
@@ -863,13 +864,13 @@ static void alpha_perf_event_irq_handler(unsigned long la_ptr,
 /*
  * Init call to initialise performance events at kernel startup.
  */
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	pr_info("Performance events: ");
 
 	if (!supported_cpu()) {
 		pr_cont("No support for your CPU.\n");
-		return;
+		return 0;
 	}
 
 	pr_cont("Supported CPU type!\n");
@@ -882,5 +883,7 @@ void __init init_hw_perf_events(void)
 	alpha_pmu = &ev67_pmu;
 
 	perf_pmu_register(&pmu);
-}
 
+	return 0;
+}
+early_initcall(init_hw_perf_events);
arch/arm/kernel/perf_event.c +1 -1
index 07a5035..d45f70e 100644
@@ -3038,7 +3038,7 @@ init_hw_perf_events(void)
 
 	return 0;
 }
-arch_initcall(init_hw_perf_events);
+early_initcall(init_hw_perf_events);
 
 /*
  * Callchain handling code.
arch/mips/kernel/perf_event_mipsxx.c +1 -1
index 5c7c6fc..183e0d2 100644
@@ -1047,6 +1047,6 @@ init_hw_perf_events(void)
 
 	return 0;
 }
-arch_initcall(init_hw_perf_events);
+early_initcall(init_hw_perf_events);
 
 #endif /* defined(CONFIG_CPU_MIPS32)... */
arch/powerpc/kernel/e500-pmu.c +1 -1
index 7c07de0..b150b51 100644
@@ -126,4 +126,4 @@ static int init_e500_pmu(void)
 	return register_fsl_emb_pmu(&e500_pmu);
 }
 
-arch_initcall(init_e500_pmu);
+early_initcall(init_e500_pmu);
arch/powerpc/kernel/mpc7450-pmu.c +1 -1
index 09d7202..2cc5e03 100644
@@ -414,4 +414,4 @@ static int init_mpc7450_pmu(void)
 	return register_power_pmu(&mpc7450_pmu);
 }
 
-arch_initcall(init_mpc7450_pmu);
+early_initcall(init_mpc7450_pmu);
arch/powerpc/kernel/power4-pmu.c +1 -1
index 2a361cd..ead8b3c 100644
@@ -613,4 +613,4 @@ static int init_power4_pmu(void)
 	return register_power_pmu(&power4_pmu);
 }
 
-arch_initcall(init_power4_pmu);
+early_initcall(init_power4_pmu);
arch/powerpc/kernel/power5+-pmu.c +1 -1
index 199de52..eca0ac5 100644
@@ -682,4 +682,4 @@ static int init_power5p_pmu(void)
 	return register_power_pmu(&power5p_pmu);
 }
 
-arch_initcall(init_power5p_pmu);
+early_initcall(init_power5p_pmu);
arch/powerpc/kernel/power5-pmu.c +1 -1
index 98b6a72..d5ff0f6 100644
@@ -621,4 +621,4 @@ static int init_power5_pmu(void)
 	return register_power_pmu(&power5_pmu);
 }
 
-arch_initcall(init_power5_pmu);
+early_initcall(init_power5_pmu);
arch/powerpc/kernel/power6-pmu.c +1 -1
index 84a607b..3160392 100644
@@ -544,4 +544,4 @@ static int init_power6_pmu(void)
 	return register_power_pmu(&power6_pmu);
 }
 
-arch_initcall(init_power6_pmu);
+early_initcall(init_power6_pmu);
arch/powerpc/kernel/power7-pmu.c +1 -1
index 852f7b7..593740f 100644
@@ -369,4 +369,4 @@ static int init_power7_pmu(void)
 	return register_power_pmu(&power7_pmu);
 }
 
-arch_initcall(init_power7_pmu);
+early_initcall(init_power7_pmu);
arch/powerpc/kernel/ppc970-pmu.c +1 -1
index 3fee685..9a6e093 100644
@@ -494,4 +494,4 @@ static int init_ppc970_pmu(void)
 	return register_power_pmu(&ppc970_pmu);
 }
 
-arch_initcall(init_ppc970_pmu);
+early_initcall(init_ppc970_pmu);
arch/sh/kernel/cpu/sh4/perf_event.c +1 -1
index dbf3b4b..748955d 100644
@@ -250,4 +250,4 @@ static int __init sh7750_pmu_init(void)
 
 	return register_sh_pmu(&sh7750_pmu);
 }
-arch_initcall(sh7750_pmu_init);
+early_initcall(sh7750_pmu_init);
arch/sh/kernel/cpu/sh4a/perf_event.c +1 -1
index 5802765..17e6beb 100644
@@ -284,4 +284,4 @@ static int __init sh4a_pmu_init(void)
 
 	return register_sh_pmu(&sh4a_pmu);
 }
-arch_initcall(sh4a_pmu_init);
+early_initcall(sh4a_pmu_init);
arch/sparc/include/asm/perf_event.h +0 -4
index 6e8bfa1..4d3dbe3 100644
@@ -4,8 +4,6 @@
 #ifdef CONFIG_PERF_EVENTS
 #include <asm/ptrace.h>
 
-extern void init_hw_perf_events(void);
-
 #define perf_arch_fetch_caller_regs(regs, ip)		\
 do {							\
 	unsigned long _pstate, _asi, _pil, _i7, _fp;	\
@@ -26,8 +24,6 @@ do {							\
 	(regs)->u_regs[UREG_I6] = _fp;			\
 	(regs)->u_regs[UREG_I7] = _i7;			\
 } while (0)
-#else
-static inline void init_hw_perf_events(void)	{ }
 #endif
 
 #endif
arch/sparc/kernel/nmi.c +0 -2
index a4bd7ba..300f810 100644
@@ -270,8 +270,6 @@ int __init nmi_init(void)
 			atomic_set(&nmi_active, -1);
 		}
 	}
-	if (!err)
-		init_hw_perf_events();
 
 	return err;
 }
arch/sparc/kernel/perf_event.c +5 -2
index 0d6deb5..75c5b12 100644
@@ -1307,20 +1307,23 @@ static bool __init supported_pmu(void)
 	return false;
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	pr_info("Performance events: ");
 
 	if (!supported_pmu()) {
 		pr_cont("No support for PMU type '%s'\n", sparc_pmu_type);
-		return;
+		return 0;
 	}
 
 	pr_cont("Supported PMU type is '%s'\n", sparc_pmu_type);
 
 	perf_pmu_register(&pmu);
 	register_die_notifier(&perf_event_nmi_notifier);
+
+	return 0;
 }
+early_initcall(init_hw_perf_event);
 
 void perf_callchain_kernel(struct perf_callchain_entry *entry,
 			   struct pt_regs *regs)
arch/x86/include/asm/perf_event.h +0 -2
index 550e26b..d9d4dae 100644
@@ -125,7 +125,6 @@ union cpuid10_edx {
 #define IBS_OP_MAX_CNT_EXT	0x007FFFFFULL	/* not a register bit mask */
 
 #ifdef CONFIG_PERF_EVENTS
-extern void init_hw_perf_events(void);
 extern void perf_events_lapic_init(void);
 
 #define PERF_EVENT_INDEX_OFFSET			0
@@ -156,7 +155,6 @@ extern unsigned long perf_misc_flags(struct pt_regs *regs);
 }
 
 #else
-static inline void init_hw_perf_events(void)		{ }
 static inline void perf_events_lapic_init(void)	{ }
 #endif
 
arch/x86/kernel/cpu/common.c +0 -1
index 4b68bda..1d59834 100644
@@ -894,7 +894,6 @@ void __init identify_boot_cpu(void)
 #else
 	vgetcpu_set_mode();
 #endif
-	init_hw_perf_events();
 }
 
 void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/perf_event.c +7 -4
index c01dfec..817d2b1 100644
@@ -1353,7 +1353,7 @@ static void __init pmu_check_apic(void)
 	pr_info("no hardware sampling interrupt available.\n");
 }
 
-void __init init_hw_perf_events(void)
+int __init init_hw_perf_events(void)
 {
 	struct event_constraint *c;
 	int err;
@@ -1368,11 +1368,11 @@ void __init init_hw_perf_events(void)
 		err = amd_pmu_init();
 		break;
 	default:
-		return;
+		return 0;
 	}
 	if (err != 0) {
 		pr_cont("no PMU driver, software events only.\n");
-		return;
+		return 0;
 	}
 
 	pmu_check_apic();
@@ -1380,7 +1380,7 @@ void __init init_hw_perf_events(void)
 	/* sanity check that the hardware exists or is emulated */
 	if (!check_hw_exists()) {
 		pr_cont("Broken PMU hardware detected, software events only.\n");
-		return;
+		return 0;
 	}
 
 	pr_cont("%s PMU driver.\n", x86_pmu.name);
@@ -1431,7 +1431,10 @@ void __init init_hw_perf_events(void)
 
 	perf_pmu_register(&pmu);
 	perf_cpu_notifier(x86_pmu_notifier);
+
+	return 0;
 }
+early_initcall(init_hw_perf_events);
 
 static inline void x86_pmu_read(struct perf_event *event)
 {
include/linux/sched.h +4 -0
index 2c79e92..d2e63d1 100644
@@ -316,6 +316,7 @@ extern int proc_dowatchdog_thresh(struct ctl_table *table, int write,
 				  size_t *lenp, loff_t *ppos);
 extern unsigned int  softlockup_panic;
 extern int softlockup_thresh;
+void lockup_detector_init(void);
 #else
 static inline void touch_softlockup_watchdog(void)
 {
@@ -326,6 +327,9 @@ static inline void touch_softlockup_watchdog_sync(void)
 static inline void touch_all_softlockup_watchdogs(void)
 {
 }
+static inline void lockup_detector_init(void)
+{
+}
 #endif
 
 #ifdef CONFIG_DETECT_HUNG_TASK
init/main.c +1 -0
index 8646401..261ad7b 100644
@@ -882,6 +882,7 @@ static int __init kernel_init(void * unused)
 	smp_prepare_cpus(setup_max_cpus);
 
 	do_pre_smp_initcalls();
+	lockup_detector_init();
 
 	smp_init();
 	sched_init_smp();
kernel/watchdog.c +3 -4
index 6e3c41a..cad4e42 100644
@@ -547,13 +547,13 @@ static struct notifier_block __cpuinitdata cpu_nfb = {
 	.notifier_call = cpu_callback
 };
 
-static int __init spawn_watchdog_task(void)
+void __init lockup_detector_init(void)
 {
 	void *cpu = (void *)(long)smp_processor_id();
 	int err;
 
 	if (no_watchdog)
-		return 0;
+		return;
 
 	err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
 	WARN_ON(notifier_to_errno(err));
@@ -561,6 +561,5 @@ static int __init spawn_watchdog_task(void)
 	cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
 	register_cpu_notifier(&cpu_nfb);
 
-	return 0;
+	return;
 }
-early_initcall(spawn_watchdog_task);
#12 lore raw

RFC PATCH 3/8 perf: Move perf_event_init() into main.c

In reply to Peter Zijlstra

Currently we call perf_event_init() from sched_init(). In order to make it more obvious move it to the cannnonical location.

---
 init/main.c    |    2 ++
 kernel/sched.c |    2 --
 2 files changed, 2 insertions(+), 2 deletions(-)
init/main.c +2 -0
Index: linux-2.6/init/main.c
===================================================================
@@ -68,6 +68,7 @@
 #include <linux/sfi.h>
 #include <linux/shmem_fs.h>
 #include <linux/slab.h>
+#include <linux/perf_event.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -604,6 +605,7 @@ asmlinkage void __init start_kernel(void
 				"enabled *very* early, fixing it\n");
 		local_irq_disable();
 	}
+	perf_event_init();
 	rcu_init();
 	radix_tree_init();
 	/* init some links before init_ISA_irqs() */
kernel/sched.c +0 -2
Index: linux-2.6/kernel/sched.c
===================================================================
@@ -7876,8 +7876,6 @@ void __init sched_init(void)
 		zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT);
 #endif /* SMP */
 
-	perf_event_init();
-
 	scheduler_running = 1;
 }
 
#13 lore raw

[tip:perf/core] perf: Move perf_event_init() into main.c

Commit-ID:  24a24bb6ff3dc3a09bb131241be920ecc3f0e519
Gitweb:     http://git.kernel.org/tip/24a24bb6ff3dc3a09bb131241be920ecc3f0e519
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Wed, 17 Nov 2010 23:17:33 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 16 Dec 2010 11:36:42 +0100

perf: Move perf_event_init() into main.c

Currently we call perf_event_init() from sched_init(). In order to make it more obvious move it to the cannnonical location.

LKML-Reference: <[email protected]>

---
 init/main.c    |    2 ++
 kernel/sched.c |    2 --
 2 files changed, 2 insertions(+), 2 deletions(-)
init/main.c +2 -0
index 261ad7b..559e862 100644
@@ -67,6 +67,7 @@
 #include <linux/sfi.h>
 #include <linux/shmem_fs.h>
 #include <linux/slab.h>
+#include <linux/perf_event.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -603,6 +604,7 @@ asmlinkage void __init start_kernel(void)
 				"enabled *very* early, fixing it\n");
 		local_irq_disable();
 	}
+	perf_event_init();
 	rcu_init();
 	radix_tree_init();
 	/* init some links before init_ISA_irqs() */
kernel/sched.c +0 -2
index dc91a4d..605ab1b 100644
@@ -8108,8 +8108,6 @@ void __init sched_init(void)
 		zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT);
 #endif /* SMP */
 
-	perf_event_init();
-
 	scheduler_running = 1;
 }
 
#14 lore raw

RFC PATCH 4/8 perf: Use early_initcall() for tracepoint and breakpoint init

In reply to Peter Zijlstra

Just like other pmu implementations, use early_initcall().

---
 kernel/hw_breakpoint.c |    2 +-
 kernel/perf_event.c    |    9 +++------
 2 files changed, 4 insertions(+), 7 deletions(-)
kernel/hw_breakpoint.c +1 -1
Index: linux-2.6/kernel/hw_breakpoint.c
===================================================================
@@ -655,6 +655,6 @@ static int __init init_hw_breakpoint(voi
 
 	return -ENOMEM;
 }
-core_initcall(init_hw_breakpoint);
+early_initcall(init_hw_breakpoint);
 
 
kernel/perf_event.c +3 -6
Index: linux-2.6/kernel/perf_event.c
===================================================================
@@ -4831,10 +4831,12 @@ static struct pmu perf_tracepoint = {
 	.read		= perf_swevent_read,
 };
 
-static inline void perf_tp_register(void)
+static __init int perf_tp_init(void)
 {
 	perf_pmu_register(&perf_tracepoint);
+	return 0;
 }
+early_initcall(perf_tp_init);
 
 static int perf_event_set_filter(struct perf_event *event, void __user *arg)
 {
@@ -4861,10 +4863,6 @@ static void perf_event_free_filter(struc
 
 #else
 
-static inline void perf_tp_register(void)
-{
-}
-
 static int perf_event_set_filter(struct perf_event *event, void __user *arg)
 {
 	return -ENOENT;
@@ -6365,6 +6363,5 @@ void __init perf_event_init(void)
 	perf_pmu_register(&perf_swevent);
 	perf_pmu_register(&perf_cpu_clock);
 	perf_pmu_register(&perf_task_clock);
-	perf_tp_register();
 	perf_cpu_notifier(perf_cpu_notify);
 }
#15 lore raw

RFC PATCH 5/8 init: Initialized IRD earlier

In reply to Peter Zijlstra

perf_event_init() wants to start using IDR trees, its needs in turn are satisfied by mm_init().

---
 init/main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/main.c +1 -1
Index: linux-2.6/init/main.c
===================================================================
@@ -605,6 +605,7 @@ asmlinkage void __init start_kernel(void
 				"enabled *very* early, fixing it\n");
 		local_irq_disable();
 	}
+	idr_init_cache();
 	perf_event_init();
 	rcu_init();
 	radix_tree_init();
@@ -661,7 +662,6 @@ asmlinkage void __init start_kernel(void
 	enable_debug_pagealloc();
 	kmemleak_init();
 	debug_objects_mem_init();
-	idr_init_cache();
 	setup_per_cpu_pageset();
 	numa_policy_init();
 	if (late_time_init)
#16 lore raw

[tip:perf/core] init: Initialized IDR earlier

Commit-ID:  9f58a205c62d0dad1df38d076324a89b1a0f1d65
Gitweb:     http://git.kernel.org/tip/9f58a205c62d0dad1df38d076324a89b1a0f1d65
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Wed, 17 Nov 2010 23:17:35 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 16 Dec 2010 11:36:43 +0100

init: Initialized IDR earlier

perf_event_init() wants to start using IDR trees, its needs in turn are satisfied by mm_init().

LKML-Reference: <[email protected]>

---
 init/main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
init/main.c +1 -1
index 559e862..ea51770 100644
@@ -604,6 +604,7 @@ asmlinkage void __init start_kernel(void)
 				"enabled *very* early, fixing it\n");
 		local_irq_disable();
 	}
+	idr_init_cache();
 	perf_event_init();
 	rcu_init();
 	radix_tree_init();
@@ -660,7 +661,6 @@ asmlinkage void __init start_kernel(void)
 	enable_debug_pagealloc();
 	kmemleak_init();
 	debug_objects_mem_init();
-	idr_init_cache();
 	setup_per_cpu_pageset();
 	numa_policy_init();
 	if (late_time_init)
#17 lore raw

RFC PATCH 6/8 perf: Dynamic pmu types

In reply to Peter Zijlstra

Extend the perf_pmu_register() interface to allow for named and dynamic pmu types.

Because we need to support the existing static types we cannot use dynamic types for everything, hence provide a type argument.

If we want to enumerate the PMUs they need a name, provide one.

---
 arch/alpha/kernel/perf_event.c           |    2 -
 arch/arm/kernel/perf_event.c             |    2 -
 arch/powerpc/kernel/perf_event.c         |    2 -
 arch/powerpc/kernel/perf_event_fsl_emb.c |    2 -
 arch/sh/kernel/perf_event.c              |    2 -
 arch/sparc/kernel/perf_event.c           |    2 -
 arch/x86/kernel/cpu/perf_event.c         |    2 -
 include/linux/perf_event.h               |    5 ++-
 kernel/hw_breakpoint.c                   |    2 -
 kernel/perf_event.c                      |   49 +++++++++++++++++++++++++++----
 10 files changed, 55 insertions(+), 15 deletions(-)
include/linux/perf_event.h +4 -1
Index: linux-2.6/include/linux/perf_event.h
===================================================================
@@ -578,6 +578,9 @@ struct perf_event;
 struct pmu {
 	struct list_head		entry;
 
+	char				*name;
+	int				type;
+
 	int * __percpu			pmu_disable_count;
 	struct perf_cpu_context * __percpu pmu_cpu_context;
 	int				task_ctx_nr;
@@ -901,7 +904,7 @@ struct perf_output_handle {
 
 #ifdef CONFIG_PERF_EVENTS
 
-extern int perf_pmu_register(struct pmu *pmu);
+extern int perf_pmu_register(struct pmu *pmu, char *name, int type);
 extern void perf_pmu_unregister(struct pmu *pmu);
 
 extern int perf_num_counters(void);
kernel/perf_event.c +43 -6

110 lines not on this page · raw message

arch/alpha/kernel/perf_event.c +1 -1
Index: linux-2.6/arch/alpha/kernel/perf_event.c
===================================================================
@@ -882,7 +882,7 @@ int __init init_hw_perf_events(void)
 	/* And set up PMU specification */
 	alpha_pmu = &ev67_pmu;
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 
 	return 0;
 }
arch/arm/kernel/perf_event.c +1 -1
Index: linux-2.6/arch/arm/kernel/perf_event.c
===================================================================
@@ -3034,7 +3034,7 @@ init_hw_perf_events(void)
 		pr_info("no hardware support available\n");
 	}
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 
 	return 0;
 }
arch/powerpc/kernel/perf_event.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/perf_event.c
===================================================================
@@ -1379,7 +1379,7 @@ int register_power_pmu(struct power_pmu 
 		freeze_events_kernel = MMCR0_FCHV;
 #endif /* CONFIG_PPC64 */
 
-	perf_pmu_register(&power_pmu);
+	perf_pmu_register(&power_pmu, "cpu", PERF_TYPE_RAW);
 	perf_cpu_notifier(power_pmu_notifier);
 
 	return 0;
arch/powerpc/kernel/perf_event_fsl_emb.c +1 -1
Index: linux-2.6/arch/powerpc/kernel/perf_event_fsl_emb.c
===================================================================
@@ -681,7 +681,7 @@ int register_fsl_emb_pmu(struct fsl_emb_
 	pr_info("%s performance monitor hardware support registered\n",
 		pmu->name);
 
-	perf_pmu_register(&fsl_emb_pmu);
+	perf_pmu_register(&fsl_emb_pmu, "cpu", PERF_TYPE_RAW);
 
 	return 0;
 }
arch/sh/kernel/perf_event.c +1 -1
Index: linux-2.6/arch/sh/kernel/perf_event.c
===================================================================
@@ -389,7 +389,7 @@ int __cpuinit register_sh_pmu(struct sh_
 
 	WARN_ON(_pmu->num_events > MAX_HWEVENTS);
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 	perf_cpu_notifier(sh_pmu_notifier);
 	return 0;
 }
arch/sparc/kernel/perf_event.c +1 -1
Index: linux-2.6/arch/sparc/kernel/perf_event.c
===================================================================
@@ -1318,7 +1318,7 @@ int __init init_hw_perf_events(void)
 
 	pr_cont("Supported PMU type is '%s'\n", sparc_pmu_type);
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 	register_die_notifier(&perf_event_nmi_notifier);
 
 	return 0;
arch/x86/kernel/cpu/perf_event.c +1 -1
Index: linux-2.6/arch/x86/kernel/cpu/perf_event.c
===================================================================
@@ -1418,7 +1418,7 @@ int __init init_hw_perf_events(void)
 	pr_info("... fixed-purpose events:   %d\n",     x86_pmu.num_counters_fixed);
 	pr_info("... event mask:             %016Lx\n", x86_pmu.intel_ctrl);
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 	perf_cpu_notifier(x86_pmu_notifier);
 
 	return 0;
kernel/hw_breakpoint.c +1 -1
Index: linux-2.6/kernel/hw_breakpoint.c
===================================================================
@@ -641,7 +641,7 @@ static int __init init_hw_breakpoint(voi
 
 	constraints_initialized = 1;
 
-	perf_pmu_register(&perf_breakpoint);
+	perf_pmu_register(&perf_breakpoint, "breakpoint", PERF_TYPE_BREAKPOINT);
 
 	return register_die_notifier(&hw_breakpoint_exceptions_nb);
 
#18 lore raw

[tip:perf/core] perf: Dynamic pmu types

Commit-ID:  2e80a82a49c4c7eca4e35734380f28298ba5db19
Gitweb:     http://git.kernel.org/tip/2e80a82a49c4c7eca4e35734380f28298ba5db19
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Wed, 17 Nov 2010 23:17:36 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 16 Dec 2010 11:36:43 +0100

perf: Dynamic pmu types

Extend the perf_pmu_register() interface to allow for named and dynamic pmu types.

Because we need to support the existing static types we cannot use dynamic types for everything, hence provide a type argument.

If we want to enumerate the PMUs they need a name, provide one.

LKML-Reference: <[email protected]>

---
 arch/alpha/kernel/perf_event.c           |    2 +-
 arch/arm/kernel/perf_event.c             |    2 +-
 arch/powerpc/kernel/perf_event.c         |    2 +-
 arch/powerpc/kernel/perf_event_fsl_emb.c |    2 +-
 arch/sh/kernel/perf_event.c              |    2 +-
 arch/sparc/kernel/perf_event.c           |    2 +-
 arch/x86/kernel/cpu/perf_event.c         |    2 +-
 include/linux/perf_event.h               |    5 ++-
 kernel/hw_breakpoint.c                   |    2 +-
 kernel/perf_event.c                      |   48 ++++++++++++++++++++++++++----
 10 files changed, 54 insertions(+), 15 deletions(-)
arch/alpha/kernel/perf_event.c +1 -1
index 3283059..90561c4 100644
@@ -882,7 +882,7 @@ int __init init_hw_perf_events(void)
 	/* And set up PMU specification */
 	alpha_pmu = &ev67_pmu;
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 
 	return 0;
 }
arch/arm/kernel/perf_event.c +1 -1
index d45f70e..fdfa497 100644
@@ -3034,7 +3034,7 @@ init_hw_perf_events(void)
 		pr_info("no hardware support available\n");
 	}
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 
 	return 0;
 }
arch/powerpc/kernel/perf_event.c +1 -1
index 3129c85..5674807 100644
@@ -1379,7 +1379,7 @@ int register_power_pmu(struct power_pmu *pmu)
 		freeze_events_kernel = MMCR0_FCHV;
 #endif /* CONFIG_PPC64 */
 
-	perf_pmu_register(&power_pmu);
+	perf_pmu_register(&power_pmu, "cpu", PERF_TYPE_RAW);
 	perf_cpu_notifier(power_pmu_notifier);
 
 	return 0;
arch/powerpc/kernel/perf_event_fsl_emb.c +1 -1
index 7ecca59..4dcf5f8 100644
@@ -681,7 +681,7 @@ int register_fsl_emb_pmu(struct fsl_emb_pmu *pmu)
 	pr_info("%s performance monitor hardware support registered\n",
 		pmu->name);
 
-	perf_pmu_register(&fsl_emb_pmu);
+	perf_pmu_register(&fsl_emb_pmu, "cpu", PERF_TYPE_RAW);
 
 	return 0;
 }
arch/sh/kernel/perf_event.c +1 -1
index 5a4b334..2ee21a4 100644
@@ -389,7 +389,7 @@ int __cpuinit register_sh_pmu(struct sh_pmu *_pmu)
 
 	WARN_ON(_pmu->num_events > MAX_HWEVENTS);
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 	perf_cpu_notifier(sh_pmu_notifier);
 	return 0;
 }
arch/sparc/kernel/perf_event.c +1 -1
index 39348b1..7605786 100644
@@ -1318,7 +1318,7 @@ int __init init_hw_perf_events(void)
 
 	pr_cont("Supported PMU type is '%s'\n", sparc_pmu_type);
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 	register_die_notifier(&perf_event_nmi_notifier);
 
 	return 0;
arch/x86/kernel/cpu/perf_event.c +1 -1
index ce27c54..0a360d1 100644
@@ -1465,7 +1465,7 @@ int __init init_hw_perf_events(void)
 	pr_info("... fixed-purpose events:   %d\n",     x86_pmu.num_counters_fixed);
 	pr_info("... event mask:             %016Lx\n", x86_pmu.intel_ctrl);
 
-	perf_pmu_register(&pmu);
+	perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
 	perf_cpu_notifier(x86_pmu_notifier);
 
 	return 0;
include/linux/perf_event.h +4 -1
index 30e50e2..21206d2 100644
@@ -588,6 +588,9 @@ struct perf_event;
 struct pmu {
 	struct list_head		entry;
 
+	char				*name;
+	int				type;
+
 	int * __percpu			pmu_disable_count;
 	struct perf_cpu_context * __percpu pmu_cpu_context;
 	int				task_ctx_nr;
@@ -916,7 +919,7 @@ struct perf_output_handle {
 
 #ifdef CONFIG_PERF_EVENTS
 
-extern int perf_pmu_register(struct pmu *pmu);
+extern int perf_pmu_register(struct pmu *pmu, char *name, int type);
 extern void perf_pmu_unregister(struct pmu *pmu);
 
 extern int perf_num_counters(void);
kernel/hw_breakpoint.c +1 -1
index e532582..086adf2 100644
@@ -641,7 +641,7 @@ int __init init_hw_breakpoint(void)
 
 	constraints_initialized = 1;
 
-	perf_pmu_register(&perf_breakpoint);
+	perf_pmu_register(&perf_breakpoint, "breakpoint", PERF_TYPE_BREAKPOINT);
 
 	return register_die_notifier(&hw_breakpoint_exceptions_nb);
 
kernel/perf_event.c +42 -6

105 lines not on this page · raw message

#19 lore raw

RFC PATCH 7/8 perf: Sysfs enumeration

In reply to Peter Zijlstra

Simple sysfs emumeration of the PMUs.

Use a "event_source" bus, and add PMU devices using their name.

Each PMU device has a type attribute which contrains the value needed for perf_event_attr::type to identify this PMU.

---
 include/linux/perf_event.h |    1 
 kernel/perf_event.c        |   94 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 94 insertions(+), 1 deletion(-)
include/linux/perf_event.h +1 -0
Index: linux-2.6/include/linux/perf_event.h
===================================================================
@@ -578,6 +578,7 @@ struct perf_event;
 struct pmu {
 	struct list_head		entry;
 
+	struct device			*dev;
 	char				*name;
 	int				type;
 
kernel/perf_event.c +93 -1

140 lines not on this page · raw message

#20 lore raw

[tip:perf/core] perf: Sysfs enumeration

Commit-ID:  abe43400579d5de0078c2d3a760e6598e183f871
Gitweb:     http://git.kernel.org/tip/abe43400579d5de0078c2d3a760e6598e183f871
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Wed, 17 Nov 2010 23:17:37 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 16 Dec 2010 11:36:43 +0100

perf: Sysfs enumeration

Simple sysfs emumeration of the PMUs.

Use a "event_source" bus, and add PMU devices using their name.

Each PMU device has a type attribute which contrains the value needed for perf_event_attr::type to identify this PMU.

This is the minimal stub needed to start using this interface, we'll consider extending the sysfs usage later.

LKML-Reference: <[email protected]>

---
 include/linux/perf_event.h |    1 +
 kernel/perf_event.c        |   95 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 95 insertions(+), 1 deletions(-)
include/linux/perf_event.h +1 -0
index 21206d2..dda5b0a 100644
@@ -588,6 +588,7 @@ struct perf_event;
 struct pmu {
 	struct list_head		entry;
 
+	struct device			*dev;
 	char				*name;
 	int				type;
 
kernel/perf_event.c +94 -1

134 lines not on this page · raw message

#21 lore raw

RFC PATCH 8/8 perf: Sysfs events

In reply to Peter Zijlstra

Simple example of a static event enumeration,.. need to come up with something more dynamic for things like trace-events which can come and go during the life-time of a struct pmu.

---
 arch/x86/kernel/cpu/perf_event.c |   51 ++++++++++++++++++++++++++++++++++++
 include/linux/perf_event.h       |    1 
 kernel/perf_event.c              |   55 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+)
include/linux/perf_event.h +1 -0
Index: linux-2.6/include/linux/perf_event.h
===================================================================
@@ -578,6 +578,7 @@ struct perf_event;
 struct pmu {
 	struct list_head		entry;
 
+	const struct attribute_group	**groups;
 	struct device			*dev;
 	char				*name;
 	int				type;
kernel/perf_event.c +55 -0

68 lines not on this page · raw message

arch/x86/kernel/cpu/perf_event.c +51 -0

64 lines not on this page · raw message