From: Anton Blanchard <anton@samba.org>

Add DEBUG_STACK_USAGE to ppc64


---

 arch/ppc64/Kconfig              |    9 +++++++++
 include/asm-ppc64/thread_info.h |   15 ++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff -puN arch/ppc64/Kconfig~ppc64-debug-stack-usage arch/ppc64/Kconfig
--- 25/arch/ppc64/Kconfig~ppc64-debug-stack-usage	2004-02-21 20:58:20.000000000 -0800
+++ 25-akpm/arch/ppc64/Kconfig	2004-02-21 20:58:20.000000000 -0800
@@ -316,6 +316,15 @@ config DEBUG_KERNEL
 	  Say Y here if you are developing drivers or trying to debug and
 	  identify kernel problems.
 
+config DEBUG_STACK_USAGE
+	bool "Stack utilization instrumentation"
+	depends on DEBUG_KERNEL
+	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.
+
+	  This option will slow down process creation somewhat.
+
 config DEBUG_SLAB
 	bool "Debug memory allocations"
 	depends on DEBUG_KERNEL
diff -puN include/asm-ppc64/thread_info.h~ppc64-debug-stack-usage include/asm-ppc64/thread_info.h
--- 25/include/asm-ppc64/thread_info.h~ppc64-debug-stack-usage	2004-02-21 20:58:20.000000000 -0800
+++ 25-akpm/include/asm-ppc64/thread_info.h	2004-02-21 20:58:20.000000000 -0800
@@ -11,6 +11,7 @@
 #ifdef __KERNEL__
 
 #ifndef __ASSEMBLY__
+#include <linux/config.h>
 #include <asm/processor.h>
 #include <linux/stringify.h>
 
@@ -51,7 +52,19 @@ struct thread_info {
 #define THREAD_ORDER		2
 #define THREAD_SIZE		(PAGE_SIZE << THREAD_ORDER)
 #define THREAD_SHIFT		(PAGE_SHIFT + THREAD_ORDER)
-#define alloc_thread_info(task)	((struct thread_info *)kmalloc(THREAD_SIZE, GFP_KERNEL))
+#ifdef CONFIG_DEBUG_STACK_USAGE
+#define alloc_thread_info(tsk)					\
+	({							\
+		struct thread_info *ret;			\
+								\
+		ret = kmalloc(THREAD_SIZE, GFP_KERNEL);		\
+		if (ret)					\
+			memset(ret, 0, THREAD_SIZE);		\
+		ret;						\
+	})
+#else
+#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
+#endif
 #define free_thread_info(ti)	kfree(ti)
 #define get_thread_info(ti)	get_task_struct((ti)->task)
 #define put_thread_info(ti)	put_task_struct((ti)->task)

_