[PATCH 01/10] perf_counter: fix uninitialized usage of event_list

From: Peter Zijlstra
Date: Thu Mar 19 2009 - 15:46:16 EST


When doing the generic context switch event I ran into some early boot
hangs, which were caused by inf func recursion (event, fault, event, fault).

I eventually tracked it down to event_list not being initialized at the
time of the first event. Fix this.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
include/linux/init_task.h | 2 ++
kernel/perf_counter.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -1506,7 +1506,7 @@ static void perf_swcounter_ctx_event(str
{
struct perf_counter *counter;

- if (list_empty(&ctx->event_list))
+ if (system_state != SYSTEM_RUNNING || list_empty(&ctx->event_list))
return;

rcu_read_lock();
Index: linux-2.6/include/linux/init_task.h
===================================================================
--- linux-2.6.orig/include/linux/init_task.h
+++ linux-2.6/include/linux/init_task.h
@@ -124,6 +124,8 @@ extern struct cred init_cred;
# define INIT_PERF_COUNTERS(tsk) \
.perf_counter_ctx.counter_list = \
LIST_HEAD_INIT(tsk.perf_counter_ctx.counter_list), \
+ .perf_counter_ctx.event_list = \
+ LIST_HEAD_INIT(tsk.perf_counter_ctx.event_list), \
.perf_counter_ctx.lock = \
__SPIN_LOCK_UNLOCKED(tsk.perf_counter_ctx.lock),
#else

--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/