Subject: frame_info_init in 2.6 kernel

From: Atsushi Nemoto <[email-masked]>
Date: Thu, 20 Nov 2003 16:50:28 +0900 (JST)

I suppose everybody running 2.6 mips kernel see this error message:

> Can't analyze prologue code at XXXXXXXX

XXXXXXXX is an address of schedule_timeout function.

This is because schedule_timeout was moved to timer.c from sched.c and
therefore compiled without -fno-omit-frame-pointer.

If the error is detected, get_wchan does not work so the "ps lw"
command can not print WCHAN field correctly.

How about this patch?

--- arch/mips/kernel/process.c.org	Thu Nov 20 16:34:45 2003
+++ arch/mips/kernel/process.c	Thu Nov 20 16:38:39 2003
@@ -251,12 +251,20 @@
 
 static int __init frame_info_init(void)
 {
-	mips_frame_info_initialized =
-		!get_frame_info(&schedule_frame, schedule) &&
-		!get_frame_info(&schedule_timeout_frame, schedule_timeout) &&
-		!get_frame_info(&sleep_on_frame, sleep_on) &&
-		!get_frame_info(&sleep_on_timeout_frame, sleep_on_timeout) &&
-		!get_frame_info(&wait_for_completion_frame, wait_for_completion);
+	/* in 2.6 kernel, schedule_timout is out of [first_sched,last_sched] */
+	if ((unsigned long)schedule_timeout < first_sched ||
+	    (unsigned long)schedule_timeout >= last_sched)
+		mips_frame_info_initialized =
+			!get_frame_info(&schedule_frame, schedule) &&
+			!get_frame_info(&sleep_on_frame, sleep_on) &&
+			!get_frame_info(&wait_for_completion_frame, wait_for_completion);
+	else
+		mips_frame_info_initialized =
+			!get_frame_info(&schedule_frame, schedule) &&
+			!get_frame_info(&schedule_timeout_frame, schedule_timeout) &&
+			!get_frame_info(&sleep_on_frame, sleep_on) &&
+			!get_frame_info(&sleep_on_timeout_frame, sleep_on_timeout) &&
+			!get_frame_info(&wait_for_completion_frame, wait_for_completion);
 
 	return 0;
 }
@@ -323,6 +331,9 @@
 	goto out;
 
 schedule_timeout_caller:
+	if ((unsigned long)schedule_timeout < first_sched ||
+	    (unsigned long)schedule_timeout >= last_sched)
+		return pc;	/* failsafe */
 	/*
 	 * The schedule_timeout frame
 	 */
---
Atsushi Nemoto