Skip to contentSkip to conversation

use ELF sections for get_wchan()

PATCH William Lee Irwin III 4 participants 10 messages Nov 18, 2003 – Nov 20, 2003

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

I noticed a bunch of "FIXME: this depends on the order of these functions" comments in/around wchan calculations.

So I decided I'd remove the dependency on the order of the functions by dumping them all into an ELF section with clear delimiters.

-- wli

arch/alpha/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/alpha/kernel/process.c
@@ -513,11 +513,6 @@ thread_saved_pc(task_t *t)
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long
 get_wchan(struct task_struct *p)
 {
@@ -536,7 +531,8 @@ get_wchan(struct task_struct *p)
 	 */
 
 	pc = thread_saved_pc(p);
-	if (pc >= first_sched && pc < last_sched) {
+	if (pc >= scheduling_functions_start_here &&
+			pc < scheduling_functions_end_here) {
 		schedule_frame = ((unsigned long *)p->thread_info->pcb.ksp)[6];
 		return ((unsigned long *)schedule_frame)[12];
 	}
arch/alpha/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/alpha/kernel/vmlinux.lds.S
@@ -17,6 +17,9 @@ SECTIONS
   _text = .;					/* Text and read-only data */
   .text : { 
 	*(.text) 
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
   } :kernel
arch/arm/boot/compressed/vmlinux.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm/boot/compressed/vmlinux.lds.in wchan-2.6.0-test9-bk22-1/arch/arm/boot/compressed/vmlinux.lds.in
@@ -21,6 +21,9 @@ SECTIONS
     _start = .;
     *(.start)
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.gnu.warning)
     *(.rodata)
arch/arm/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/arm/kernel/process.c
@@ -415,11 +415,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, lr;
@@ -434,7 +429,8 @@ unsigned long get_wchan(struct task_stru
 		if (fp < stack_page || fp > 4092+stack_page)
 			return 0;
 		lr = pc_pointer (((unsigned long *)fp)[-1]);
-		if (lr < first_sched || lr > last_sched)
+		if (lr < scheduling_functions_start_here ||
+				lr > scheduling_functions_end_here)
 			return lr;
 		fp = *(unsigned long *) (fp - 12);
 	} while (count ++ < 16);
arch/arm/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/arm/kernel/vmlinux.lds.S
@@ -73,6 +73,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.text.sched)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/arm26/boot/compressed/vmlinux.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/boot/compressed/vmlinux.lds.in wchan-2.6.0-test9-bk22-1/arch/arm26/boot/compressed/vmlinux.lds.in
@@ -21,6 +21,9 @@ SECTIONS
     _start = .;
     *(.start)
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.gnu.warning)
     *(.rodata)
arch/arm26/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/process.c
@@ -400,11 +400,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, lr;
@@ -419,7 +414,8 @@ unsigned long get_wchan(struct task_stru
 		if (fp < stack_page || fp > 4092+stack_page)
 			return 0;
 		lr = pc_pointer (((unsigned long *)fp)[-1]);
-		if (lr < first_sched || lr > last_sched)
+		if (lr < scheduling_functions_start_here ||
+				lr > scheduling_functions_end_here)
 			return lr;
 		fp = *(unsigned long *) (fp - 12);
 	} while (count ++ < 16);
arch/arm26/kernel/vmlinux-arm26-xip.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/vmlinux-arm26-xip.lds.in wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/vmlinux-arm26-xip.lds.in
@@ -66,6 +66,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.text.sched)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/arm26/kernel/vmlinux-arm26.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/vmlinux-arm26.lds.in wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/vmlinux-arm26.lds.in
@@ -67,6 +67,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.text.sched)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/cris/arch-v10/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/cris/arch-v10/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/cris/arch-v10/vmlinux.lds.S
@@ -25,6 +25,9 @@ SECTIONS
 	__stext = .;
 	.text : {
 		*(.text)
+		__scheduling_functions_start_here = .;
+		*(.text.sched)
+		__scheduling_functions_end_here = .;
 		*(.fixup)
 		*(.text.__*)
 	}
arch/h8300/kernel/process.c +2 -7
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/h8300/kernel/process.c
@@ -264,11 +264,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
 	return ((struct pt_regs *)tsk->thread.esp0)->pc;
@@ -289,8 +284,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/h8300/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/h8300/kernel/vmlinux.lds.S
@@ -82,6 +82,9 @@ SECTIONS
 #endif
 	__stext = . ;
         	*(.text)
+	__scheduling_functions_start_here = .;
+		*(.text.sched)
+	__scheduling_functions_end_here = .;
 	. = ALIGN(0x4) ;
 		*(.exit.text)
 		*(.text.*)
arch/i386/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/i386/kernel/process.c
@@ -631,11 +631,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ebp, esp, eip;
@@ -653,14 +648,13 @@ unsigned long get_wchan(struct task_stru
 		if (ebp < stack_page || ebp > 8184+stack_page)
 			return 0;
 		eip = *(unsigned long *) (ebp+4);
-		if (eip < first_sched || eip >= last_sched)
+		if (eip < scheduling_functions_start_here ||
+				eip >= scheduling_functions_end_here)
 			return eip;
 		ebp = *(unsigned long *) ebp;
 	} while (count++ < 16);
 	return 0;
 }
-#undef last_sched
-#undef first_sched
 
 /*
  * sys_alloc_thread_area: get a yet unused TLS descriptor index.
arch/i386/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/i386/kernel/vmlinux.lds.S
@@ -15,6 +15,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
arch/ia64/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ia64/kernel/process.c
@@ -638,11 +638,6 @@ get_wchan (struct task_struct *p)
 	/*
 	 * These bracket the sleeping functions..
 	 */
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
-#	define first_sched	((unsigned long) scheduling_functions_start_here)
-#	define last_sched	((unsigned long) scheduling_functions_end_here)
-
 	/*
 	 * Note: p may not be a blocked task (it could be current or
 	 * another process running on some other CPU.  Rather than
@@ -656,12 +651,11 @@ get_wchan (struct task_struct *p)
 		if (unw_unwind(&info) < 0)
 			return 0;
 		unw_get_ip(&info, &ip);
-		if (ip < first_sched || ip >= last_sched)
+		if (ip < scheduling_functions_start_here ||
+				ip >= scheduling_functions_end_here)
 			return ip;
 	} while (count++ < 16);
 	return 0;
-#	undef first_sched
-#	undef last_sched
 }
 
 void
arch/ia64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ia64/kernel/vmlinux.lds.S
@@ -35,6 +35,9 @@ SECTIONS
     {
 	*(.text.ivt)
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.gnu.linkonce.t*)
     }
   .text2 : AT(ADDR(.text2) - LOAD_OFFSET)
arch/m68k/kernel/process.c +4 -11
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/process.c
@@ -65,12 +65,10 @@ asmlinkage void ret_from_fork(void);
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
 	struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
 	/* Check whether the thread is blocked in resume() */
-	if (sw->retpc > (unsigned long)scheduling_functions_start_here &&
-	    sw->retpc < (unsigned long)scheduling_functions_end_here)
+	if (sw->retpc > scheduling_functions_start_here &&
+	    sw->retpc < scheduling_functions_end_here)
 		return ((unsigned long *)sw->a6)[1];
 	else
 		return sw->retpc;
