[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20081106195107.GA17545@x200.localdomain>
Date: Thu, 6 Nov 2008 22:51:07 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Ken Chen <kenchen@...gle.com>
Cc: Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org
Subject: Re: [patch] add /proc/pid/stack to dump task's stack trace
On Thu, Nov 06, 2008 at 11:01:39AM -0800, Ken Chen wrote:
> This patch adds the ability to query a task's stack trace via /proc/pid/stack.
> It is considered to be more useful than /proc/pid/wchan as it provides full
> stack trace instead of single depth.
Please, name handler proc_pid_stack following current convention.
And drop space before casts.
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -338,6 +339,35 @@ static int proc_pid_wchan
> else
> return sprintf(buffer, "%s", symname);
> }
> +
> +#define MAX_STACK_TRACE_DEPTH 32
> +static int proc_stack_trace(struct task_struct *task, char *buffer)
> +{
> + int i, len = 0;
> + unsigned long *entries;
> + struct stack_trace trace;
> +
> + entries = kmalloc(sizeof(*entries) * MAX_STACK_TRACE_DEPTH, GFP_KERNEL);
> + if (!entries)
> + goto out;
> +
> + trace.nr_entries = 0;
> + trace.max_entries = MAX_STACK_TRACE_DEPTH;
> + trace.entries = entries;
> + trace.skip = 0;
> +
> + read_lock(&tasklist_lock);
> + save_stack_trace_tsk(task, &trace);
> + read_unlock(&tasklist_lock);
> +
> + for (i = 0; i < trace.nr_entries; i++) {
> + len += sprintf(buffer + len, "[<%p>] %pS\n",
> + (void *) entries[i], (void *) entries[i]);
> + }
> + kfree(entries);
> +out:
> + return len;
> +}
> #endif /* CONFIG_KALLSYMS */
>
> #ifdef CONFIG_SCHEDSTATS
> @@ -2489,6 +2519,7 @@ static const struct pid_entry tgid_base_stuff[] = {
> DIR("attr", S_IRUGO|S_IXUGO, attr_dir),
> #endif
> #ifdef CONFIG_KALLSYMS
> + INF("stack", S_IRUSR, stack_trace),
> INF("wchan", S_IRUGO, pid_wchan),
> #endif
> #ifdef CONFIG_SCHEDSTATS
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists