statm         Process memory status information
  status                Process status in human readable form
  wchan         If CONFIG_KALLSYMS is set, a pre-decoded wchan
+ stack         Report full stack trace, enable via CONFIG_STACKTRACE
  smaps         Extension based on maps, the rss size for each mapped file
 ..............................................................................
 
 
        }
 }
 
-static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
+static void save_context_stack(struct stack_trace *trace,
+       struct task_struct *tsk, struct pt_regs *regs)
 {
        unsigned long sp = regs->regs[29];
 #ifdef CONFIG_KALLSYMS
 
        if (raw_show_trace || !__kernel_text_address(pc)) {
                unsigned long stack_page =
-                       (unsigned long)task_stack_page(current);
+                       (unsigned long)task_stack_page(tsk);
                if (stack_page && sp >= stack_page &&
                    sp <= stack_page + THREAD_SIZE - 32)
                        save_raw_context_stack(trace, sp);
                        trace->entries[trace->nr_entries++] = pc;
                if (trace->nr_entries >= trace->max_entries)
                        break;
-               pc = unwind_stack(current, &sp, pc, &ra);
+               pc = unwind_stack(tsk, &sp, pc, &ra);
        } while (pc);
 #else
        save_raw_context_stack(trace, sp);
  * Save stack-backtrace addresses into a stack_trace buffer.
  */
 void save_stack_trace(struct stack_trace *trace)
+{
+       save_stack_trace_tsk(current, trace);
+}
+EXPORT_SYMBOL_GPL(save_stack_trace);
+
+void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
        struct pt_regs dummyregs;
        struct pt_regs *regs = &dummyregs;
 
        WARN_ON(trace->nr_entries || !trace->max_entries);
 
-       prepare_frametrace(regs);
-       save_context_stack(trace, regs);
+       if (tsk != current) {
+               regs->regs[29] = tsk->thread.reg29;
+               regs->regs[31] = 0;
+               regs->cp0_epc = tsk->thread.reg31;
+       } else
+               prepare_frametrace(regs);
+       save_context_stack(trace, tsk, regs);
 }
-EXPORT_SYMBOL_GPL(save_stack_trace);
+EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
 
 #include <linux/mm.h>
 #include <linux/rcupdate.h>
 #include <linux/kallsyms.h>
+#include <linux/stacktrace.h>
 #include <linux/resource.h>
 #include <linux/module.h>
 #include <linux/mount.h>
 }
 #endif /* CONFIG_KALLSYMS */
 
+#ifdef CONFIG_STACKTRACE
+
+#define MAX_STACK_TRACE_DEPTH  64
+
+static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
+                         struct pid *pid, struct task_struct *task)
+{
+       struct stack_trace trace;
+       unsigned long *entries;
+       int i;
+
+       entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL);
+       if (!entries)
+               return -ENOMEM;
+
+       trace.nr_entries        = 0;
+       trace.max_entries       = MAX_STACK_TRACE_DEPTH;
+       trace.entries           = entries;
+       trace.skip              = 0;
+       save_stack_trace_tsk(task, &trace);
+
+       for (i = 0; i < trace.nr_entries; i++) {
+               seq_printf(m, "[<%p>] %pS\n",
+                          (void *)entries[i], (void *)entries[i]);
+       }
+       kfree(entries);
+
+       return 0;
+}
+#endif
+
 #ifdef CONFIG_SCHEDSTATS
 /*
  * Provides /proc/PID/schedstat
 #ifdef CONFIG_KALLSYMS
        INF("wchan",      S_IRUGO, proc_pid_wchan),
 #endif
+#ifdef CONFIG_STACKTRACE
+       ONE("stack",      S_IRUSR, proc_pid_stack),
+#endif
 #ifdef CONFIG_SCHEDSTATS
        INF("schedstat",  S_IRUGO, proc_pid_schedstat),
 #endif
 #ifdef CONFIG_KALLSYMS
        INF("wchan",     S_IRUGO, proc_pid_wchan),
 #endif
+#ifdef CONFIG_STACKTRACE
+       ONE("stack",      S_IRUSR, proc_pid_stack),
+#endif
 #ifdef CONFIG_SCHEDSTATS
        INF("schedstat", S_IRUGO, proc_pid_schedstat),
 #endif