Minor __sched cleanups
Subsystems (9)
PATCH 1/1 Minor __sched cleanups
Fairly minor cleanups to wli's recent __sched implementation:
Name: Minor __sched Cleanups
Status: Tested on 2.6.5-mm4
Version: -mm
1) __sched_text_start and __sched_test_end are more normal section marker names, and can be used directly.
2) There is no comment and no reason for __sched to be in linux/init.h:
linux/sched.h would be preferable.
arch/alpha/kernel/process.c +2 -2
@@ -513,8 +513,8 @@ thread_saved_pc(task_t *t)/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p)
arch/arm/kernel/process.c +2 -2
@@ -414,8 +414,8 @@ pid_t kernel_thread(int (*fn)(void *), v/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/arm26/kernel/process.c +2 -2
@@ -400,8 +400,8 @@ pid_t kernel_thread(int (*fn)(void *), v/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/cris/arch-v10/kernel/process.c +2 -2
@@ -217,8 +217,8 @@ asmlinkage int sys_execve(const char *fn* These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/h8300/kernel/process.c +2 -2
@@ -264,8 +264,8 @@ out:/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long thread_saved_pc (struct task_struct *tsk) {
arch/i386/kernel/kgdb_stub.c +2 -2
@@ -654,8 +654,8 @@ gdb_regs_to_regs(int *gdb_regs, struct p#endif }/* gdb_regs_to_regs */ -#define first_sched scheduling_functions_start_here -#define last_sched scheduling_functions_end_here +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)int thread_list =0 ;
arch/i386/kernel/process.c +2 -2
@@ -632,8 +632,8 @@ out:/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)#define top_esp (THREAD_SIZE - sizeof(unsigned long))#define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long))
arch/ia64/kernel/process.c +2 -2
@@ -660,8 +660,8 @@ get_wchan (struct task_struct *p)/* * These bracket the sleeping functions.. */ -# define first_sched ((unsigned long) scheduling_functions_start_here) -# define last_sched ((unsigned long) scheduling_functions_end_here) +# define first_sched ((unsigned long)__sched_text_start) +# define last_sched ((unsigned long)__sched_text_end)/* * Note: p may not be a blocked task (it could be current or
arch/m68k/kernel/process.c +4 -4
@@ -67,8 +67,8 @@ unsigned long thread_saved_pc(struct tas {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 > (unsigned long )__sched_text_start && + sw->retpc < (unsigned long )__sched_text_end)return ((unsigned long *)sw->a6)[1 ];else return sw->retpc;
@@ -385,8 +385,8 @@ out:/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/m68knommu/kernel/process.c +4 -4
@@ -407,8 +407,8 @@ out:/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
@@ -440,8 +440,8 @@ unsigned long thread_saved_pc(struct tasstruct 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 > (unsigned long )__sched_text_start && + sw->retpc < (unsigned long )__sched_text_end)return ((unsigned long *)sw->a6)[1 ];else return sw->retpc;
arch/mips/kernel/process.c +2 -2
@@ -283,8 +283,8 @@ unsigned long thread_saved_pc(struct tas/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)/* get_wchan - a maintenance nightmare^W^Wpain in the ass ... */ unsigned long get_wchan (struct task_struct *p)
arch/ppc/kernel/process.c +2 -2
@@ -661,8 +661,8 @@ void __init ll_puts(const char *s)/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/ppc64/kernel/process.c +2 -2
@@ -475,8 +475,8 @@ static inline int validate_sp(unsigned l/* * These bracket the sleeping functions.. */ -#define first_sched (*(unsigned long *)scheduling_functions_start_here) -#define last_sched (*(unsigned long *)scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/s390/kernel/process.c +2 -2
@@ -384,8 +384,8 @@ void dump_thread(struct pt_regs * regs,/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/sh/kernel/process.c +2 -2
@@ -464,8 +464,8 @@ out:/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/sparc/kernel/process.c +2 -2
@@ -715,8 +715,8 @@ unsigned long get_wchan(struct task_strubreak ; 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 < ((unsigned long )__sched_text_start) || + pc >= ((unsigned long )__sched_text_end)) { ret = pc; goto out; }
arch/sparc64/kernel/process.c +2 -2
@@ -847,8 +847,8 @@ unsigned long get_wchan(struct task_strubreak ; 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 < ((unsigned long )__sched_text_start) || + pc >= ((unsigned long )__sched_text_end)) { ret = pc; goto out; }
arch/v850/kernel/process.c +2 -2
@@ -203,8 +203,8 @@ int sys_execve (char *name, char **argv,/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/x86_64/kernel/kgdb_stub.c +2 -2
@@ -667,8 +667,8 @@ gdb_regs_to_regs(unsigned long *gdb_regs#endif }/* gdb_regs_to_regs */ -#define first_sched scheduling_functions_start_here -#define last_sched scheduling_functions_end_here +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)int thread_list =0 ;extern void thread_return (void );
arch/x86_64/kernel/process.c +2 -2
@@ -576,8 +576,8 @@ asmlinkage long sys_vfork(struct pt_regs/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
include/asm-generic/vmlinux.lds.h +2 -2
@@ -53,6 +53,6 @@ }#define SCHED_TEXT \ - __scheduling_functions_start_here = .; \ + __sched_text_start = .; \ *(.sched.text) \ - __scheduling_functions_end_here = .; + __sched_text_end = .;
include/linux/init.h +0 -2
@@ -47,8 +47,6 @@#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 +6 -0
@@ -172,6 +172,12 @@ 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; + +/* Attach to any functions which should be ignored in wchan output. */ +#define __sched __attribute__((__section__(".sched.text"))) +/* Linker adds these: start and end of __sched functions */ +extern char __sched_text_start[], __sched_text_end[]; +extern const unsigned long scheduling_functions_start_here;extern const unsigned long scheduling_functions_end_here;
kernel/sched.c +0 -7
@@ -252,13 +252,6 @@ 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: */
Signature · 1 line
Anyone who quotes me in their signature is an idiot -- Rusty Russell
arch/alpha/kernel/process.c thread_saved_pc(task_t *t) · line 517
Quoted 11 lines
diff -urpN --exclude TAGS -X
/home/rusty/devel/kernel/kernel-patches/current-dontdiff--minimal.24943-linux-2.6.5-mm4/arch/alpha/kernel/process.c.24943-linux-2.6.5-mm4.updated/arch/alpha/kernel/process.carch/alpha/kernel/process.c +2
-2@@ -513,8 +513,8 @@ thread_saved_pc(task_t *t)/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)
Any good reason to keep the definitions in the various arch specific process.c files?
Locating them in sched.h would be a nice consolidation.
Sam
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · William Lee Irwin III
Quoted 8 lines · Rusty Russell
Fairly minor cleanups to wli's recent
__schedimplementation:
Name: Minor__schedCleanups
Status: Tested on 2.6.5-mm4
Version: -mm
1)__sched_text_startand__sched_test_endare more normal section marker names, and can be used directly.
2) There is no comment and no reason for__schedto be inlinux/init.h:
linux/sched.hwould be preferable.Hmm, why not consolidate first_sched/last_sched while we're at it?
s/consolidate/remove/ perhaps?
Agreed that they're kinda silly. This moves the test into sched.c.
How's this instead?
Name: in_sched_functions()
Status: Booted on 2.6.5-mm4
Version: -mm
1) Create an in_sched_functions() function in sched.c and make the archs use it. (Two archs have wchan #if 0'd out: left them alone).
2) Move __sched from linux/init.h to linux/sched.h and add comment.
3) Rename __scheduling_functions_start_here/end_here to __sched_text_start/end.
Thanks to wli and Sam Ravnborg for clue donation.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .24943-linux-2.6.5-mm4/arch/alpha/kernel/process.c .24943-linux-2.6.5-mm4.updated/arch/alpha/kernel/process.c
arch/alpha/kernel/process.c +1 -7
@@ -510,12 +510,6 @@ thread_saved_pc(task_t *t)return 0 ; } -/* -* These bracket the sleeping functions.. -*/ -#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) {
@@ -534,7 +528,7 @@ get_wchan(struct task_struct *p)*/ pc =thread_saved_pc (p); -if (pc >= first_sched && pc < last_sched) { +if (in_sched_functions (pc)) { schedule_frame = ((unsigned long *)p->thread_info->pcb.ksp)[6 ];return ((unsigned long *)schedule_frame)[12 ]; }
arch/arm/kernel/process.c +1 -7
@@ -411,12 +411,6 @@ pid_t kernel_thread(int (*fn)(void *), vreturn do_fork (flags|CLONE_VM |CLONE_UNTRACED ,0 , ®s,0 ,NULL ,NULL ); } -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -431,7 +425,7 @@ unsigned long get_wchan(struct task_struif (fp < stack_page || fp >4092 +stack_page)return 0 ; lr =pc_pointer (((unsigned long *)fp)[-1 ]); -if (lr < first_sched || lr > last_sched) +if (!in_sched_functions (lr))return lr; fp = *(unsigned long *) (fp -12 ); }while (count ++ <16 );
arch/arm26/kernel/process.c +1 -7
@@ -397,12 +397,6 @@ pid_t kernel_thread(int (*fn)(void *), vreturn __ret; } -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -417,7 +411,7 @@ unsigned long get_wchan(struct task_struif (fp < stack_page || fp >4092 +stack_page)return 0 ; lr =pc_pointer (((unsigned long *)fp)[-1 ]); -if (lr < first_sched || lr > last_sched) +if (!in_sched_functions (lr))return lr; fp = *(unsigned long *) (fp -12 ); }while (count ++ <16 );
arch/cris/arch-v10/kernel/process.c +2 -2
@@ -217,8 +217,8 @@ asmlinkage int sys_execve(const char *fn* These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/h8300/kernel/process.c +1 -7
@@ -261,12 +261,6 @@ out:return error; } -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -287,7 +281,7 @@ unsigned long get_wchan(struct task_stru fp >= 8184+stack_page)return 0 ; pc = ((unsigned long *)fp)[1 ]; -if (pc < first_sched || pc >= last_sched) +if (!in_sched_functions (pc))return pc; fp = *(unsigned long *) fp; }while (count++ <16 );
arch/i386/kernel/kgdb_stub.c +1 -3
@@ -654,8 +654,6 @@ gdb_regs_to_regs(int *gdb_regs, struct p#endif }/* gdb_regs_to_regs */ -#define first_sched scheduling_functions_start_here -#define last_sched scheduling_functions_end_hereint thread_list =0 ;
@@ -716,7 +714,7 @@ get_gdb_regs(struct task_struct *p, stru gdb_regs[_PC] = *(unsigned long *) (gdb_regs[_EBP] +4 ); gdb_regs[_ESP] = gdb_regs[_EBP] +8 ; gdb_regs[_EBP] = *(unsigned long *) gdb_regs[_EBP]; -if (gdb_regs[_PC] < first_sched || gdb_regs[_PC] >= last_sched) +if (!in_sched_functions (gdb_regs[_PC]))return ; }while (count++ <16 );return ;
arch/i386/kernel/process.c +1 -8
@@ -629,11 +629,6 @@ out:return error; } -/* -* These bracket the sleeping functions.. -*/ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here)#define top_esp (THREAD_SIZE - sizeof(unsigned long))#define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long))
@@ -654,14 +649,12 @@ unsigned long get_wchan(struct task_struif (ebp < stack_page || ebp > top_ebp+stack_page)return 0 ; eip = *(unsigned long *) (ebp+4 ); -if (eip < first_sched || eip >= last_sched) +if (!in_sched_functions (eip))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/ia64/kernel/process.c +1 -8
@@ -657,11 +657,6 @@ get_wchan (struct task_struct *p)struct unw_frame_info info;unsigned long ip;int count =0 ; -/* -* These bracket the sleeping functions.. -*/ -# 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
@@ -676,12 +671,10 @@ 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 (!in_sched_functions (ip))return ip; }while (count++ <16 );return 0 ; -# undef first_sched -# undef last_sched }void
arch/m68k/kernel/process.c +3 -9
@@ -67,8 +67,8 @@ unsigned long thread_saved_pc(struct tas {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 > (unsigned long )__sched_text_start && + sw->retpc < (unsigned long )__sched_text_end)return ((unsigned long *)sw->a6)[1 ];else return sw->retpc;
@@ -382,12 +382,6 @@ out:return error; } -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -403,7 +397,7 @@ unsigned long get_wchan(struct task_stru fp >= 8184+stack_page)return 0 ; pc = ((unsigned long *)fp)[1 ]; -if (pc < first_sched || pc >= last_sched) +if (!in_sched_functions (pc))return pc; fp = *(unsigned long *) fp; }while (count++ <16 );
arch/m68knommu/kernel/process.c +3 -9
@@ -404,12 +404,6 @@ out:return error; } -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -425,7 +419,7 @@ unsigned long get_wchan(struct task_stru fp >= 8184+stack_page)return 0 ; pc = ((unsigned long *)fp)[1 ]; -if (pc < first_sched || pc >= last_sched) +if (!in_sched_functions (pc))return pc; fp = *(unsigned long *) fp; }while (count++ <16 );
@@ -440,8 +434,8 @@ unsigned long thread_saved_pc(struct tasstruct 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 > (unsigned long )__sched_text_start && + sw->retpc < (unsigned long )__sched_text_end)return ((unsigned long *)sw->a6)[1 ];else return sw->retpc;
arch/mips/kernel/process.c +2 -8
@@ -280,12 +280,6 @@ unsigned long thread_saved_pc(struct tasreturn ((unsigned long *)t->reg29)[schedule_frame.pc_offset]; } -/* -* These bracket the sleeping functions.. -*/ -#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) {
@@ -297,7 +291,7 @@ unsigned long get_wchan(struct task_struif (!mips_frame_info_initialized)return 0 ; pc =thread_saved_pc (p); -if (pc < first_sched || pc >= last_sched) +if (!in_sched_functions (pc)) goto out;if (pc >= (unsigned long ) sleep_on_timeout)
@@ -331,7 +325,7 @@ schedule_timeout_caller:*/ pc = ((unsigned long *)frame)[schedule_timeout_frame.pc_offset]; -if (pc >= first_sched && pc < last_sched) { +if (in_sched_functions (pc)) {/* 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/ppc/kernel/process.c +1 -7
@@ -658,12 +658,6 @@ void __init ll_puts(const char *s) }#endif -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -678,7 +672,7 @@ unsigned long get_wchan(struct task_strureturn 0 ;if (count >0 ) { ip = *(unsigned long *)(sp +4 ); -if (ip < first_sched || ip >= last_sched) +if (!in_sched_functions (ip))return ip; } }while (count++ <16 );
arch/ppc64/kernel/process.c +1 -7
@@ -472,12 +472,6 @@ static inline int validate_sp(unsigned lreturn 1 ; } -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -496,7 +490,7 @@ unsigned long get_wchan(struct task_strureturn 0 ;if (count >0 ) { ip = *(unsigned long *)(sp +16 ); -if (ip < first_sched || ip >= last_sched) +if (!in_sched_functions (ip))return ip; } }while (count++ <16 );
arch/s390/kernel/process.c +1 -9
@@ -381,12 +381,6 @@ void dump_thread(struct pt_regs * regs, dump->regs.per_info = current->thread.per_info; } -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -409,12 +403,10 @@ unsigned long get_wchan(struct task_stru#else r14 = *(unsigned long *) (bc+112 );#endif -if (r14 < first_sched || r14 >= last_sched) +if (!in_sched_functions (r14))return r14; bc = (*(unsigned long *) bc) &PSW_ADDR_INSN ; }while (count++ <16 );return 0 ; } -#undef last_sched -#undef first_sched
arch/sh/kernel/process.c +1 -7
@@ -461,12 +461,6 @@ out:return error; } -/* -* These bracket the sleeping functions.. -*/ -#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;
@@ -479,7 +473,7 @@ unsigned long get_wchan(struct task_stru* The same comment as on the Alpha applies here, too ... */ pc =thread_saved_pc (p); -if (pc >= first_sched && pc < last_sched) { +if (in_sched_functions (pc)) { schedule_frame = ((unsigned long *)(long )p->thread.sp)[1 ];return (unsigned long )((unsigned long *)schedule_frame)[1 ]; }
arch/sparc/kernel/process.c +2 -2
@@ -715,8 +715,8 @@ unsigned long get_wchan(struct task_strubreak ; 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 < ((unsigned long )__sched_text_start) || + pc >= ((unsigned long )__sched_text_end)) { ret = pc; goto out; }
arch/sparc64/kernel/process.c +2 -2
@@ -847,8 +847,8 @@ unsigned long get_wchan(struct task_strubreak ; 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 < ((unsigned long )__sched_text_start) || + pc >= ((unsigned long )__sched_text_end)) { ret = pc; goto out; }
arch/v850/kernel/process.c +2 -2
@@ -203,8 +203,8 @@ int sys_execve (char *name, char **argv,/* * These bracket the sleeping functions.. */ -#define first_sched ((unsigned long) scheduling_functions_start_here) -#define last_sched ((unsigned long) scheduling_functions_end_here) +#define first_sched ((unsigned long)__sched_text_start) +#define last_sched ((unsigned long)__sched_text_end)unsigned long get_wchan (struct task_struct *p) {
arch/x86_64/kernel/kgdb_stub.c +1 -4
@@ -667,9 +667,6 @@ gdb_regs_to_regs(unsigned long *gdb_regs#endif }/* gdb_regs_to_regs */ -#define first_sched scheduling_functions_start_here -#define last_sched scheduling_functions_end_here -int thread_list =0 ;extern void thread_return (void );
@@ -730,7 +727,7 @@ get_gdb_regs(struct task_struct *p, stru rsp = (unsigned long *)rbp; pc = rsp[1 ]; -if (pc < first_sched || pc >= last_sched) +if (!in_sched_functions (pc))break ; gdb_regs[_PC] = (unsigned long )pc; gdb_regs[_RSP] = (unsigned long )rsp;
arch/x86_64/kernel/process.c +1 -9
@@ -573,12 +573,6 @@ asmlinkage long sys_vfork(struct pt_regs NULL, NULL); } -/* -* These bracket the sleeping functions.. -*/ -#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 stack;
@@ -595,14 +589,12 @@ unsigned long get_wchan(struct task_struif (fp < (unsigned long )stack || fp > (unsigned long )stack+THREAD_SIZE )return 0 ; rip = *(u64 *)(fp+8 ); -if (rip < first_sched || rip >= last_sched) +if (!in_sched_functions (rip))return rip; fp = *(u64 *)fp; }while (count++ <16 );return 0 ; } -#undef last_sched -#undef first_schedlong do_arch_prctl (struct task_struct *task,int code,unsigned long addr) {
include/asm-generic/vmlinux.lds.h +2 -2
@@ -53,6 +53,6 @@ }#define SCHED_TEXT \ - __scheduling_functions_start_here = .; \ + __sched_text_start = .; \ *(.sched.text) \ - __scheduling_functions_end_here = .; + __sched_text_end = .;
include/linux/init.h +0 -2
@@ -47,8 +47,6 @@#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 +4 -2
@@ -172,9 +172,11 @@ 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; +/* Attach to any functions which should be ignored in wchan output. */ +#define __sched __attribute__((__section__(".sched.text"))) +/* Is this address in the __sched functions? */ +extern int in_sched_functions (unsigned long addr);#define MAX_SCHEDULE_TIMEOUT LONG_MAXextern signed long FASTCALL (schedule_timeout (signed long timeout));
kernel/sched.c +8 -7
@@ -252,13 +252,6 @@ 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: */
@@ -3676,6 +3669,14 @@ void __init sched_init_smp(void) }#endif /* CONFIG_SMP */ +int in_sched_functions (unsigned long addr) +{ +/* Linker adds these: start and end of __sched functions */ +extern char __sched_text_start[], __sched_text_end[]; +return addr >= (unsigned long )__sched_text_start + && addr < (unsigned long )__sched_text_end; +} +void __init sched_init (void ) {runqueue_t *rq;
Signature · 1 line
Anyone who quotes me in their signature is an idiot -- Rusty Russell