Hi Jate,
On 26/10/10 07:27, Jate Sujjavanich wrote:
For us people still running m68knommu: I implemented this in arch/m68k*. I patched fs/proc/base.c, and I'm not sure entirely sure if it's the proper place. I believe a stack checker for threads would need to be implemented inside of libpthreads. ---- Simple stack checker for the m68knommu architecture. It implements a per-PID proc file system entry. The kernel already memsets the bss, brk, and stack regions to zero. The checker calculates the used stack space by searching for the first non-zero value. The values returned are the total stack size and used size. /root # cat /proc/144/stackuse 4082 2089 Signed-off-by<Jate Sujjavanich jsujjavan...@syntech-fuelmaster.com> ---- diff --git a/arch/m68k/include/asm/mmu.h b/arch/m68k/include/asm/mmu.h index 8a11a63..cbb0db7 100644 --- a/arch/m68k/include/asm/mmu.h +++ b/arch/m68k/include/asm/mmu.h @@ -7,6 +7,7 @@ typedef unsigned long mm_context_t; #else typedef struct { unsigned long end_brk; + unsigned long end_stack;
This added field never seems to be initialized or set to any value in the following parts of the patch? Even though its value is used... Regards Greg
} mm_context_t; #endif diff --git a/fs/proc/base.c b/fs/proc/base.c index 8418fcc..f33557a 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -360,6 +360,30 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns, } #endif +#if !defined(CONFIG_MMU)&& defined(CONFIG_M68K) +static int proc_pid_stack_usage(struct seq_file *m, struct pid_namespace *ns, + struct pid *pid, struct task_struct *task) +{ + struct mm_struct *mm = get_task_mm(task); + + unsigned long stack_length = mm->start_stack - mm->context.end_stack; + unsigned char *stack_first_data = + (unsigned char *)mm->context.end_stack; + unsigned long stack_used; + + while ((stack_first_data< (unsigned char *)mm->start_stack) + && (*stack_first_data == 0)) + stack_first_data++; + + stack_used = mm->start_stack - (unsigned long)stack_first_data; + + /* est stack size, zero zone */ + seq_printf(m, "%lu %lu\n", stack_length, (unsigned long)stack_used); + + return 0; +} +#endif + #ifdef CONFIG_SCHEDSTATS /* * Provides /proc/PID/schedstat @@ -2615,6 +2639,9 @@ static const struct pid_entry tgid_base_stuff[] = { #ifdef CONFIG_STACKTRACE ONE("stack", S_IRUSR, proc_pid_stack), #endif +#if !defined(CONFIG_MMU)&& defined(CONFIG_M68K) + ONE("stackuse", S_IRUGO, proc_pid_stack_usage), +#endif #ifdef CONFIG_SCHEDSTATS INF("schedstat", S_IRUGO, proc_pid_schedstat), #endif @@ -2949,6 +2976,9 @@ static const struct pid_entry tid_base_stuff[] = { #ifdef CONFIG_STACKTRACE ONE("stack", S_IRUSR, proc_pid_stack), #endif +#if !defined(CONFIG_MMU)&& defined(CONFIG_M68K) + ONE("stackuse", S_IRUGO, proc_pid_stack_usage), +#endif #ifdef CONFIG_SCHEDSTATS INF("schedstat", S_IRUGO, proc_pid_schedstat), #endif _______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
-- ------------------------------------------------------------------------ Greg Ungerer -- Principal Engineer EMAIL: g...@snapgear.com SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com _______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev