All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf,hw_breakpoint: Initialize hardware api earlier
@ 2010-11-04 22:53 Jason Wessel
  2010-11-05 15:17 ` Frederic Weisbecker
  2010-11-18 14:04 ` [tip:perf/urgent] " tip-bot for Jason Wessel
  0 siblings, 2 replies; 3+ messages in thread
From: Jason Wessel @ 2010-11-04 22:53 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: Ingo Molnar, Peter Zijlstra, lkml


Hi Frederic,

Per our conversation, here is a possible patch to fix the early
debugging.  It might be the case that you can kill off the return code
from the init_hw_breakpoint(), or at least do something with it.  It
was not obvious to me what you might want to emit for a mess or act on
if the initialization fails.


Thanks,
Jason.


--
>From 7c425dba3a4522343faf3519f3d0e99e2e55f30c Mon Sep 17 00:00:00 2001
From: Jason Wessel <jason.wessel@windriver.com>
Date: Thu, 4 Nov 2010 17:33:01 -0500
Subject: [PATCH] perf,hw_breakpoint: Initialize hardware api earlier

When using early debugging, the kernel does not initialize the
hw_breakpoint API early enough and causes the late initialization of
the kernel debugger to fail. The boot arguments are:

    earlyprintk=vga ekgdboc=kbd kgdbwait

Then simply type "go" at the kdb prompt and boot. The kernel will
later emit the message:

    kgdb: Could not allocate hwbreakpoints

And at that point the kernel debugger will cease to work correctly.

The solution is to initialize the hw_breakpoint at the same time that
all the other perf call backs are initialized instead of using a
core_initcall() initialization which happens well after the kernel
debugger can make use of hardware breakpoints.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Ingo Molnar <mingo@elte.hu>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/hw_breakpoint.h |    4 ++++
 kernel/hw_breakpoint.c        |    3 +--
 kernel/perf_event.c           |    2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index a2d6ea4..d9d1799 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -33,6 +33,8 @@ enum bp_type_idx {
 
 #ifdef CONFIG_HAVE_HW_BREAKPOINT
 
+extern int __init init_hw_breakpoint(void);
+
 static inline void hw_breakpoint_init(struct perf_event_attr *attr)
 {
 	memset(attr, 0, sizeof(*attr));
@@ -108,6 +110,8 @@ static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
 
 #else /* !CONFIG_HAVE_HW_BREAKPOINT */
 
+static inline extern int __init init_hw_breakpoint(void) { return 0; }
+
 static inline struct perf_event *
 register_user_hw_breakpoint(struct perf_event_attr *attr,
 			    perf_overflow_handler_t triggered,
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
index 2c9120f..e532582 100644
--- a/kernel/hw_breakpoint.c
+++ b/kernel/hw_breakpoint.c
@@ -620,7 +620,7 @@ static struct pmu perf_breakpoint = {
 	.read		= hw_breakpoint_pmu_read,
 };
 
-static int __init init_hw_breakpoint(void)
+int __init init_hw_breakpoint(void)
 {
 	unsigned int **task_bp_pinned;
 	int cpu, err_cpu;
@@ -655,6 +655,5 @@ static int __init init_hw_breakpoint(void)
 
 	return -ENOMEM;
 }
-core_initcall(init_hw_breakpoint);
 
 
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 517d827..b1eb5c6 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -31,6 +31,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/perf_event.h>
 #include <linux/ftrace_event.h>
+#include <linux/hw_breakpoint.h>
 
 #include <asm/irq_regs.h>
 
@@ -6302,4 +6303,5 @@ void __init perf_event_init(void)
 	perf_pmu_register(&perf_task_clock);
 	perf_tp_register();
 	perf_cpu_notifier(perf_cpu_notify);
+	init_hw_breakpoint();
 }
-- 
1.6.3.3


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

* Re: [PATCH] perf,hw_breakpoint: Initialize hardware api earlier
  2010-11-04 22:53 [PATCH] perf,hw_breakpoint: Initialize hardware api earlier Jason Wessel
@ 2010-11-05 15:17 ` Frederic Weisbecker
  2010-11-18 14:04 ` [tip:perf/urgent] " tip-bot for Jason Wessel
  1 sibling, 0 replies; 3+ messages in thread
From: Frederic Weisbecker @ 2010-11-05 15:17 UTC (permalink / raw)
  To: Jason Wessel; +Cc: Ingo Molnar, Peter Zijlstra, lkml

2010/11/4 Jason Wessel <jason.wessel@windriver.com>:
>
> Hi Frederic,
>
> Per our conversation, here is a possible patch to fix the early
> debugging.  It might be the case that you can kill off the return code
> from the init_hw_breakpoint(), or at least do something with it.  It
> was not obvious to me what you might want to emit for a mess or act on
> if the initialization fails.



Ok, we can kill the return code from it, but we need to keep some
warnings in case
of failure.


>
>
> Thanks,
> Jason.
>
>
> --
> From 7c425dba3a4522343faf3519f3d0e99e2e55f30c Mon Sep 17 00:00:00 2001
> From: Jason Wessel <jason.wessel@windriver.com>
> Date: Thu, 4 Nov 2010 17:33:01 -0500
> Subject: [PATCH] perf,hw_breakpoint: Initialize hardware api earlier
>
> When using early debugging, the kernel does not initialize the
> hw_breakpoint API early enough and causes the late initialization of
> the kernel debugger to fail. The boot arguments are:
>
>    earlyprintk=vga ekgdboc=kbd kgdbwait
>
> Then simply type "go" at the kdb prompt and boot. The kernel will
> later emit the message:
>
>    kgdb: Could not allocate hwbreakpoints
>
> And at that point the kernel debugger will cease to work correctly.
>
> The solution is to initialize the hw_breakpoint at the same time that
> all the other perf call backs are initialized instead of using a
> core_initcall() initialization which happens well after the kernel
> debugger can make use of hardware breakpoints.
>
> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---


For the rest, it looks good.

Thanks!

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

* [tip:perf/urgent] perf,hw_breakpoint: Initialize hardware api earlier
  2010-11-04 22:53 [PATCH] perf,hw_breakpoint: Initialize hardware api earlier Jason Wessel
  2010-11-05 15:17 ` Frederic Weisbecker
@ 2010-11-18 14:04 ` tip-bot for Jason Wessel
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Jason Wessel @ 2010-11-18 14:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, jason.wessel, fweisbec,
	tglx, mingo

Commit-ID:  3c502e7a0255d82621ff25d60cc816624830497e
Gitweb:     http://git.kernel.org/tip/3c502e7a0255d82621ff25d60cc816624830497e
Author:     Jason Wessel <jason.wessel@windriver.com>
AuthorDate: Thu, 4 Nov 2010 17:33:01 -0500
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Fri, 12 Nov 2010 14:51:55 +0100

perf,hw_breakpoint: Initialize hardware api earlier

When using early debugging, the kernel does not initialize the
hw_breakpoint API early enough and causes the late initialization of
the kernel debugger to fail. The boot arguments are:

    earlyprintk=vga ekgdboc=kbd kgdbwait

Then simply type "go" at the kdb prompt and boot. The kernel will
later emit the message:

    kgdb: Could not allocate hwbreakpoints

And at that point the kernel debugger will cease to work correctly.

The solution is to initialize the hw_breakpoint at the same time that
all the other perf call backs are initialized instead of using a
core_initcall() initialization which happens well after the kernel
debugger can make use of hardware breakpoints.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Ingo Molnar <mingo@elte.hu>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <4CD3396D.1090308@windriver.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 include/linux/hw_breakpoint.h |    4 ++++
 kernel/hw_breakpoint.c        |    3 +--
 kernel/perf_event.c           |    6 ++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index a2d6ea4..d1e55fe 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -33,6 +33,8 @@ enum bp_type_idx {
 
 #ifdef CONFIG_HAVE_HW_BREAKPOINT
 
+extern int __init init_hw_breakpoint(void);
+
 static inline void hw_breakpoint_init(struct perf_event_attr *attr)
 {
 	memset(attr, 0, sizeof(*attr));
@@ -108,6 +110,8 @@ static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
 
 #else /* !CONFIG_HAVE_HW_BREAKPOINT */
 
+static inline int __init init_hw_breakpoint(void) { return 0; }
+
 static inline struct perf_event *
 register_user_hw_breakpoint(struct perf_event_attr *attr,
 			    perf_overflow_handler_t triggered,
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
index 2c9120f..e532582 100644
--- a/kernel/hw_breakpoint.c
+++ b/kernel/hw_breakpoint.c
@@ -620,7 +620,7 @@ static struct pmu perf_breakpoint = {
 	.read		= hw_breakpoint_pmu_read,
 };
 
-static int __init init_hw_breakpoint(void)
+int __init init_hw_breakpoint(void)
 {
 	unsigned int **task_bp_pinned;
 	int cpu, err_cpu;
@@ -655,6 +655,5 @@ static int __init init_hw_breakpoint(void)
 
 	return -ENOMEM;
 }
-core_initcall(init_hw_breakpoint);
 
 
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 517d827..05b7d8c 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -31,6 +31,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/perf_event.h>
 #include <linux/ftrace_event.h>
+#include <linux/hw_breakpoint.h>
 
 #include <asm/irq_regs.h>
 
@@ -6295,6 +6296,8 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
 
 void __init perf_event_init(void)
 {
+	int ret;
+
 	perf_event_init_all_cpus();
 	init_srcu_struct(&pmus_srcu);
 	perf_pmu_register(&perf_swevent);
@@ -6302,4 +6305,7 @@ void __init perf_event_init(void)
 	perf_pmu_register(&perf_task_clock);
 	perf_tp_register();
 	perf_cpu_notifier(perf_cpu_notify);
+
+	ret = init_hw_breakpoint();
+	WARN(ret, "hw_breakpoint initialization failed with: %d", ret);
 }

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

end of thread, other threads:[~2010-11-18 14:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-04 22:53 [PATCH] perf,hw_breakpoint: Initialize hardware api earlier Jason Wessel
2010-11-05 15:17 ` Frederic Weisbecker
2010-11-18 14:04 ` [tip:perf/urgent] " tip-bot for Jason Wessel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.