From 6c31da3464b4d28825d1827ee41a3a217b2dcf0e Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Sat, 19 Mar 2016 17:54:10 +0100 Subject: [PATCH] parisc,metag: Implement CONFIG_DEBUG_STACK_USAGE option On parisc and metag the stack grows upwards, so for those we need to scan the stack downwards in order to calculate how much stack a process has used. Tested on a 64bit parisc kernel. Signed-off-by: Helge Deller --- include/linux/sched.h | 8 ++++++++ lib/Kconfig.debug | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 34495d2d2d7b..589c4780b077 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2870,10 +2870,18 @@ static inline unsigned long stack_not_used(struct task_struct *p) unsigned long *n = end_of_stack(p); do { /* Skip over canary */ +# ifdef CONFIG_STACK_GROWSUP + n--; +# else n++; +# endif } while (!*n); +# ifdef CONFIG_STACK_GROWSUP + return (unsigned long)end_of_stack(p) - (unsigned long)n; +# else return (unsigned long)n - (unsigned long)end_of_stack(p); +# endif } #endif extern void set_task_stack_end_magic(struct task_struct *tsk); diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 532d4d52d1df..1e9a607534ca 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -558,7 +558,7 @@ config DEBUG_KMEMLEAK_DEFAULT_OFF config DEBUG_STACK_USAGE bool "Stack utilization instrumentation" - depends on DEBUG_KERNEL && !IA64 && !PARISC && !METAG + depends on DEBUG_KERNEL && !IA64 help Enables the display of the minimum amount of free stack which each task has ever had available in the sysrq-T and sysrq-P debug output. -- 2.39.2