Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c11274655558e72d8d4a598c0077874c094d97d5
Commit:     c11274655558e72d8d4a598c0077874c094d97d5
Parent:     c9a3072d13e4b8a6549ecc1db6390a55c7ee2ddf
Author:     Jeff Dike <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 4 22:30:36 2008 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Feb 5 09:44:25 2008 -0800

    uml: implement get_wchan
    
    Implement get_wchan - the algorithm is similar to x86.  It starts with the
    stack pointer of the process in question and looks above that for addresses
    that are kernel text.  The second one which isn't in the scheduler is the 
one
    that's returned.  The first one is ignored because that will be UML's own
    context switching routine.
    
    Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 arch/um/kernel/process.c           |   35 +++++++++++++++++++++++++++++++++++
 include/asm-um/processor-generic.h |    2 +-
 2 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 0eae00b..c7ea7f2 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -459,3 +459,38 @@ unsigned long arch_align_stack(unsigned long sp)
        return sp & ~0xf;
 }
 #endif
+
+unsigned long get_wchan(struct task_struct *p)
+{
+       unsigned long stack_page, sp, ip;
+       bool seen_sched = 0;
+
+       if ((p == NULL) || (p == current) || (p->state == TASK_RUNNING))
+               return 0;
+
+       stack_page = (unsigned long) task_stack_page(p);
+       /* Bail if the process has no kernel stack for some reason */
+       if (stack_page == 0)
+               return 0;
+
+       sp = p->thread.switch_buf->JB_SP;
+       /*
+        * Bail if the stack pointer is below the bottom of the kernel
+        * stack for some reason
+        */
+       if (sp < stack_page)
+               return 0;
+
+       while (sp < stack_page + THREAD_SIZE) {
+               ip = *((unsigned long *) sp);
+               if (in_sched_functions(ip))
+                       /* Ignore everything until we're above the scheduler */
+                       seen_sched = 1;
+               else if (kernel_text_address(ip) && seen_sched)
+                       return ip;
+
+               sp += sizeof(unsigned long);
+       }
+
+       return 0;
+}
diff --git a/include/asm-um/processor-generic.h 
b/include/asm-um/processor-generic.h
index 78c0599..057a76d 100644
--- a/include/asm-um/processor-generic.h
+++ b/include/asm-um/processor-generic.h
@@ -128,6 +128,6 @@ extern struct cpuinfo_um cpu_data[];
 
 
 #define KSTK_REG(tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf)
-#define get_wchan(p) (0)
+extern unsigned long get_wchan(struct task_struct *p);
 
 #endif
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to