@@ -387,11 +385,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, pc;
@@ -407,8 +400,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/m68k/kernel/vmlinux-std.lds +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/vmlinux-std.lds wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/vmlinux-std.lds
@@ -12,6 +12,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x4e75
arch/m68k/kernel/vmlinux-sun3.lds +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/vmlinux-sun3.lds wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/vmlinux-sun3.lds
@@ -13,6 +13,9 @@ SECTIONS
   .text : {
 	*(.head)
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x4e75
arch/m68knommu/kernel/process.c +4 -11
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/m68knommu/kernel/process.c
@@ -406,11 +406,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, pc;
@@ -426,8 +421,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
@@ -439,13 +434,11 @@ unsigned long get_wchan(struct task_stru
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
 	struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
 
 	/* Check whether the thread is blocked in resume() */
-	if (sw->retpc > (unsigned long)scheduling_functions_start_here &&
-	    sw->retpc < (unsigned long)scheduling_functions_end_here)
+	if (sw->retpc > scheduling_functions_start_here &&
+	    sw->retpc < scheduling_functions_end_here)
 		return ((unsigned long *)sw->a6)[1];
 	else
 		return sw->retpc;
arch/m68knommu/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/m68knommu/kernel/vmlinux.lds.S
@@ -191,6 +191,9 @@ SECTIONS {
 	.text : {
 		_stext = . ;
         	*(.text)
+		__scheduling_functions_start_here = .;
+		*(.text.sched)
+		__scheduling_functions_end_here = .;
         	*(.text.lock)
 
 		. = ALIGN(16);          /* Exception table              */
arch/mips/kernel/process.c +4 -7
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/mips/kernel/process.c
@@ -276,11 +276,6 @@ unsigned long thread_saved_pc(struct tas
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 /* get_wchan - a maintenance nightmare^W^Wpain in the ass ...  */
 unsigned long get_wchan(struct task_struct *p)
 {
@@ -292,7 +287,8 @@ unsigned long get_wchan(struct task_stru
 	if (!mips_frame_info_initialized)
 		return 0;
 	pc = thread_saved_pc(p);
-	if (pc < first_sched || pc >= last_sched)
+	if (pc < scheduling_functions_start_here ||
+			pc >= scheduling_functions_end_here)
 		goto out;
 
 	if (pc >= (unsigned long) sleep_on_timeout)
@@ -326,7 +322,8 @@ schedule_timeout_caller:
 	 */
 	pc    = ((unsigned long *)frame)[schedule_timeout_frame.pc_offset];
 
-	if (pc >= first_sched && pc < last_sched) {
+	if (pc >= scheduling_functions_start_here &&
+			pc < scheduling_functions_end_here) {
 		/* schedule_timeout called by [interruptible_]sleep_on_timeout */
 		frame = ((unsigned long *)frame)[schedule_timeout_frame.frame_offset];
 		pc    = ((unsigned long *)frame)[sleep_on_timeout_frame.pc_offset];
arch/mips/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/mips/kernel/vmlinux.lds.S
@@ -27,6 +27,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.gnu.warning)
   } =0
arch/parisc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/parisc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/parisc/kernel/vmlinux.lds.S
@@ -24,6 +24,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text BLOCK(16) : {
 	*(.text*)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here =.;
 	*(.PARISC.unwind)
 	*(.fixup)
 	*(.lock.text)		/* out-of-line lock text */
arch/ppc/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ppc/kernel/process.c
@@ -650,11 +650,6 @@ void __init ll_puts(const char *s)
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched    ((unsigned long) scheduling_functions_start_here)
-#define last_sched     ((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ip, sp;
@@ -669,7 +664,8 @@ unsigned long get_wchan(struct task_stru
 			return 0;
 		if (count > 0) {
 			ip = *(unsigned long *)(sp + 4);
-			if (ip < first_sched || ip >= last_sched)
+			if (ip < scheduling_functions_start_here ||
+					ip >= scheduling_functions_end_here)
 				return ip;
 		}
 	} while (count++ < 16);
arch/ppc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ppc/kernel/vmlinux.lds.S
@@ -31,6 +31,9 @@ SECTIONS
   .text      :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.got1)
     __got2_start = .;
arch/ppc64/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ppc64/kernel/process.c
@@ -369,11 +369,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched    (*(unsigned long *)scheduling_functions_start_here)
-#define last_sched     (*(unsigned long *)scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ip, sp;
@@ -393,7 +388,8 @@ unsigned long get_wchan(struct task_stru
 			 * XXX we mask the upper 32 bits until procps
 			 * gets fixed.
 			 */
-			if (ip < first_sched || ip >= last_sched)
+			if (ip < scheduling_functions_start_here ||
+					ip >= scheduling_functions_end_here)
 				return (ip & 0xFFFFFFFF);
 		}
 	} while (count++ < 16);
arch/ppc64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ppc64/kernel/vmlinux.lds.S
@@ -33,6 +33,9 @@ SECTIONS
   .text      :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.got1)
   }
arch/s390/kernel/process.c +2 -9
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/s390/kernel/process.c
@@ -371,11 +371,6 @@ void dump_thread(struct pt_regs * regs, 
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long r14, r15, bc;
@@ -398,12 +393,10 @@ unsigned long get_wchan(struct task_stru
 #else
 		r14 = *(unsigned long *) (bc+112);
 #endif
-		if (r14 < first_sched || r14 >= last_sched)
+		if (r14 < scheduling_functions_start_here ||
+				r14 >= scheduling_functions_end_here)
 			return r14;
 		bc = (*(unsigned long *) bc) & PSW_ADDR_INSN;
 	} while (count++ < 16);
 	return 0;
 }
-#undef last_sched
-#undef first_sched
-
arch/s390/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/s390/kernel/vmlinux.lds.S
@@ -23,6 +23,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x0700
arch/sh/kernel/process.c +0 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sh/kernel/process.c
@@ -375,11 +375,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long schedule_frame;
arch/sh/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sh/kernel/vmlinux.lds.S
@@ -22,6 +22,9 @@ SECTIONS
 	} = 0
   .text : {
 	*(.text)
+	__scheduling_functions_start_here =.;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x0009
arch/sparc/kernel/process.c +2 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sparc/kernel/process.c
@@ -692,9 +692,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 	return retval;
 }
 
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-
 unsigned long get_wchan(struct task_struct *task)
 {
 	unsigned long pc, fp, bias = 0;
@@ -715,8 +712,8 @@ unsigned long get_wchan(struct task_stru
 			break;
 		rw = (struct reg_window *) fp;
 		pc = rw->ins[7];
-		if (pc < ((unsigned long) scheduling_functions_start_here) ||
-                    pc >= ((unsigned long) scheduling_functions_end_here)) {
+		if (pc < scheduling_functions_start_here ||
+                    pc >= scheduling_functions_end_here) {
 			ret = pc;
 			goto out;
 		}
arch/sparc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sparc/kernel/vmlinux.lds.S
@@ -12,6 +12,9 @@ SECTIONS
   .text 0xf0004000 :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.gnu.warning)
   } =0
   _etext = .;
arch/sparc64/kernel/process.c +2 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sparc64/kernel/process.c
@@ -824,9 +824,6 @@ out:
 	return error;
 }
 
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-
 unsigned long get_wchan(struct task_struct *task)
 {
 	unsigned long pc, fp, bias = 0;
@@ -850,8 +847,8 @@ unsigned long get_wchan(struct task_stru
 			break;
 		rw = (struct reg_window *) fp;
 		pc = rw->ins[7];
-		if (pc < ((unsigned long) scheduling_functions_start_here) ||
-		    pc >= ((unsigned long) scheduling_functions_end_here)) {
+		if (pc < scheduling_functions_start_here ||
+		    pc >= scheduling_functions_end_here) {
 			ret = pc;
 			goto out;
 		}
arch/sparc64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sparc64/kernel/vmlinux.lds.S
@@ -15,6 +15,9 @@ SECTIONS
   .text 0x0000000000404000 :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.gnu.warning)
   } =0
   _etext = .;
arch/v850/kernel/process.c +5 -9
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/v850/kernel/process.c
@@ -203,11 +203,6 @@ int sys_execve (char *name, char **argv,
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here (void);
-extern void scheduling_functions_end_here (void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan (struct task_struct *p)
 {
 #if 0  /* Barf.  Figure out the stack-layout later.  XXX  */
@@ -221,15 +216,16 @@ unsigned long get_wchan (struct task_str
 
 	/* This quite disgusting function walks up the stack, following
 	   saved return address, until it something that's out of bounds
-	   (as defined by `first_sched' and `last_sched').  It then
-	   returns the last PC that was in-bounds.  */
+	   (as defined by `scheduling_functions_start_here' and
+	   `scheduling_functions_end_here').  It then returns the last
+	   PC that was in-bounds.  */
 	do {
 		if (fp < stack_page + sizeof (struct task_struct) ||
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/v850/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/v850/kernel/vmlinux.lds.S
@@ -64,6 +64,9 @@
 #define TEXT_CONTENTS							      \
 		__stext = . ;						      \
         	*(.text)						      \
+		__scheduling_functions_start_here = .;
+		*(.text.sched)
+		__scheduling_functions_end_here = .;
 			*(.exit.text)	/* 2.5 convention */		      \
 			*(.text.exit)	/* 2.4 convention */		      \
 			*(.text.lock)					      \
arch/x86_64/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/x86_64/kernel/process.c
@@ -528,11 +528,6 @@ asmlinkage long sys_vfork(struct pt_regs
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	u64 fp,rip;
@@ -547,14 +542,13 @@ unsigned long get_wchan(struct task_stru
 		if (fp < (unsigned long)p || fp > (unsigned long)p+THREAD_SIZE)
 			return 0; 
 		rip = *(u64 *)(fp+8); 
-		if (rip < first_sched || rip >= last_sched)
+		if (rip < scheduling_functions_start_here ||
+				rip >= scheduling_functions_end_here)
 			return rip; 
 		fp = *(u64 *)fp; 
 	} while (count++ < 16); 
 	return 0;
 }
-#undef last_sched
-#undef first_sched
 
 long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
 { 
arch/x86_64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/x86_64/kernel/vmlinux.lds.S
@@ -14,6 +14,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
include/linux/init.h +2 -0
diff -prauN linux-2.6.0-test9-bk22/include/linux/init.h wchan-2.6.0-test9-bk22-1/include/linux/init.h
@@ -45,6 +45,8 @@
 #define __exitdata	__attribute__ ((__section__(".exit.data")))
 #define __exit_call	__attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
 
+#define __sched		__attribute__((__section__(".text.sched")))
+
 #ifdef MODULE
 #define __exit		__attribute__ ((__section__(".exit.text")))
 #else
include/linux/sched.h +2 -0
diff -prauN linux-2.6.0-test9-bk22/include/linux/sched.h wchan-2.6.0-test9-bk22-1/include/linux/sched.h
@@ -169,6 +169,8 @@ extern void update_one_process(struct ta
 			       unsigned long system, int cpu);
 extern void scheduler_tick(int user_tick, int system);
 extern unsigned long cache_decay_ticks;
+extern const unsigned long scheduling_functions_start_here;
+extern const unsigned long scheduling_functions_end_here;
 
 
 #define	MAX_SCHEDULE_TIMEOUT	LONG_MAX
kernel/sched.c +26 -23

178 lines not on this page · raw message

kernel/timer.c +2 -2
diff -prauN linux-2.6.0-test9-bk22/kernel/timer.c wchan-2.6.0-test9-bk22-1/kernel/timer.c
@@ -1000,7 +1000,7 @@ static void process_timeout(unsigned lon
  *
  * In all cases the return value is guaranteed to be non-negative.
  */
-signed long schedule_timeout(signed long timeout)
+__sched signed long schedule_timeout(signed long timeout)
 {
 	struct timer_list timer;
 	unsigned long expire;
@@ -1060,7 +1060,7 @@ asmlinkage long sys_gettid(void)
 	return current->pid;
 }
 
-static long nanosleep_restart(struct restart_block *restart)
+static __sched long nanosleep_restart(struct restart_block *restart)
 {
 	unsigned long expire = restart->arg0, now = jiffies;
 	struct timespec *rmtp = (struct timespec *) restart->arg1;
#1 lore raw

A couple of comments on the patch:

arch/arm/boot/compressed/vmlinux.lds.in

Quoted 3 lines

diff -prauN linux-2.6.0-test9-bk22/arch/arm/boot/compressed/vmlinux.lds.in wchan-2.6.0-test9-bk22-1/arch/arm/boot/compressed/vmlinux.lds.in

arch/arm/boot/compressed/vmlinux.lds.in +0 -0

You don't need to add to this file - this linker script takes the binary kernel image and puts the necessary decompressor magic around it.

arch/arm26/boot/compressed/vmlinux.lds.in

Quoted 3 lines

diff -prauN linux-2.6.0-test9-bk22/arch/arm26/boot/compressed/vmlinux.lds.in wchan-2.6.0-test9-bk22-1/arch/arm26/boot/compressed/vmlinux.lds.in

arch/arm26/boot/compressed/vmlinux.lds.in +0 -0

Same again.

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
#2 lore raw
Quoted 3 lines
Quoted 3 lines

diff -prauN linux-2.6.0-test9-bk22/arch/arm/boot/compressed/vmlinux.lds.in wchan-2.6.0-test9-bk22-1/arch/arm/boot/compressed/vmlinux.lds.in

arch/arm/boot/compressed/vmlinux.lds.in +0 -0
Quoted 2 lines · Russell King

You don't need to add to this file - this linker script takes the binary kernel image and puts the necessary decompressor magic around it.

Aha, thanks. I'll follow up with an amended patch (for both instances).

-- wli

#3 lore raw
Quoted 2 lines · Russell King
Quoted 2 lines

You don't need to add to this file - this linker script takes the binary kernel image and puts the necessary decompressor magic around it.

Quoted 1 line · William Lee Irwin III

Aha, thanks. I'll follow up with an amended patch (for both instances).

And here it is. I also added a small tweak for the #if 0'd v850 code (which assumed a 2.4 stack layout; v850's using off-stack task_t's now).

-- wli

arch/alpha/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/alpha/kernel/process.c
@@ -513,11 +513,6 @@ thread_saved_pc(task_t *t)
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long
 get_wchan(struct task_struct *p)
 {
@@ -536,7 +531,8 @@ get_wchan(struct task_struct *p)
 	 */
 
 	pc = thread_saved_pc(p);
-	if (pc >= first_sched && pc < last_sched) {
+	if (pc >= scheduling_functions_start_here &&
+			pc < scheduling_functions_end_here) {
 		schedule_frame = ((unsigned long *)p->thread_info->pcb.ksp)[6];
 		return ((unsigned long *)schedule_frame)[12];
 	}
arch/alpha/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/alpha/kernel/vmlinux.lds.S
@@ -17,6 +17,9 @@ SECTIONS
   _text = .;					/* Text and read-only data */
   .text : { 
 	*(.text) 
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
   } :kernel
arch/arm/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/arm/kernel/process.c
@@ -415,11 +415,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, lr;
@@ -434,7 +429,8 @@ unsigned long get_wchan(struct task_stru
 		if (fp < stack_page || fp > 4092+stack_page)
 			return 0;
 		lr = pc_pointer (((unsigned long *)fp)[-1]);
-		if (lr < first_sched || lr > last_sched)
+		if (lr < scheduling_functions_start_here ||
+				lr > scheduling_functions_end_here)
 			return lr;
 		fp = *(unsigned long *) (fp - 12);
 	} while (count ++ < 16);
arch/arm/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/arm/kernel/vmlinux.lds.S
@@ -73,6 +73,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.text.sched)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/arm26/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/process.c
@@ -400,11 +400,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, lr;
@@ -419,7 +414,8 @@ unsigned long get_wchan(struct task_stru
 		if (fp < stack_page || fp > 4092+stack_page)
 			return 0;
 		lr = pc_pointer (((unsigned long *)fp)[-1]);
-		if (lr < first_sched || lr > last_sched)
+		if (lr < scheduling_functions_start_here ||
+				lr > scheduling_functions_end_here)
 			return lr;
 		fp = *(unsigned long *) (fp - 12);
 	} while (count ++ < 16);
arch/arm26/kernel/vmlinux-arm26-xip.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/vmlinux-arm26-xip.lds.in wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/vmlinux-arm26-xip.lds.in
@@ -66,6 +66,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.text.sched)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/arm26/kernel/vmlinux-arm26.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/vmlinux-arm26.lds.in wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/vmlinux-arm26.lds.in
@@ -67,6 +67,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.text.sched)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/cris/arch-v10/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/cris/arch-v10/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/cris/arch-v10/vmlinux.lds.S
@@ -25,6 +25,9 @@ SECTIONS
 	__stext = .;
 	.text : {
 		*(.text)
+		__scheduling_functions_start_here = .;
+		*(.text.sched)
+		__scheduling_functions_end_here = .;
 		*(.fixup)
 		*(.text.__*)
 	}
arch/h8300/kernel/process.c +2 -7
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/h8300/kernel/process.c
@@ -264,11 +264,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
 	return ((struct pt_regs *)tsk->thread.esp0)->pc;
@@ -289,8 +284,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/h8300/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/h8300/kernel/vmlinux.lds.S
@@ -82,6 +82,9 @@ SECTIONS
 #endif
 	__stext = . ;
         	*(.text)
+	__scheduling_functions_start_here = .;
+		*(.text.sched)
+	__scheduling_functions_end_here = .;
 	. = ALIGN(0x4) ;
 		*(.exit.text)
 		*(.text.*)
arch/i386/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/i386/kernel/process.c
@@ -631,11 +631,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ebp, esp, eip;
@@ -653,14 +648,13 @@ unsigned long get_wchan(struct task_stru
 		if (ebp < stack_page || ebp > 8184+stack_page)
 			return 0;
 		eip = *(unsigned long *) (ebp+4);
-		if (eip < first_sched || eip >= last_sched)
+		if (eip < scheduling_functions_start_here ||
+				eip >= scheduling_functions_end_here)
 			return eip;
 		ebp = *(unsigned long *) ebp;
 	} while (count++ < 16);
 	return 0;
 }
-#undef last_sched
-#undef first_sched
 
 /*
  * sys_alloc_thread_area: get a yet unused TLS descriptor index.
arch/i386/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/i386/kernel/vmlinux.lds.S
@@ -15,6 +15,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
arch/ia64/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ia64/kernel/process.c
@@ -638,11 +638,6 @@ get_wchan (struct task_struct *p)
 	/*
 	 * These bracket the sleeping functions..
 	 */
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
-#	define first_sched	((unsigned long) scheduling_functions_start_here)
-#	define last_sched	((unsigned long) scheduling_functions_end_here)
-
 	/*
 	 * Note: p may not be a blocked task (it could be current or
 	 * another process running on some other CPU.  Rather than
@@ -656,12 +651,11 @@ get_wchan (struct task_struct *p)
 		if (unw_unwind(&info) < 0)
 			return 0;
 		unw_get_ip(&info, &ip);
-		if (ip < first_sched || ip >= last_sched)
+		if (ip < scheduling_functions_start_here ||
+				ip >= scheduling_functions_end_here)
 			return ip;
 	} while (count++ < 16);
 	return 0;
-#	undef first_sched
-#	undef last_sched
 }
 
 void
arch/ia64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ia64/kernel/vmlinux.lds.S
@@ -35,6 +35,9 @@ SECTIONS
     {
 	*(.text.ivt)
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.gnu.linkonce.t*)
     }
   .text2 : AT(ADDR(.text2) - LOAD_OFFSET)
arch/m68k/kernel/process.c +4 -11
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/process.c
@@ -65,12 +65,10 @@ asmlinkage void ret_from_fork(void);
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
 	struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
 	/* Check whether the thread is blocked in resume() */
-	if (sw->retpc > (unsigned long)scheduling_functions_start_here &&
-	    sw->retpc < (unsigned long)scheduling_functions_end_here)
+	if (sw->retpc > scheduling_functions_start_here &&
+	    sw->retpc < scheduling_functions_end_here)
 		return ((unsigned long *)sw->a6)[1];
 	else
 		return sw->retpc;
@@ -387,11 +385,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, pc;
@@ -407,8 +400,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/m68k/kernel/vmlinux-std.lds +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/vmlinux-std.lds wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/vmlinux-std.lds
@@ -12,6 +12,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x4e75
arch/m68k/kernel/vmlinux-sun3.lds +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/vmlinux-sun3.lds wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/vmlinux-sun3.lds
@@ -13,6 +13,9 @@ SECTIONS
   .text : {
 	*(.head)
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x4e75
arch/m68knommu/kernel/process.c +4 -11
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/m68knommu/kernel/process.c
@@ -406,11 +406,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, pc;
@@ -426,8 +421,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
@@ -439,13 +434,11 @@ unsigned long get_wchan(struct task_stru
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
 	struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
 
 	/* Check whether the thread is blocked in resume() */
-	if (sw->retpc > (unsigned long)scheduling_functions_start_here &&
-	    sw->retpc < (unsigned long)scheduling_functions_end_here)
+	if (sw->retpc > scheduling_functions_start_here &&
+	    sw->retpc < scheduling_functions_end_here)
 		return ((unsigned long *)sw->a6)[1];
 	else
 		return sw->retpc;
arch/m68knommu/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/m68knommu/kernel/vmlinux.lds.S
@@ -191,6 +191,9 @@ SECTIONS {
 	.text : {
 		_stext = . ;
         	*(.text)
+		__scheduling_functions_start_here = .;
+		*(.text.sched)
+		__scheduling_functions_end_here = .;
         	*(.text.lock)
 
 		. = ALIGN(16);          /* Exception table              */
arch/mips/kernel/process.c +4 -7
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/mips/kernel/process.c
@@ -276,11 +276,6 @@ unsigned long thread_saved_pc(struct tas
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 /* get_wchan - a maintenance nightmare^W^Wpain in the ass ...  */
 unsigned long get_wchan(struct task_struct *p)
 {
@@ -292,7 +287,8 @@ unsigned long get_wchan(struct task_stru
 	if (!mips_frame_info_initialized)
 		return 0;
 	pc = thread_saved_pc(p);
-	if (pc < first_sched || pc >= last_sched)
+	if (pc < scheduling_functions_start_here ||
+			pc >= scheduling_functions_end_here)
 		goto out;
 
 	if (pc >= (unsigned long) sleep_on_timeout)
@@ -326,7 +322,8 @@ schedule_timeout_caller:
 	 */
 	pc    = ((unsigned long *)frame)[schedule_timeout_frame.pc_offset];
 
-	if (pc >= first_sched && pc < last_sched) {
+	if (pc >= scheduling_functions_start_here &&
+			pc < scheduling_functions_end_here) {
 		/* schedule_timeout called by [interruptible_]sleep_on_timeout */
 		frame = ((unsigned long *)frame)[schedule_timeout_frame.frame_offset];
 		pc    = ((unsigned long *)frame)[sleep_on_timeout_frame.pc_offset];
arch/mips/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/mips/kernel/vmlinux.lds.S
@@ -27,6 +27,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.gnu.warning)
   } =0
arch/parisc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/parisc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/parisc/kernel/vmlinux.lds.S
@@ -24,6 +24,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text BLOCK(16) : {
 	*(.text*)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here =.;
 	*(.PARISC.unwind)
 	*(.fixup)
 	*(.lock.text)		/* out-of-line lock text */
arch/ppc/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ppc/kernel/process.c
@@ -650,11 +650,6 @@ void __init ll_puts(const char *s)
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched    ((unsigned long) scheduling_functions_start_here)
-#define last_sched     ((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ip, sp;
@@ -669,7 +664,8 @@ unsigned long get_wchan(struct task_stru
 			return 0;
 		if (count > 0) {
 			ip = *(unsigned long *)(sp + 4);
-			if (ip < first_sched || ip >= last_sched)
+			if (ip < scheduling_functions_start_here ||
+					ip >= scheduling_functions_end_here)
 				return ip;
 		}
 	} while (count++ < 16);
arch/ppc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ppc/kernel/vmlinux.lds.S
@@ -31,6 +31,9 @@ SECTIONS
   .text      :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.got1)
     __got2_start = .;
arch/ppc64/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ppc64/kernel/process.c
@@ -369,11 +369,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched    (*(unsigned long *)scheduling_functions_start_here)
-#define last_sched     (*(unsigned long *)scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ip, sp;
@@ -393,7 +388,8 @@ unsigned long get_wchan(struct task_stru
 			 * XXX we mask the upper 32 bits until procps
 			 * gets fixed.
 			 */
-			if (ip < first_sched || ip >= last_sched)
+			if (ip < scheduling_functions_start_here ||
+					ip >= scheduling_functions_end_here)
 				return (ip & 0xFFFFFFFF);
 		}
 	} while (count++ < 16);
arch/ppc64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ppc64/kernel/vmlinux.lds.S
@@ -33,6 +33,9 @@ SECTIONS
   .text      :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.got1)
   }
arch/s390/kernel/process.c +2 -9
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/s390/kernel/process.c
@@ -371,11 +371,6 @@ void dump_thread(struct pt_regs * regs, 
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long r14, r15, bc;
@@ -398,12 +393,10 @@ unsigned long get_wchan(struct task_stru
 #else
 		r14 = *(unsigned long *) (bc+112);
 #endif
-		if (r14 < first_sched || r14 >= last_sched)
+		if (r14 < scheduling_functions_start_here ||
+				r14 >= scheduling_functions_end_here)
 			return r14;
 		bc = (*(unsigned long *) bc) & PSW_ADDR_INSN;
 	} while (count++ < 16);
 	return 0;
 }
-#undef last_sched
-#undef first_sched
-
arch/s390/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/s390/kernel/vmlinux.lds.S
@@ -23,6 +23,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x0700
arch/sh/kernel/process.c +0 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sh/kernel/process.c
@@ -375,11 +375,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long schedule_frame;
arch/sh/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sh/kernel/vmlinux.lds.S
@@ -22,6 +22,9 @@ SECTIONS
 	} = 0
   .text : {
 	*(.text)
+	__scheduling_functions_start_here =.;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x0009
arch/sparc/kernel/process.c +2 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sparc/kernel/process.c
@@ -692,9 +692,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 	return retval;
 }
 
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-
 unsigned long get_wchan(struct task_struct *task)
 {
 	unsigned long pc, fp, bias = 0;
@@ -715,8 +712,8 @@ unsigned long get_wchan(struct task_stru
 			break;
 		rw = (struct reg_window *) fp;
 		pc = rw->ins[7];
-		if (pc < ((unsigned long) scheduling_functions_start_here) ||
-                    pc >= ((unsigned long) scheduling_functions_end_here)) {
+		if (pc < scheduling_functions_start_here ||
+                    pc >= scheduling_functions_end_here) {
 			ret = pc;
 			goto out;
 		}
arch/sparc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sparc/kernel/vmlinux.lds.S
@@ -12,6 +12,9 @@ SECTIONS
   .text 0xf0004000 :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.gnu.warning)
   } =0
   _etext = .;
arch/sparc64/kernel/process.c +2 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sparc64/kernel/process.c
@@ -824,9 +824,6 @@ out:
 	return error;
 }
 
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-
 unsigned long get_wchan(struct task_struct *task)
 {
 	unsigned long pc, fp, bias = 0;
@@ -850,8 +847,8 @@ unsigned long get_wchan(struct task_stru
 			break;
 		rw = (struct reg_window *) fp;
 		pc = rw->ins[7];
-		if (pc < ((unsigned long) scheduling_functions_start_here) ||
-		    pc >= ((unsigned long) scheduling_functions_end_here)) {
+		if (pc < scheduling_functions_start_here ||
+		    pc >= scheduling_functions_end_here) {
 			ret = pc;
 			goto out;
 		}
arch/sparc64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sparc64/kernel/vmlinux.lds.S
@@ -15,6 +15,9 @@ SECTIONS
   .text 0x0000000000404000 :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.text.sched)
+    __scheduling_functions_end_here = .;
     *(.gnu.warning)
   } =0
   _etext = .;
arch/v850/kernel/process.c +7 -11
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/v850/kernel/process.c
@@ -203,11 +203,6 @@ int sys_execve (char *name, char **argv,
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here (void);
-extern void scheduling_functions_end_here (void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan (struct task_struct *p)
 {
 #if 0  /* Barf.  Figure out the stack-layout later.  XXX  */
@@ -221,15 +216,16 @@ unsigned long get_wchan (struct task_str
 
 	/* This quite disgusting function walks up the stack, following
 	   saved return address, until it something that's out of bounds
-	   (as defined by `first_sched' and `last_sched').  It then
-	   returns the last PC that was in-bounds.  */
+	   (as defined by `scheduling_functions_start_here' and
+	   `scheduling_functions_end_here').  It then returns the last
+	   PC that was in-bounds.  */
 	do {
-		if (fp < stack_page + sizeof (struct task_struct) ||
-		    fp >= 8184+stack_page)
+		if (fp < stack_page + sizeof(struct thread_info) ||
+		    fp >= THREAD_SIZE + stack_page - 8)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/v850/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/v850/kernel/vmlinux.lds.S
@@ -64,6 +64,9 @@
 #define TEXT_CONTENTS							      \
 		__stext = . ;						      \
         	*(.text)						      \
+		__scheduling_functions_start_here = .;
+		*(.text.sched)
+		__scheduling_functions_end_here = .;
 			*(.exit.text)	/* 2.5 convention */		      \
 			*(.text.exit)	/* 2.4 convention */		      \
 			*(.text.lock)					      \
arch/x86_64/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/x86_64/kernel/process.c
@@ -528,11 +528,6 @@ asmlinkage long sys_vfork(struct pt_regs
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	u64 fp,rip;
@@ -547,14 +542,13 @@ unsigned long get_wchan(struct task_stru
 		if (fp < (unsigned long)p || fp > (unsigned long)p+THREAD_SIZE)
 			return 0; 
 		rip = *(u64 *)(fp+8); 
-		if (rip < first_sched || rip >= last_sched)
+		if (rip < scheduling_functions_start_here ||
+				rip >= scheduling_functions_end_here)
 			return rip; 
 		fp = *(u64 *)fp; 
 	} while (count++ < 16); 
 	return 0;
 }
-#undef last_sched
-#undef first_sched
 
 long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
 { 
arch/x86_64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/x86_64/kernel/vmlinux.lds.S
@@ -14,6 +14,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.text.sched)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
include/linux/init.h +2 -0
diff -prauN linux-2.6.0-test9-bk22/include/linux/init.h wchan-2.6.0-test9-bk22-1/include/linux/init.h
@@ -45,6 +45,8 @@
 #define __exitdata	__attribute__ ((__section__(".exit.data")))
 #define __exit_call	__attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
 
+#define __sched		__attribute__((__section__(".text.sched")))
+
 #ifdef MODULE
 #define __exit		__attribute__ ((__section__(".exit.text")))
 #else
include/linux/sched.h +2 -0
diff -prauN linux-2.6.0-test9-bk22/include/linux/sched.h wchan-2.6.0-test9-bk22-1/include/linux/sched.h
@@ -169,6 +169,8 @@ extern void update_one_process(struct ta
 			       unsigned long system, int cpu);
 extern void scheduler_tick(int user_tick, int system);
 extern unsigned long cache_decay_ticks;
+extern const unsigned long scheduling_functions_start_here;
+extern const unsigned long scheduling_functions_end_here;
 
 
 #define	MAX_SCHEDULE_TIMEOUT	LONG_MAX
kernel/sched.c +26 -23

178 lines not on this page · raw message

kernel/timer.c +2 -2
diff -prauN linux-2.6.0-test9-bk22/kernel/timer.c wchan-2.6.0-test9-bk22-1/kernel/timer.c
@@ -1000,7 +1000,7 @@ static void process_timeout(unsigned lon
  *
  * In all cases the return value is guaranteed to be non-negative.
  */
-signed long schedule_timeout(signed long timeout)
+__sched signed long schedule_timeout(signed long timeout)
 {
 	struct timer_list timer;
 	unsigned long expire;
@@ -1060,7 +1060,7 @@ asmlinkage long sys_gettid(void)
 	return current->pid;
 }
 
-static long nanosleep_restart(struct restart_block *restart)
+static __sched long nanosleep_restart(struct restart_block *restart)
 {
 	unsigned long expire = restart->arg0, now = jiffies;
 	struct timespec *rmtp = (struct timespec *) restart->arg1;
#4 lore raw
Quoted 1 line · William Lee Irwin III
Quoted 1 line

Aha, thanks. I'll follow up with an amended patch (for both instances).

Quoted 2 lines · William Lee Irwin III

And here it is. I also added a small tweak for the #if 0'd v850 code (which assumed a 2.4 stack layout; v850's using off-stack task_t's now).

willy said I should use .sched.text instead of .text.sched; this fixes it up to do that.

-- wli

arch/alpha/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/alpha/kernel/process.c
@@ -513,11 +513,6 @@ thread_saved_pc(task_t *t)
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long
 get_wchan(struct task_struct *p)
 {
@@ -536,7 +531,8 @@ get_wchan(struct task_struct *p)
 	 */
 
 	pc = thread_saved_pc(p);
-	if (pc >= first_sched && pc < last_sched) {
+	if (pc >= scheduling_functions_start_here &&
+			pc < scheduling_functions_end_here) {
 		schedule_frame = ((unsigned long *)p->thread_info->pcb.ksp)[6];
 		return ((unsigned long *)schedule_frame)[12];
 	}
arch/alpha/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/alpha/kernel/vmlinux.lds.S
@@ -17,6 +17,9 @@ SECTIONS
   _text = .;					/* Text and read-only data */
   .text : { 
 	*(.text) 
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
   } :kernel
arch/arm/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/arm/kernel/process.c
@@ -415,11 +415,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, lr;
@@ -434,7 +429,8 @@ unsigned long get_wchan(struct task_stru
 		if (fp < stack_page || fp > 4092+stack_page)
 			return 0;
 		lr = pc_pointer (((unsigned long *)fp)[-1]);
-		if (lr < first_sched || lr > last_sched)
+		if (lr < scheduling_functions_start_here ||
+				lr > scheduling_functions_end_here)
 			return lr;
 		fp = *(unsigned long *) (fp - 12);
 	} while (count ++ < 16);
arch/arm/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/arm/kernel/vmlinux.lds.S
@@ -73,6 +73,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.sched.text)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/arm26/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/process.c
@@ -400,11 +400,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, lr;
@@ -419,7 +414,8 @@ unsigned long get_wchan(struct task_stru
 		if (fp < stack_page || fp > 4092+stack_page)
 			return 0;
 		lr = pc_pointer (((unsigned long *)fp)[-1]);
-		if (lr < first_sched || lr > last_sched)
+		if (lr < scheduling_functions_start_here ||
+				lr > scheduling_functions_end_here)
 			return lr;
 		fp = *(unsigned long *) (fp - 12);
 	} while (count ++ < 16);
arch/arm26/kernel/vmlinux-arm26-xip.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/vmlinux-arm26-xip.lds.in wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/vmlinux-arm26-xip.lds.in
@@ -66,6 +66,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.sched.text)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/arm26/kernel/vmlinux-arm26.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/vmlinux-arm26.lds.in wchan-2.6.0-test9-bk22-1/arch/arm26/kernel/vmlinux-arm26.lds.in
@@ -67,6 +67,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.sched.text)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/cris/arch-v10/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/cris/arch-v10/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/cris/arch-v10/vmlinux.lds.S
@@ -25,6 +25,9 @@ SECTIONS
 	__stext = .;
 	.text : {
 		*(.text)
+		__scheduling_functions_start_here = .;
+		*(.sched.text)
+		__scheduling_functions_end_here = .;
 		*(.fixup)
 		*(.text.__*)
 	}
arch/h8300/kernel/process.c +2 -7
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/h8300/kernel/process.c
@@ -264,11 +264,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
 	return ((struct pt_regs *)tsk->thread.esp0)->pc;
@@ -289,8 +284,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/h8300/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/h8300/kernel/vmlinux.lds.S
@@ -82,6 +82,9 @@ SECTIONS
 #endif
 	__stext = . ;
         	*(.text)
+	__scheduling_functions_start_here = .;
+		*(.sched.text)
+	__scheduling_functions_end_here = .;
 	. = ALIGN(0x4) ;
 		*(.exit.text)
 		*(.text.*)
arch/i386/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/i386/kernel/process.c
@@ -631,11 +631,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ebp, esp, eip;
@@ -653,14 +648,13 @@ unsigned long get_wchan(struct task_stru
 		if (ebp < stack_page || ebp > 8184+stack_page)
 			return 0;
 		eip = *(unsigned long *) (ebp+4);
-		if (eip < first_sched || eip >= last_sched)
+		if (eip < scheduling_functions_start_here ||
+				eip >= scheduling_functions_end_here)
 			return eip;
 		ebp = *(unsigned long *) ebp;
 	} while (count++ < 16);
 	return 0;
 }
-#undef last_sched
-#undef first_sched
 
 /*
  * sys_alloc_thread_area: get a yet unused TLS descriptor index.
arch/i386/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/i386/kernel/vmlinux.lds.S
@@ -15,6 +15,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
arch/ia64/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ia64/kernel/process.c
@@ -638,11 +638,6 @@ get_wchan (struct task_struct *p)
 	/*
 	 * These bracket the sleeping functions..
 	 */
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
-#	define first_sched	((unsigned long) scheduling_functions_start_here)
-#	define last_sched	((unsigned long) scheduling_functions_end_here)
-
 	/*
 	 * Note: p may not be a blocked task (it could be current or
 	 * another process running on some other CPU.  Rather than
@@ -656,12 +651,11 @@ get_wchan (struct task_struct *p)
 		if (unw_unwind(&info) < 0)
 			return 0;
 		unw_get_ip(&info, &ip);
-		if (ip < first_sched || ip >= last_sched)
+		if (ip < scheduling_functions_start_here ||
+				ip >= scheduling_functions_end_here)
 			return ip;
 	} while (count++ < 16);
 	return 0;
-#	undef first_sched
-#	undef last_sched
 }
 
 void
arch/ia64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ia64/kernel/vmlinux.lds.S
@@ -35,6 +35,9 @@ SECTIONS
     {
 	*(.text.ivt)
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.gnu.linkonce.t*)
     }
   .text2 : AT(ADDR(.text2) - LOAD_OFFSET)
arch/m68k/kernel/process.c +4 -11
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/process.c
@@ -65,12 +65,10 @@ asmlinkage void ret_from_fork(void);
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
 	struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
 	/* Check whether the thread is blocked in resume() */
-	if (sw->retpc > (unsigned long)scheduling_functions_start_here &&
-	    sw->retpc < (unsigned long)scheduling_functions_end_here)
+	if (sw->retpc > scheduling_functions_start_here &&
+	    sw->retpc < scheduling_functions_end_here)
 		return ((unsigned long *)sw->a6)[1];
 	else
 		return sw->retpc;
@@ -387,11 +385,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, pc;
@@ -407,8 +400,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/m68k/kernel/vmlinux-std.lds +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/vmlinux-std.lds wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/vmlinux-std.lds
@@ -12,6 +12,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x4e75
arch/m68k/kernel/vmlinux-sun3.lds +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/vmlinux-sun3.lds wchan-2.6.0-test9-bk22-1/arch/m68k/kernel/vmlinux-sun3.lds
@@ -13,6 +13,9 @@ SECTIONS
   .text : {
 	*(.head)
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x4e75
arch/m68knommu/kernel/process.c +4 -11
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/m68knommu/kernel/process.c
@@ -406,11 +406,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, pc;
@@ -426,8 +421,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
@@ -439,13 +434,11 @@ unsigned long get_wchan(struct task_stru
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
 	struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
 
 	/* Check whether the thread is blocked in resume() */
-	if (sw->retpc > (unsigned long)scheduling_functions_start_here &&
-	    sw->retpc < (unsigned long)scheduling_functions_end_here)
+	if (sw->retpc > scheduling_functions_start_here &&
+	    sw->retpc < scheduling_functions_end_here)
 		return ((unsigned long *)sw->a6)[1];
 	else
 		return sw->retpc;
arch/m68knommu/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/m68knommu/kernel/vmlinux.lds.S
@@ -191,6 +191,9 @@ SECTIONS {
 	.text : {
 		_stext = . ;
         	*(.text)
+		__scheduling_functions_start_here = .;
+		*(.sched.text)
+		__scheduling_functions_end_here = .;
         	*(.text.lock)
 
 		. = ALIGN(16);          /* Exception table              */
arch/mips/kernel/process.c +4 -7
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/mips/kernel/process.c
@@ -276,11 +276,6 @@ unsigned long thread_saved_pc(struct tas
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 /* get_wchan - a maintenance nightmare^W^Wpain in the ass ...  */
 unsigned long get_wchan(struct task_struct *p)
 {
@@ -292,7 +287,8 @@ unsigned long get_wchan(struct task_stru
 	if (!mips_frame_info_initialized)
 		return 0;
 	pc = thread_saved_pc(p);
-	if (pc < first_sched || pc >= last_sched)
+	if (pc < scheduling_functions_start_here ||
+			pc >= scheduling_functions_end_here)
 		goto out;
 
 	if (pc >= (unsigned long) sleep_on_timeout)
@@ -326,7 +322,8 @@ schedule_timeout_caller:
 	 */
 	pc    = ((unsigned long *)frame)[schedule_timeout_frame.pc_offset];
 
-	if (pc >= first_sched && pc < last_sched) {
+	if (pc >= scheduling_functions_start_here &&
+			pc < scheduling_functions_end_here) {
 		/* schedule_timeout called by [interruptible_]sleep_on_timeout */
 		frame = ((unsigned long *)frame)[schedule_timeout_frame.frame_offset];
 		pc    = ((unsigned long *)frame)[sleep_on_timeout_frame.pc_offset];
arch/mips/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/mips/kernel/vmlinux.lds.S
@@ -27,6 +27,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.gnu.warning)
   } =0
arch/parisc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/parisc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/parisc/kernel/vmlinux.lds.S
@@ -24,6 +24,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text BLOCK(16) : {
 	*(.text*)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here =.;
 	*(.PARISC.unwind)
 	*(.fixup)
 	*(.lock.text)		/* out-of-line lock text */
arch/ppc/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ppc/kernel/process.c
@@ -650,11 +650,6 @@ void __init ll_puts(const char *s)
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched    ((unsigned long) scheduling_functions_start_here)
-#define last_sched     ((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ip, sp;
@@ -669,7 +664,8 @@ unsigned long get_wchan(struct task_stru
 			return 0;
 		if (count > 0) {
 			ip = *(unsigned long *)(sp + 4);
-			if (ip < first_sched || ip >= last_sched)
+			if (ip < scheduling_functions_start_here ||
+					ip >= scheduling_functions_end_here)
 				return ip;
 		}
 	} while (count++ < 16);
arch/ppc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ppc/kernel/vmlinux.lds.S
@@ -31,6 +31,9 @@ SECTIONS
   .text      :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.got1)
     __got2_start = .;
arch/ppc64/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/ppc64/kernel/process.c
@@ -369,11 +369,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched    (*(unsigned long *)scheduling_functions_start_here)
-#define last_sched     (*(unsigned long *)scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ip, sp;
@@ -393,7 +388,8 @@ unsigned long get_wchan(struct task_stru
 			 * XXX we mask the upper 32 bits until procps
 			 * gets fixed.
 			 */
-			if (ip < first_sched || ip >= last_sched)
+			if (ip < scheduling_functions_start_here ||
+					ip >= scheduling_functions_end_here)
 				return (ip & 0xFFFFFFFF);
 		}
 	} while (count++ < 16);
arch/ppc64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/ppc64/kernel/vmlinux.lds.S
@@ -33,6 +33,9 @@ SECTIONS
   .text      :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.got1)
   }
arch/s390/kernel/process.c +2 -9
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/s390/kernel/process.c
@@ -371,11 +371,6 @@ void dump_thread(struct pt_regs * regs, 
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long r14, r15, bc;
@@ -398,12 +393,10 @@ unsigned long get_wchan(struct task_stru
 #else
 		r14 = *(unsigned long *) (bc+112);
 #endif
-		if (r14 < first_sched || r14 >= last_sched)
+		if (r14 < scheduling_functions_start_here ||
+				r14 >= scheduling_functions_end_here)
 			return r14;
 		bc = (*(unsigned long *) bc) & PSW_ADDR_INSN;
 	} while (count++ < 16);
 	return 0;
 }
-#undef last_sched
-#undef first_sched
-
arch/s390/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/s390/kernel/vmlinux.lds.S
@@ -23,6 +23,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x0700
arch/sh/kernel/process.c +0 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sh/kernel/process.c
@@ -375,11 +375,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long schedule_frame;
arch/sh/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sh/kernel/vmlinux.lds.S
@@ -22,6 +22,9 @@ SECTIONS
 	} = 0
   .text : {
 	*(.text)
+	__scheduling_functions_start_here =.;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x0009
arch/sparc/kernel/process.c +2 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sparc/kernel/process.c
@@ -692,9 +692,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 	return retval;
 }
 
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-
 unsigned long get_wchan(struct task_struct *task)
 {
 	unsigned long pc, fp, bias = 0;
@@ -715,8 +712,8 @@ unsigned long get_wchan(struct task_stru
 			break;
 		rw = (struct reg_window *) fp;
 		pc = rw->ins[7];
-		if (pc < ((unsigned long) scheduling_functions_start_here) ||
-                    pc >= ((unsigned long) scheduling_functions_end_here)) {
+		if (pc < scheduling_functions_start_here ||
+                    pc >= scheduling_functions_end_here) {
 			ret = pc;
 			goto out;
 		}
arch/sparc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sparc/kernel/vmlinux.lds.S
@@ -12,6 +12,9 @@ SECTIONS
   .text 0xf0004000 :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.gnu.warning)
   } =0
   _etext = .;
arch/sparc64/kernel/process.c +2 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/sparc64/kernel/process.c
@@ -824,9 +824,6 @@ out:
 	return error;
 }
 
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-
 unsigned long get_wchan(struct task_struct *task)
 {
 	unsigned long pc, fp, bias = 0;
@@ -850,8 +847,8 @@ unsigned long get_wchan(struct task_stru
 			break;
 		rw = (struct reg_window *) fp;
 		pc = rw->ins[7];
-		if (pc < ((unsigned long) scheduling_functions_start_here) ||
-		    pc >= ((unsigned long) scheduling_functions_end_here)) {
+		if (pc < scheduling_functions_start_here ||
+		    pc >= scheduling_functions_end_here) {
 			ret = pc;
 			goto out;
 		}
arch/sparc64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/sparc64/kernel/vmlinux.lds.S
@@ -15,6 +15,9 @@ SECTIONS
   .text 0x0000000000404000 :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.gnu.warning)
   } =0
   _etext = .;
arch/v850/kernel/process.c +7 -11
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/v850/kernel/process.c
@@ -203,11 +203,6 @@ int sys_execve (char *name, char **argv,
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here (void);
-extern void scheduling_functions_end_here (void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan (struct task_struct *p)
 {
 #if 0  /* Barf.  Figure out the stack-layout later.  XXX  */
@@ -221,15 +216,16 @@ unsigned long get_wchan (struct task_str
 
 	/* This quite disgusting function walks up the stack, following
 	   saved return address, until it something that's out of bounds
-	   (as defined by `first_sched' and `last_sched').  It then
-	   returns the last PC that was in-bounds.  */
+	   (as defined by `scheduling_functions_start_here' and
+	   `scheduling_functions_end_here').  It then returns the last
+	   PC that was in-bounds.  */
 	do {
-		if (fp < stack_page + sizeof (struct task_struct) ||
-		    fp >= 8184+stack_page)
+		if (fp < stack_page + sizeof(struct thread_info) ||
+		    fp >= THREAD_SIZE + stack_page - 8)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/v850/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/v850/kernel/vmlinux.lds.S
@@ -64,6 +64,9 @@
 #define TEXT_CONTENTS							      \
 		__stext = . ;						      \
         	*(.text)						      \
+		__scheduling_functions_start_here = .;
+		*(.sched.text)
+		__scheduling_functions_end_here = .;
 			*(.exit.text)	/* 2.5 convention */		      \
 			*(.text.exit)	/* 2.4 convention */		      \
 			*(.text.lock)					      \
arch/x86_64/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/process.c wchan-2.6.0-test9-bk22-1/arch/x86_64/kernel/process.c
@@ -528,11 +528,6 @@ asmlinkage long sys_vfork(struct pt_regs
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	u64 fp,rip;
@@ -547,14 +542,13 @@ unsigned long get_wchan(struct task_stru
 		if (fp < (unsigned long)p || fp > (unsigned long)p+THREAD_SIZE)
 			return 0; 
 		rip = *(u64 *)(fp+8); 
-		if (rip < first_sched || rip >= last_sched)
+		if (rip < scheduling_functions_start_here ||
+				rip >= scheduling_functions_end_here)
 			return rip; 
 		fp = *(u64 *)fp; 
 	} while (count++ < 16); 
 	return 0;
 }
-#undef last_sched
-#undef first_sched
 
 long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
 { 
arch/x86_64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-1/arch/x86_64/kernel/vmlinux.lds.S
@@ -14,6 +14,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
include/linux/init.h +2 -0
diff -prauN linux-2.6.0-test9-bk22/include/linux/init.h wchan-2.6.0-test9-bk22-1/include/linux/init.h
@@ -45,6 +45,8 @@
 #define __exitdata	__attribute__ ((__section__(".exit.data")))
 #define __exit_call	__attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
 
+#define __sched		__attribute__((__section__(".sched.text")))
+
 #ifdef MODULE
 #define __exit		__attribute__ ((__section__(".exit.text")))
 #else
include/linux/sched.h +2 -0
diff -prauN linux-2.6.0-test9-bk22/include/linux/sched.h wchan-2.6.0-test9-bk22-1/include/linux/sched.h
@@ -169,6 +169,8 @@ extern void update_one_process(struct ta
 			       unsigned long system, int cpu);
 extern void scheduler_tick(int user_tick, int system);
 extern unsigned long cache_decay_ticks;
+extern const unsigned long scheduling_functions_start_here;
+extern const unsigned long scheduling_functions_end_here;
 
 
 #define	MAX_SCHEDULE_TIMEOUT	LONG_MAX
kernel/sched.c +26 -23

178 lines not on this page · raw message

kernel/timer.c +2 -2
diff -prauN linux-2.6.0-test9-bk22/kernel/timer.c wchan-2.6.0-test9-bk22-1/kernel/timer.c
@@ -1000,7 +1000,7 @@ static void process_timeout(unsigned lon
  *
  * In all cases the return value is guaranteed to be non-negative.
  */
-signed long schedule_timeout(signed long timeout)
+__sched signed long schedule_timeout(signed long timeout)
 {
 	struct timer_list timer;
 	unsigned long expire;
@@ -1060,7 +1060,7 @@ asmlinkage long sys_gettid(void)
 	return current->pid;
 }
 
-static long nanosleep_restart(struct restart_block *restart)
+static __sched long nanosleep_restart(struct restart_block *restart)
 {
 	unsigned long expire = restart->arg0, now = jiffies;
 	struct timespec *rmtp = (struct timespec *) restart->arg1;
#5 lore raw
Quoted 2 lines · William Lee Irwin III

willy said I should use .sched.text instead of .text.sched; this fixes it up to do that.

Hi wli,
how about utilising asm-generic/vmlinux.h.S now that you are touching so many .lds files?
Something like the attached could be used?

That will simplify and consolidate the the .lds files, but full flexibility remains.

I noticed that there were small diferences between the individual architectures, but specifying only content of the section should allow it to be used all over.

Sam

===== include/asm-generic/vmlinux.lds.h 1.8 vs edited =====

include/asm-generic/vmlinux.lds.h +9 -0
@@ -45,6 +45,15 @@
 		*(__ksymtab_strings)					\
 	}
 
+#define TEXT_CONTENT							\
+		_stext = .;						\
+		*(.text)						\
+		__schduling_functions_start_here = .;			\
+		*(.sched.text)						\
+		__scheduling_functions_end_here = .;			\
+		*(.fixup)						\
+		*(.gnu.warning)						
+
 #define SECURITY_INIT							\
 	.security_initcall.init : {					\
 		__security_initcall_start = .;				\
#6 lore raw
Quoted 2 lines · William Lee Irwin III
Quoted 2 lines

willy said I should use .sched.text instead of .text.sched; this fixes it up to do that.

Quoted 9 lines · Sam Ravnborg

Hi wli,
how about utilising asm-generic/vmlinux.h.S now that you are touching so many .lds files?
Something like the attached could be used?
That will simplify and consolidate the the .lds files, but full flexibility remains.
I noticed that there were small diferences between the individual architectures, but specifying only content of the section should allow it to be used all over.

This doesn't quite cover all cases, though I agree in principle. It would probably be okay to rearrange the sections, but I'm vaguely queasy about it turning into a cleanup.

-- wli

#7 lore raw
In reply to William Lee Irwin III

Hi,

Quoted 5 lines

I noticed a bunch of "FIXME: this depends on the order of these functions" comments in/around wchan calculations.

So I decided I'd remove the dependency on the order of the functions by dumping them all into an ELF section with clear delimiters.

I like it. At the moment wchan is next to useless because everything ends up in down* or something similar.

Anton

#8 lore raw
Quoted 4 lines · At some point in the past, I wrote:
Quoted 4 lines

I noticed a bunch of "FIXME: this depends on the order of these functions" comments in/around wchan calculations.
So I decided I'd remove the dependency on the order of the functions by dumping them all into an ELF section with clear delimiters.

Quoted 2 lines · Anton Blanchard

I like it. At the moment wchan is next to useless because everything ends up in down* or something similar.

down_*() aren't covered by this yet; I'll do a sweep for that and repost.

-- wli

#9 lore raw
Quoted 4 lines · At some point in the past, I wrote:
Quoted 4 lines
Quoted 4 lines

I noticed a bunch of "FIXME: this depends on the order of these functions" comments in/around wchan calculations.
So I decided I'd remove the dependency on the order of the functions by dumping them all into an ELF section with clear delimiters.

Quoted 2 lines · Anton Blanchard
Quoted 2 lines

I like it. At the moment wchan is next to useless because everything ends up in down* or something similar.

Quoted 1 line · William Lee Irwin III

down_*() aren't covered by this yet; I'll do a sweep for that and repost.

Okay, here is the updated patch:

arch/alpha/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/alpha/kernel/process.c
@@ -513,11 +513,6 @@ thread_saved_pc(task_t *t)
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long
 get_wchan(struct task_struct *p)
 {
@@ -536,7 +531,8 @@ get_wchan(struct task_struct *p)
 	 */
 
 	pc = thread_saved_pc(p);
-	if (pc >= first_sched && pc < last_sched) {
+	if (pc >= scheduling_functions_start_here &&
+			pc < scheduling_functions_end_here) {
 		schedule_frame = ((unsigned long *)p->thread_info->pcb.ksp)[6];
 		return ((unsigned long *)schedule_frame)[12];
 	}
arch/alpha/kernel/semaphore.c +5 -4
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/alpha/kernel/semaphore.c
@@ -7,6 +7,7 @@
 
 #include <linux/errno.h>
 #include <linux/sched.h>
+#include <linux/init.h>
 
 /*
  * Semaphores are implemented using a two-way counter:
@@ -52,7 +53,7 @@
  * Either form may be used in conjunction with "up()".
  */
 
-void
+__sched void
 __down_failed(struct semaphore *sem)
 {
 	DECLARE_WAITQUEUE(wait, current);
@@ -103,7 +104,7 @@ __down_failed(struct semaphore *sem)
 #endif
 }
 
-int
+__sched int
 __down_failed_interruptible(struct semaphore *sem)
 {
 	DECLARE_WAITQUEUE(wait, current);
@@ -201,7 +202,7 @@ __up_wakeup(struct semaphore *sem)
 	wake_up(&sem->wait);
 }
 
-void
+__sched void
 down(struct semaphore *sem)
 {
 #if WAITQUEUE_DEBUG
@@ -215,7 +216,7 @@ down(struct semaphore *sem)
 	__down(sem);
 }
 
-int
+__sched int
 down_interruptible(struct semaphore *sem)
 {
 #if WAITQUEUE_DEBUG
arch/alpha/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/alpha/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/alpha/kernel/vmlinux.lds.S
@@ -17,6 +17,9 @@ SECTIONS
   _text = .;					/* Text and read-only data */
   .text : { 
 	*(.text) 
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
   } :kernel
arch/arm/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/arm/kernel/process.c
@@ -415,11 +415,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, lr;
@@ -434,7 +429,8 @@ unsigned long get_wchan(struct task_stru
 		if (fp < stack_page || fp > 4092+stack_page)
 			return 0;
 		lr = pc_pointer (((unsigned long *)fp)[-1]);
-		if (lr < first_sched || lr > last_sched)
+		if (lr < scheduling_functions_start_here ||
+				lr > scheduling_functions_end_here)
 			return lr;
 		fp = *(unsigned long *) (fp - 12);
 	} while (count ++ < 16);
arch/arm/kernel/semaphore.c +5 -3
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/arm/kernel/semaphore.c
@@ -13,6 +13,7 @@
  */
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <linux/init.h>
 
 #include <asm/semaphore.h>
 
@@ -54,7 +55,7 @@ void __up(struct semaphore *sem)
 
 static spinlock_t semaphore_lock = SPIN_LOCK_UNLOCKED;
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -87,7 +88,7 @@ void __down(struct semaphore * sem)
 	wake_up(&sem->wait);
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
@@ -176,7 +177,8 @@ int __down_trylock(struct semaphore * se
  * registers (r0 to r3 and lr), but not ip, as we use it as a return
  * value in some cases..
  */
-asm("	.align	5				\n\
+asm("	.section .sched.text			\n\
+	.align	5				\n\
 	.globl	__down_failed			\n\
 __down_failed:					\n\
 	stmfd	sp!, {r0 - r3, lr}		\n\
arch/arm/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/arm/kernel/vmlinux.lds.S
@@ -73,6 +73,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.sched.text)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/arm26/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/arm26/kernel/process.c
@@ -400,11 +400,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, lr;
@@ -419,7 +414,8 @@ unsigned long get_wchan(struct task_stru
 		if (fp < stack_page || fp > 4092+stack_page)
 			return 0;
 		lr = pc_pointer (((unsigned long *)fp)[-1]);
-		if (lr < first_sched || lr > last_sched)
+		if (lr < scheduling_functions_start_here ||
+				lr > scheduling_functions_end_here)
 			return lr;
 		fp = *(unsigned long *) (fp - 12);
 	} while (count ++ < 16);
arch/arm26/kernel/semaphore.c +5 -3
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/arm26/kernel/semaphore.c
@@ -15,6 +15,7 @@
 #include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <linux/init.h>
 
 #include <asm/semaphore.h>
 
@@ -56,7 +57,7 @@ void __up(struct semaphore *sem)
 
 static spinlock_t semaphore_lock = SPIN_LOCK_UNLOCKED;
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -89,7 +90,7 @@ void __down(struct semaphore * sem)
 	wake_up(&sem->wait);
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
@@ -178,7 +179,8 @@ int __down_trylock(struct semaphore * se
  * registers (r0 to r3 and lr), but not ip, as we use it as a return
  * value in some cases..
  */
-asm("	.align	5				\n\
+asm("	.section .sched.text			\n\
+	.align	5				\n\
 	.globl	__down_failed			\n\
 __down_failed:					\n\
 	stmfd	sp!, {r0 - r3, lr}		\n\
arch/arm26/kernel/vmlinux-arm26-xip.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/vmlinux-arm26-xip.lds.in wchan-2.6.0-test9-bk22-2/arch/arm26/kernel/vmlinux-arm26-xip.lds.in
@@ -66,6 +66,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.sched.text)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/arm26/kernel/vmlinux-arm26.lds.in +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/arm26/kernel/vmlinux-arm26.lds.in wchan-2.6.0-test9-bk22-2/arch/arm26/kernel/vmlinux-arm26.lds.in
@@ -67,6 +67,9 @@ SECTIONS
 	.text : {			/* Real text segment		*/
 		_text = .;		/* Text and read-only data	*/
 			*(.text)
+			__scheduling_functions_start_here = .;
+			*(.sched.text)
+			__scheduling_functions_end_here = .;
 			*(.fixup)
 			*(.gnu.warning)
 			*(.rodata)
arch/cris/arch-v10/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/cris/arch-v10/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/cris/arch-v10/vmlinux.lds.S
@@ -25,6 +25,9 @@ SECTIONS
 	__stext = .;
 	.text : {
 		*(.text)
+		__scheduling_functions_start_here = .;
+		*(.sched.text)
+		__scheduling_functions_end_here = .;
 		*(.fixup)
 		*(.text.__*)
 	}
arch/cris/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/cris/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/cris/kernel/semaphore.c
@@ -4,6 +4,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/init.h>
 #include <asm/semaphore-helper.h>
 
 /*
@@ -94,7 +95,7 @@ void __up(struct semaphore *sem)
 	tsk->state = TASK_RUNNING;		\
 	remove_wait_queue(&sem->wait, &wait);
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	DOWN_VAR
 	DOWN_HEAD(TASK_UNINTERRUPTIBLE)
@@ -104,7 +105,7 @@ void __down(struct semaphore * sem)
 	DOWN_TAIL(TASK_UNINTERRUPTIBLE)
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int ret = 0;
 	DOWN_VAR
arch/h8300/kernel/process.c +2 -7
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/h8300/kernel/process.c
@@ -264,11 +264,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
 	return ((struct pt_regs *)tsk->thread.esp0)->pc;
@@ -289,8 +284,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/h8300/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/h8300/kernel/semaphore.c
@@ -5,6 +5,7 @@
 
 #include <linux/config.h>
 #include <linux/sched.h>
+#include <linux/init.h>
 #include <asm/semaphore-helper.h>
 
 #ifndef CONFIG_RMW_INSNS
@@ -95,7 +96,7 @@ void __up(struct semaphore *sem)
 	current->state = TASK_RUNNING;		\
 	remove_wait_queue(&sem->wait, &wait);
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	DECLARE_WAITQUEUE(wait, current);
 
@@ -106,7 +107,7 @@ void __down(struct semaphore * sem)
 	DOWN_TAIL(TASK_UNINTERRUPTIBLE)
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	DECLARE_WAITQUEUE(wait, current);
 	int ret = 0;
arch/h8300/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/h8300/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/h8300/kernel/vmlinux.lds.S
@@ -82,6 +82,9 @@ SECTIONS
 #endif
 	__stext = . ;
         	*(.text)
+	__scheduling_functions_start_here = .;
+		*(.sched.text)
+	__scheduling_functions_end_here = .;
 	. = ALIGN(0x4) ;
 		*(.exit.text)
 		*(.text.*)
arch/i386/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/i386/kernel/process.c
@@ -631,11 +631,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ebp, esp, eip;
@@ -653,14 +648,13 @@ unsigned long get_wchan(struct task_stru
 		if (ebp < stack_page || ebp > 8184+stack_page)
 			return 0;
 		eip = *(unsigned long *) (ebp+4);
-		if (eip < first_sched || eip >= last_sched)
+		if (eip < scheduling_functions_start_here ||
+				eip >= scheduling_functions_end_here)
 			return eip;
 		ebp = *(unsigned long *) ebp;
 	} while (count++ < 16);
 	return 0;
 }
-#undef last_sched
-#undef first_sched
 
 /*
  * sys_alloc_thread_area: get a yet unused TLS descriptor index.
arch/i386/kernel/semaphore.c +9 -8
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/i386/kernel/semaphore.c
@@ -15,6 +15,7 @@
 #include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/err.h>
+#include <linux/init.h>
 #include <asm/semaphore.h>
 
 /*
@@ -53,7 +54,7 @@ void __up(struct semaphore *sem)
 	wake_up(&sem->wait);
 }
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -90,7 +91,7 @@ void __down(struct semaphore * sem)
 	tsk->state = TASK_RUNNING;
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
@@ -187,7 +188,7 @@ int __down_trylock(struct semaphore * se
  * value..
  */
 asm(
-".text\n"
+".section .sched.text\n"
 ".align 4\n"
 ".globl __down_failed\n"
 "__down_failed:\n\t"
@@ -210,7 +211,7 @@ asm(
 );
 
 asm(
-".text\n"
+".section .sched.text\n"
 ".align 4\n"
 ".globl __down_failed_interruptible\n"
 "__down_failed_interruptible:\n\t"
@@ -231,7 +232,7 @@ asm(
 );
 
 asm(
-".text\n"
+".section .sched.text\n"
 ".align 4\n"
 ".globl __down_failed_trylock\n"
 "__down_failed_trylock:\n\t"
@@ -252,7 +253,7 @@ asm(
 );
 
 asm(
-".text\n"
+".section .sched.text\n"
 ".align 4\n"
 ".globl __up_wakeup\n"
 "__up_wakeup:\n\t"
@@ -271,7 +272,7 @@ asm(
  */
 #if defined(CONFIG_SMP)
 asm(
-".text\n"
+".section .sched.text\n"
 ".align	4\n"
 ".globl	__write_lock_failed\n"
 "__write_lock_failed:\n\t"
@@ -285,7 +286,7 @@ asm(
 );
 
 asm(
-".text\n"
+".section .sched.text\n"
 ".align	4\n"
 ".globl	__read_lock_failed\n"
 "__read_lock_failed:\n\t"
arch/i386/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/i386/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/i386/kernel/vmlinux.lds.S
@@ -15,6 +15,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
arch/ia64/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/ia64/kernel/process.c
@@ -638,11 +638,6 @@ get_wchan (struct task_struct *p)
 	/*
 	 * These bracket the sleeping functions..
 	 */
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
-#	define first_sched	((unsigned long) scheduling_functions_start_here)
-#	define last_sched	((unsigned long) scheduling_functions_end_here)
-
 	/*
 	 * Note: p may not be a blocked task (it could be current or
 	 * another process running on some other CPU.  Rather than
@@ -656,12 +651,11 @@ get_wchan (struct task_struct *p)
 		if (unw_unwind(&info) < 0)
 			return 0;
 		unw_get_ip(&info, &ip);
-		if (ip < first_sched || ip >= last_sched)
+		if (ip < scheduling_functions_start_here ||
+				ip >= scheduling_functions_end_here)
 			return ip;
 	} while (count++ < 16);
 	return 0;
-#	undef first_sched
-#	undef last_sched
 }
 
 void
arch/ia64/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/ia64/kernel/semaphore.c
@@ -24,6 +24,7 @@
  * <asm/semaphore.h> where we want to avoid any extra jumps and calls.
  */
 #include <linux/sched.h>
+#include <linux/init.h>
 
 #include <asm/errno.h>
 #include <asm/semaphore.h>
@@ -44,7 +45,7 @@ __up (struct semaphore *sem)
 	wake_up(&sem->wait);
 }
 
-void
+__sched void
 __down (struct semaphore *sem)
 {
 	struct task_struct *tsk = current;
@@ -82,7 +83,7 @@ __down (struct semaphore *sem)
 	tsk->state = TASK_RUNNING;
 }
 
-int
+__sched int
 __down_interruptible (struct semaphore * sem)
 {
 	int retval = 0;
arch/ia64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ia64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/ia64/kernel/vmlinux.lds.S
@@ -35,6 +35,9 @@ SECTIONS
     {
 	*(.text.ivt)
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.gnu.linkonce.t*)
     }
   .text2 : AT(ADDR(.text2) - LOAD_OFFSET)
arch/m68k/kernel/process.c +4 -11
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/m68k/kernel/process.c
@@ -65,12 +65,10 @@ asmlinkage void ret_from_fork(void);
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
 	struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
 	/* Check whether the thread is blocked in resume() */
-	if (sw->retpc > (unsigned long)scheduling_functions_start_here &&
-	    sw->retpc < (unsigned long)scheduling_functions_end_here)
+	if (sw->retpc > scheduling_functions_start_here &&
+	    sw->retpc < scheduling_functions_end_here)
 		return ((unsigned long *)sw->a6)[1];
 	else
 		return sw->retpc;
@@ -387,11 +385,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, pc;
@@ -407,8 +400,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/m68k/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/m68k/kernel/semaphore.c
@@ -5,6 +5,7 @@
 
 #include <linux/config.h>
 #include <linux/sched.h>
+#include <linux/init.h>
 #include <asm/semaphore-helper.h>
 
 #ifndef CONFIG_RMW_INSNS
@@ -95,7 +96,7 @@ void __up(struct semaphore *sem)
 	current->state = TASK_RUNNING;		\
 	remove_wait_queue(&sem->wait, &wait);
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	DECLARE_WAITQUEUE(wait, current);
 
@@ -106,7 +107,7 @@ void __down(struct semaphore * sem)
 	DOWN_TAIL(TASK_UNINTERRUPTIBLE)
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	DECLARE_WAITQUEUE(wait, current);
 	int ret = 0;
arch/m68k/kernel/vmlinux-std.lds +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/vmlinux-std.lds wchan-2.6.0-test9-bk22-2/arch/m68k/kernel/vmlinux-std.lds
@@ -12,6 +12,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x4e75
arch/m68k/kernel/vmlinux-sun3.lds +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68k/kernel/vmlinux-sun3.lds wchan-2.6.0-test9-bk22-2/arch/m68k/kernel/vmlinux-sun3.lds
@@ -13,6 +13,9 @@ SECTIONS
   .text : {
 	*(.head)
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x4e75
arch/m68knommu/kernel/process.c +4 -11
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/m68knommu/kernel/process.c
@@ -406,11 +406,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long fp, pc;
@@ -426,8 +421,8 @@ unsigned long get_wchan(struct task_stru
 		    fp >= 8184+stack_page)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
@@ -439,13 +434,11 @@ unsigned long get_wchan(struct task_stru
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-	extern void scheduling_functions_start_here(void);
-	extern void scheduling_functions_end_here(void);
 	struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
 
 	/* Check whether the thread is blocked in resume() */
-	if (sw->retpc > (unsigned long)scheduling_functions_start_here &&
-	    sw->retpc < (unsigned long)scheduling_functions_end_here)
+	if (sw->retpc > scheduling_functions_start_here &&
+	    sw->retpc < scheduling_functions_end_here)
 		return ((unsigned long *)sw->a6)[1];
 	else
 		return sw->retpc;
arch/m68knommu/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/m68knommu/kernel/semaphore.c
@@ -6,6 +6,7 @@
 #include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/err.h>
+#include <linux/init.h>
 #include <asm/semaphore-helper.h>
 
 #ifndef CONFIG_RMW_INSNS
@@ -96,7 +97,7 @@ void __up(struct semaphore *sem)
 	current->state = TASK_RUNNING;		\
 	remove_wait_queue(&sem->wait, &wait);
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	DECLARE_WAITQUEUE(wait, current);
 
@@ -107,7 +108,7 @@ void __down(struct semaphore * sem)
 	DOWN_TAIL(TASK_UNINTERRUPTIBLE)
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	DECLARE_WAITQUEUE(wait, current);
 	int ret = 0;
arch/m68knommu/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/m68knommu/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/m68knommu/kernel/vmlinux.lds.S
@@ -191,6 +191,9 @@ SECTIONS {
 	.text : {
 		_stext = . ;
         	*(.text)
+		__scheduling_functions_start_here = .;
+		*(.sched.text)
+		__scheduling_functions_end_here = .;
         	*(.text.lock)
 
 		. = ALIGN(16);          /* Exception table              */
arch/mips/kernel/process.c +4 -7
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/mips/kernel/process.c
@@ -276,11 +276,6 @@ unsigned long thread_saved_pc(struct tas
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 /* get_wchan - a maintenance nightmare^W^Wpain in the ass ...  */
 unsigned long get_wchan(struct task_struct *p)
 {
@@ -292,7 +287,8 @@ unsigned long get_wchan(struct task_stru
 	if (!mips_frame_info_initialized)
 		return 0;
 	pc = thread_saved_pc(p);
-	if (pc < first_sched || pc >= last_sched)
+	if (pc < scheduling_functions_start_here ||
+			pc >= scheduling_functions_end_here)
 		goto out;
 
 	if (pc >= (unsigned long) sleep_on_timeout)
@@ -326,7 +322,8 @@ schedule_timeout_caller:
 	 */
 	pc    = ((unsigned long *)frame)[schedule_timeout_frame.pc_offset];
 
-	if (pc >= first_sched && pc < last_sched) {
+	if (pc >= scheduling_functions_start_here &&
+			pc < scheduling_functions_end_here) {
 		/* schedule_timeout called by [interruptible_]sleep_on_timeout */
 		frame = ((unsigned long *)frame)[schedule_timeout_frame.frame_offset];
 		pc    = ((unsigned long *)frame)[sleep_on_timeout_frame.pc_offset];
arch/mips/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/mips/kernel/semaphore.c
@@ -4,6 +4,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/init.h>
 #include <asm/semaphore-helper.h>
 
 /*
@@ -94,7 +95,7 @@ void __up(struct semaphore *sem)
 	tsk->state = TASK_RUNNING;		\
 	remove_wait_queue(&sem->wait, &wait);
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	DOWN_VAR
 	DOWN_HEAD(TASK_UNINTERRUPTIBLE)
@@ -104,7 +105,7 @@ void __down(struct semaphore * sem)
 	DOWN_TAIL(TASK_UNINTERRUPTIBLE)
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int ret = 0;
 	DOWN_VAR
arch/mips/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/mips/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/mips/kernel/vmlinux.lds.S
@@ -27,6 +27,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.gnu.warning)
   } =0
arch/parisc/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/parisc/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/parisc/kernel/semaphore.c
@@ -5,6 +5,7 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/errno.h>
+#include <linux/init.h>
 
 /*
  * Semaphores are complex as we wish to avoid using two variables.
@@ -58,7 +59,7 @@ void __up(struct semaphore *sem)
 	sem->count += (sem->count < 0) ? 1 : - 1;
 	
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	DOWN_HEAD
 
@@ -74,7 +75,7 @@ void __down(struct semaphore * sem)
 	UPDATE_COUNT
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	DOWN_HEAD
 
arch/parisc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/parisc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/parisc/kernel/vmlinux.lds.S
@@ -24,6 +24,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text BLOCK(16) : {
 	*(.text*)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here =.;
 	*(.PARISC.unwind)
 	*(.fixup)
 	*(.lock.text)		/* out-of-line lock text */
arch/ppc/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/ppc/kernel/process.c
@@ -650,11 +650,6 @@ void __init ll_puts(const char *s)
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched    ((unsigned long) scheduling_functions_start_here)
-#define last_sched     ((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ip, sp;
@@ -669,7 +664,8 @@ unsigned long get_wchan(struct task_stru
 			return 0;
 		if (count > 0) {
 			ip = *(unsigned long *)(sp + 4);
-			if (ip < first_sched || ip >= last_sched)
+			if (ip < scheduling_functions_start_here ||
+					ip >= scheduling_functions_end_here)
 				return ip;
 		}
 	} while (count++ < 16);
arch/ppc/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/ppc/kernel/semaphore.c
@@ -15,6 +15,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/init.h>
 #include <asm/atomic.h>
 #include <asm/semaphore.h>
 #include <asm/errno.h>
@@ -69,7 +70,7 @@ void __up(struct semaphore *sem)
  * Thus it is only when we decrement count from some value > 0
  * that we have actually got the semaphore.
  */
-void __down(struct semaphore *sem)
+__sched void __down(struct semaphore *sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -99,7 +100,7 @@ void __down(struct semaphore *sem)
 	wake_up(&sem->wait);
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
arch/ppc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ppc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/ppc/kernel/vmlinux.lds.S
@@ -31,6 +31,9 @@ SECTIONS
   .text      :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.got1)
     __got2_start = .;
arch/ppc64/kernel/process.c +2 -6
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/ppc64/kernel/process.c
@@ -369,11 +369,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched    (*(unsigned long *)scheduling_functions_start_here)
-#define last_sched     (*(unsigned long *)scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long ip, sp;
@@ -393,7 +388,8 @@ unsigned long get_wchan(struct task_stru
 			 * XXX we mask the upper 32 bits until procps
 			 * gets fixed.
 			 */
-			if (ip < first_sched || ip >= last_sched)
+			if (ip < scheduling_functions_start_here ||
+					ip >= scheduling_functions_end_here)
 				return (ip & 0xFFFFFFFF);
 		}
 	} while (count++ < 16);
arch/ppc64/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/ppc64/kernel/semaphore.c
@@ -17,6 +17,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/init.h>
 #include <asm/atomic.h>
 #include <asm/semaphore.h>
 #include <asm/errno.h>
@@ -70,7 +71,7 @@ void __up(struct semaphore *sem)
  * Thus it is only when we decrement count from some value > 0
  * that we have actually got the semaphore.
  */
-void __down(struct semaphore *sem)
+__sched void __down(struct semaphore *sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -99,7 +100,7 @@ void __down(struct semaphore *sem)
 	wake_up(&sem->wait);
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
arch/ppc64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/ppc64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/ppc64/kernel/vmlinux.lds.S
@@ -33,6 +33,9 @@ SECTIONS
   .text      :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.fixup)
     *(.got1)
   }
arch/s390/kernel/process.c +2 -9
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/s390/kernel/process.c
@@ -371,11 +371,6 @@ void dump_thread(struct pt_regs * regs, 
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long r14, r15, bc;
@@ -398,12 +393,10 @@ unsigned long get_wchan(struct task_stru
 #else
 		r14 = *(unsigned long *) (bc+112);
 #endif
-		if (r14 < first_sched || r14 >= last_sched)
+		if (r14 < scheduling_functions_start_here ||
+				r14 >= scheduling_functions_end_here)
 			return r14;
 		bc = (*(unsigned long *) bc) & PSW_ADDR_INSN;
 	} while (count++ < 16);
 	return 0;
 }
-#undef last_sched
-#undef first_sched
-
arch/s390/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/s390/kernel/semaphore.c
@@ -11,6 +11,7 @@
  */
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <linux/init.h>
 
 #include <asm/semaphore.h>
 
@@ -59,7 +60,7 @@ void __up(struct semaphore *sem)
  *   count > 0: decrement count, wake up queue and exit.
  *   count <= 0: set count to -1, go to sleep.
  */
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -81,7 +82,7 @@ void __down(struct semaphore * sem)
  *   count > 0: wake up queue and exit.
  *   count <= 0: set count to 0, wake up queue and exit.
  */
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
arch/s390/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/s390/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/s390/kernel/vmlinux.lds.S
@@ -23,6 +23,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x0700
arch/sh/kernel/process.c +0 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/sh/kernel/process.c
@@ -375,11 +375,6 @@ out:
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	unsigned long schedule_frame;
arch/sh/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/sh/kernel/semaphore.c
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
+#include <linux/init.h>
 #include <asm/semaphore.h>
 #include <asm/semaphore-helper.h>
 
@@ -103,7 +104,7 @@ void __up(struct semaphore *sem)
 	tsk->state = TASK_RUNNING;		\
 	remove_wait_queue(&sem->wait, &wait);
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	DOWN_VAR
 	DOWN_HEAD(TASK_UNINTERRUPTIBLE)
@@ -113,7 +114,7 @@ void __down(struct semaphore * sem)
 	DOWN_TAIL(TASK_UNINTERRUPTIBLE)
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int ret = 0;
 	DOWN_VAR
arch/sh/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sh/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/sh/kernel/vmlinux.lds.S
@@ -22,6 +22,9 @@ SECTIONS
 	} = 0
   .text : {
 	*(.text)
+	__scheduling_functions_start_here =.;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x0009
arch/sparc/kernel/process.c +2 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/sparc/kernel/process.c
@@ -692,9 +692,6 @@ pid_t kernel_thread(int (*fn)(void *), v
 	return retval;
 }
 
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-
 unsigned long get_wchan(struct task_struct *task)
 {
 	unsigned long pc, fp, bias = 0;
@@ -715,8 +712,8 @@ unsigned long get_wchan(struct task_stru
 			break;
 		rw = (struct reg_window *) fp;
 		pc = rw->ins[7];
-		if (pc < ((unsigned long) scheduling_functions_start_here) ||
-                    pc >= ((unsigned long) scheduling_functions_end_here)) {
+		if (pc < scheduling_functions_start_here ||
+                    pc >= scheduling_functions_end_here) {
 			ret = pc;
 			goto out;
 		}
arch/sparc/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/sparc/kernel/semaphore.c
@@ -4,6 +4,7 @@
 
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <linux/init.h>
 
 #include <asm/semaphore.h>
 
@@ -45,7 +46,7 @@ void __up(struct semaphore *sem)
 
 static spinlock_t semaphore_lock = SPIN_LOCK_UNLOCKED;
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -78,7 +79,7 @@ void __down(struct semaphore * sem)
 	wake_up(&sem->wait);
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
arch/sparc/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/sparc/kernel/vmlinux.lds.S
@@ -12,6 +12,9 @@ SECTIONS
   .text 0xf0004000 :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.gnu.warning)
   } =0
   _etext = .;
arch/sparc/lib/rwsem.S +2 -1
diff -prauN linux-2.6.0-test9-bk22/arch/sparc/lib/rwsem.S wchan-2.6.0-test9-bk22-2/arch/sparc/lib/rwsem.S
@@ -8,7 +8,7 @@
 #include <asm/ptrace.h>
 #include <asm/psr.h>
 
-	.text
+	.section .sched.text
 	.align	4
 
 	.globl		___down_read
@@ -113,6 +113,7 @@ ___down_write:
 	ba		2b
 	 restore	%l5, %g0, %g5
 
+	.text
 	.globl		___up_read
 ___up_read:
 	rd		%psr, %g3
arch/sparc64/kernel/process.c +2 -5
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/sparc64/kernel/process.c
@@ -824,9 +824,6 @@ out:
 	return error;
 }
 
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-
 unsigned long get_wchan(struct task_struct *task)
 {
 	unsigned long pc, fp, bias = 0;
@@ -850,8 +847,8 @@ unsigned long get_wchan(struct task_stru
 			break;
 		rw = (struct reg_window *) fp;
 		pc = rw->ins[7];
-		if (pc < ((unsigned long) scheduling_functions_start_here) ||
-		    pc >= ((unsigned long) scheduling_functions_end_here)) {
+		if (pc < scheduling_functions_start_here ||
+		    pc >= scheduling_functions_end_here) {
 			ret = pc;
 			goto out;
 		}
arch/sparc64/kernel/semaphore.c +5 -4
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/sparc64/kernel/semaphore.c
@@ -8,6 +8,7 @@
 
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <linux/init.h>
 
 /*
  * Atomically update sem->count.
@@ -90,7 +91,7 @@ void up(struct semaphore *sem)
 	: "g5", "g7", "memory", "cc");
 }
 
-static void __down(struct semaphore * sem)
+static __sched void __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -108,7 +109,7 @@ static void __down(struct semaphore * se
 	wake_up(&sem->wait);
 }
 
-void down(struct semaphore *sem)
+__sched void down(struct semaphore *sem)
 {
 	might_sleep();
 	/* This atomically does:
@@ -192,7 +193,7 @@ int down_trylock(struct semaphore *sem)
 	return ret;
 }
 
-static int __down_interruptible(struct semaphore * sem)
+static __sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
@@ -216,7 +217,7 @@ static int __down_interruptible(struct s
 	return retval;
 }
 
-int down_interruptible(struct semaphore *sem)
+__sched int down_interruptible(struct semaphore *sem)
 {
 	int ret = 0;
 	
arch/sparc64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/sparc64/kernel/vmlinux.lds.S
@@ -15,6 +15,9 @@ SECTIONS
   .text 0x0000000000404000 :
   {
     *(.text)
+    __scheduling_functions_start_here = .;
+    *(.sched.text)
+    __scheduling_functions_end_here = .;
     *(.gnu.warning)
   } =0
   _etext = .;
arch/sparc64/lib/rwsem.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/sparc64/lib/rwsem.c wchan-2.6.0-test9-bk22-2/arch/sparc64/lib/rwsem.c
@@ -6,6 +6,7 @@
 
 #include <linux/kernel.h>
 #include <linux/rwsem.h>
+#include <linux/init.h>
 #include <linux/module.h>
 
 extern struct rw_semaphore *FASTCALL(rwsem_down_read_failed(struct rw_semaphore *sem));
@@ -13,7 +14,7 @@ extern struct rw_semaphore *FASTCALL(rws
 extern struct rw_semaphore *FASTCALL(rwsem_wake(struct rw_semaphore *));
 extern struct rw_semaphore *FASTCALL(rwsem_downgrade_wake(struct rw_semaphore *));
 
-void __down_read(struct rw_semaphore *sem)
+__sched void __down_read(struct rw_semaphore *sem)
 {
 	__asm__ __volatile__(
 		"! beginning __down_read\n"
@@ -72,7 +73,7 @@ int __down_read_trylock(struct rw_semaph
 }
 EXPORT_SYMBOL(__down_read_trylock);
 
-void __down_write(struct rw_semaphore *sem)
+__sched void __down_write(struct rw_semaphore *sem)
 {
 	__asm__ __volatile__(
 		"! beginning __down_write\n\t"
arch/v850/kernel/process.c +7 -11
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/v850/kernel/process.c
@@ -203,11 +203,6 @@ int sys_execve (char *name, char **argv,
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here (void);
-extern void scheduling_functions_end_here (void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan (struct task_struct *p)
 {
 #if 0  /* Barf.  Figure out the stack-layout later.  XXX  */
@@ -221,15 +216,16 @@ unsigned long get_wchan (struct task_str
 
 	/* This quite disgusting function walks up the stack, following
 	   saved return address, until it something that's out of bounds
-	   (as defined by `first_sched' and `last_sched').  It then
-	   returns the last PC that was in-bounds.  */
+	   (as defined by `scheduling_functions_start_here' and
+	   `scheduling_functions_end_here').  It then returns the last
+	   PC that was in-bounds.  */
 	do {
-		if (fp < stack_page + sizeof (struct task_struct) ||
-		    fp >= 8184+stack_page)
+		if (fp < stack_page + sizeof(struct thread_info) ||
+		    fp >= THREAD_SIZE + stack_page - 8)
 			return 0;
 		pc = ((unsigned long *)fp)[1];
-		/* FIXME: This depends on the order of these functions. */
-		if (pc < first_sched || pc >= last_sched)
+		if (pc < scheduling_functions_start_here ||
+				pc >= scheduling_functions_end_here)
 			return pc;
 		fp = *(unsigned long *) fp;
 	} while (count++ < 16);
arch/v850/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/v850/kernel/semaphore.c
@@ -15,6 +15,7 @@
 
 #include <linux/errno.h>
 #include <linux/sched.h>
+#include <linux/init.h>
 
 #include <asm/semaphore.h>
 
@@ -56,7 +57,7 @@ void __up(struct semaphore *sem)
 
 static spinlock_t semaphore_lock = SPIN_LOCK_UNLOCKED;
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -89,7 +90,7 @@ void __down(struct semaphore * sem)
 	wake_up(&sem->wait);
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
arch/v850/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/v850/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/v850/kernel/vmlinux.lds.S
@@ -64,6 +64,9 @@
 #define TEXT_CONTENTS							      \
 		__stext = . ;						      \
         	*(.text)						      \
+		__scheduling_functions_start_here = .;
+		*(.sched.text)
+		__scheduling_functions_end_here = .;
 			*(.exit.text)	/* 2.5 convention */		      \
 			*(.text.exit)	/* 2.4 convention */		      \
 			*(.text.lock)					      \
arch/x86_64/kernel/process.c +2 -8
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/process.c wchan-2.6.0-test9-bk22-2/arch/x86_64/kernel/process.c
@@ -528,11 +528,6 @@ asmlinkage long sys_vfork(struct pt_regs
 /*
  * These bracket the sleeping functions..
  */
-extern void scheduling_functions_start_here(void);
-extern void scheduling_functions_end_here(void);
-#define first_sched	((unsigned long) scheduling_functions_start_here)
-#define last_sched	((unsigned long) scheduling_functions_end_here)
-
 unsigned long get_wchan(struct task_struct *p)
 {
 	u64 fp,rip;
@@ -547,14 +542,13 @@ unsigned long get_wchan(struct task_stru
 		if (fp < (unsigned long)p || fp > (unsigned long)p+THREAD_SIZE)
 			return 0; 
 		rip = *(u64 *)(fp+8); 
-		if (rip < first_sched || rip >= last_sched)
+		if (rip < scheduling_functions_start_here ||
+				rip >= scheduling_functions_end_here)
 			return rip; 
 		fp = *(u64 *)fp; 
 	} while (count++ < 16); 
 	return 0;
 }
-#undef last_sched
-#undef first_sched
 
 long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
 { 
arch/x86_64/kernel/semaphore.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/semaphore.c wchan-2.6.0-test9-bk22-2/arch/x86_64/kernel/semaphore.c
@@ -14,6 +14,7 @@
  */
 #include <linux/config.h>
 #include <linux/sched.h>
+#include <linux/init.h>
 #include <asm/errno.h>
 
 #include <asm/semaphore.h>
@@ -54,7 +55,7 @@ void __up(struct semaphore *sem)
 	wake_up(&sem->wait);
 }
 
-void __down(struct semaphore * sem)
+__sched void __down(struct semaphore * sem)
 {
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
@@ -91,7 +92,7 @@ void __down(struct semaphore * sem)
 	tsk->state = TASK_RUNNING;
 }
 
-int __down_interruptible(struct semaphore * sem)
+__sched int __down_interruptible(struct semaphore * sem)
 {
 	int retval = 0;
 	struct task_struct *tsk = current;
arch/x86_64/kernel/vmlinux.lds.S +3 -0
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/kernel/vmlinux.lds.S wchan-2.6.0-test9-bk22-2/arch/x86_64/kernel/vmlinux.lds.S
@@ -14,6 +14,9 @@ SECTIONS
   _text = .;			/* Text and read-only data */
   .text : {
 	*(.text)
+	__scheduling_functions_start_here = .;
+	*(.sched.text)
+	__scheduling_functions_end_here = .;
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
arch/x86_64/lib/thunk.S +2 -1
diff -prauN linux-2.6.0-test9-bk22/arch/x86_64/lib/thunk.S wchan-2.6.0-test9-bk22-2/arch/x86_64/lib/thunk.S
@@ -30,6 +30,7 @@
 	.endm
 	
 
+	.section .sched.text
 #ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM
 	thunk rwsem_down_read_failed_thunk,rwsem_down_read_failed
 	thunk rwsem_down_write_failed_thunk,rwsem_down_write_failed
@@ -53,7 +54,7 @@ restore_norax:	
 
 #ifdef CONFIG_SMP
 /* Support for read/write spinlocks. */
-	
+	.text
 /* rax:	pointer to rwlock_t */	
 ENTRY(__write_lock_failed)
 	lock
include/linux/init.h +2 -0
diff -prauN linux-2.6.0-test9-bk22/include/linux/init.h wchan-2.6.0-test9-bk22-2/include/linux/init.h
@@ -45,6 +45,8 @@
 #define __exitdata	__attribute__ ((__section__(".exit.data")))
 #define __exit_call	__attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
 
+#define __sched		__attribute__((__section__(".sched.text")))
+
 #ifdef MODULE
 #define __exit		__attribute__ ((__section__(".exit.text")))
 #else
include/linux/sched.h +2 -0
diff -prauN linux-2.6.0-test9-bk22/include/linux/sched.h wchan-2.6.0-test9-bk22-2/include/linux/sched.h
@@ -169,6 +169,8 @@ extern void update_one_process(struct ta
 			       unsigned long system, int cpu);
 extern void scheduler_tick(int user_tick, int system);
 extern unsigned long cache_decay_ticks;
+extern const unsigned long scheduling_functions_start_here;
+extern const unsigned long scheduling_functions_end_here;
 
 
 #define	MAX_SCHEDULE_TIMEOUT	LONG_MAX
kernel/sched.c +20 -17
diff -prauN linux-2.6.0-test9-bk22/kernel/sched.c wchan-2.6.0-test9-bk22-2/kernel/sched.c
@@ -221,6 +221,13 @@ static DEFINE_PER_CPU(struct runqueue, r
 #define task_rq(p)		cpu_rq(task_cpu(p))
 #define cpu_curr(cpu)		(cpu_rq(cpu)->curr)
 
+extern unsigned long __scheduling_functions_start_here;
+extern unsigned long __scheduling_functions_end_here;
+const unsigned long scheduling_functions_start_here =
+			(unsigned long)&__scheduling_functions_start_here;
+const unsigned long scheduling_functions_end_here =
+			(unsigned long)&__scheduling_functions_end_here;
+
 /*
  * Default context-switch locking:
  */
@@ -1463,12 +1470,10 @@ out:
 	rebalance_tick(rq, 0);
 }
 
-void scheduling_functions_start_here(void) { }
-
 /*
  * schedule() is the main scheduler function.
  */
-asmlinkage void schedule(void)
+asmlinkage __sched void schedule(void)
 {
 	task_t *prev, *next;
 	runqueue_t *rq;
@@ -1611,7 +1616,7 @@ EXPORT_SYMBOL(schedule);
  * off of preempt_enable.  Kernel preemptions off return from interrupt
  * occur there and call schedule directly.
  */
-asmlinkage void preempt_schedule(void)
+asmlinkage __sched void preempt_schedule(void)
 {
 	struct thread_info *ti = current_thread_info();
 
@@ -1746,7 +1751,7 @@ void complete_all(struct completion *x)
 	spin_unlock_irqrestore(&x->wait.lock, flags);
 }
 
-void wait_for_completion(struct completion *x)
+__sched void wait_for_completion(struct completion *x)
 {
 	might_sleep();
 	spin_lock_irq(&x->wait.lock);
@@ -1784,7 +1789,7 @@ EXPORT_SYMBOL(wait_for_completion);
 	__remove_wait_queue(q, &wait);				\
 	spin_unlock_irqrestore(&q->lock, flags);
 
-void interruptible_sleep_on(wait_queue_head_t *q)
+__sched void interruptible_sleep_on(wait_queue_head_t *q)
 {
 	SLEEP_ON_VAR
 
@@ -1797,7 +1802,7 @@ void interruptible_sleep_on(wait_queue_h
 
 EXPORT_SYMBOL(interruptible_sleep_on);
 
-long interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout)
+__sched long interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout)
 {
 	SLEEP_ON_VAR
 
@@ -1812,7 +1817,7 @@ long interruptible_sleep_on_timeout(wait
 
 EXPORT_SYMBOL(interruptible_sleep_on_timeout);
 
-void sleep_on(wait_queue_head_t *q)
+__sched void sleep_on(wait_queue_head_t *q)
 {
 	SLEEP_ON_VAR
 
@@ -1825,7 +1830,7 @@ void sleep_on(wait_queue_head_t *q)
 
 EXPORT_SYMBOL(sleep_on);
 
-long sleep_on_timeout(wait_queue_head_t *q, long timeout)
+__sched long sleep_on_timeout(wait_queue_head_t *q, long timeout)
 {
 	SLEEP_ON_VAR
 
@@ -1840,8 +1845,6 @@ long sleep_on_timeout(wait_queue_head_t 
 
 EXPORT_SYMBOL(sleep_on_timeout);
 
-void scheduling_functions_end_here(void) { }
-
 void set_user_nice(task_t *p, long nice)
 {
 	unsigned long flags;
@@ -2291,7 +2294,7 @@ asmlinkage long sys_sched_yield(void)
 	return 0;
 }
 
-void __cond_resched(void)
+__sched void __cond_resched(void)
 {
 	set_current_state(TASK_RUNNING);
 	schedule();
@@ -2305,7 +2308,7 @@ EXPORT_SYMBOL(__cond_resched);
  * this is a shortcut for kernel-space yielding - it marks the
  * thread runnable and calls sys_sched_yield().
  */
-void yield(void)
+__sched void yield(void)
 {
 	set_current_state(TASK_RUNNING);
 	sys_sched_yield();
@@ -2320,7 +2323,7 @@ EXPORT_SYMBOL(yield);
  * But don't do that if it is a deliberate, throttling IO wait (this task
  * has set its backing_dev_info: the queue against which it should throttle)
  */
-void io_schedule(void)
+__sched void io_schedule(void)
 {
 	struct runqueue *rq = this_rq();
 
@@ -2331,7 +2334,7 @@ void io_schedule(void)
 
 EXPORT_SYMBOL(io_schedule);
 
-long io_schedule_timeout(long timeout)
+__sched long io_schedule_timeout(long timeout)
 {
 	struct runqueue *rq = this_rq();
 	long ret;
@@ -2881,7 +2884,7 @@ EXPORT_SYMBOL(__might_sleep);
  *
  * Called inside preempt_disable().
  */
-void __preempt_spin_lock(spinlock_t *lock)
+__sched void __preempt_spin_lock(spinlock_t *lock)
 {
 	if (preempt_count() > 1) {
 		_raw_spin_lock(lock);
@@ -2897,7 +2900,7 @@ void __preempt_spin_lock(spinlock_t *loc
 
 EXPORT_SYMBOL(__preempt_spin_lock);
 
-void __preempt_write_lock(rwlock_t *lock)
+__sched void __preempt_write_lock(rwlock_t *lock)
 {
 	if (preempt_count() > 1) {
 		_raw_write_lock(lock);
kernel/timer.c +2 -2
diff -prauN linux-2.6.0-test9-bk22/kernel/timer.c wchan-2.6.0-test9-bk22-2/kernel/timer.c
@@ -1000,7 +1000,7 @@ static void process_timeout(unsigned lon
  *
  * In all cases the return value is guaranteed to be non-negative.
  */
-signed long schedule_timeout(signed long timeout)
+__sched signed long schedule_timeout(signed long timeout)
 {
 	struct timer_list timer;
 	unsigned long expire;
@@ -1060,7 +1060,7 @@ asmlinkage long sys_gettid(void)
 	return current->pid;
 }
 
-static long nanosleep_restart(struct restart_block *restart)
+static __sched long nanosleep_restart(struct restart_block *restart)
 {
 	unsigned long expire = restart->arg0, now = jiffies;
 	struct timespec *rmtp = (struct timespec *) restart->arg1;
lib/rwsem.c +3 -2
diff -prauN linux-2.6.0-test9-bk22/lib/rwsem.c wchan-2.6.0-test9-bk22-2/lib/rwsem.c
@@ -5,6 +5,7 @@
  */
 #include <linux/rwsem.h>
 #include <linux/sched.h>
+#include <linux/init.h>
 #include <linux/module.h>
 
 struct rwsem_waiter {
@@ -162,7 +163,7 @@ static inline struct rw_semaphore *rwsem
 /*
  * wait for the read lock to be granted
  */
-struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem)
+__sched struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem)
 {
 	struct rwsem_waiter waiter;
 
@@ -178,7 +179,7 @@ struct rw_semaphore *rwsem_down_read_fai
 /*
  * wait for the write lock to be granted
  */
-struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem)
+__sched struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem)
 {
 	struct rwsem_waiter waiter;