From: Ingo Molnar <mingo@elte.hu>
To: "Török Edwin" <edwintorok@gmail.com>
Cc: srostedt@redhat.com, a.p.zijlstra@chello.nl,
sandmann@daimi.au.dk, linux-kernel@vger.kernel.org,
viro@ZenIV.linux.org.uk
Subject: Re: [PATCH 1/2] tracing: add support for userspace stacktraces in tracing/iter_ctrl
Date: Sun, 23 Nov 2008 09:37:40 +0100 [thread overview]
Message-ID: <20081123083740.GD30453@elte.hu> (raw)
In-Reply-To: <1227353328-16104-2-git-send-email-edwintorok@gmail.com>
* Török Edwin <edwintorok@gmail.com> wrote:
> +struct stack_frame {
> + const void __user *next_fp;
> + unsigned long return_address;
> +};
Small detail: please s/return_address/ret_addr - its expressive power
is the same but as a bonus it will cause less col-80 related
linebreaks in usage sites.
> +void save_stack_trace_user(struct stack_trace *trace)
> +{
> + /*
> + * Trace user stack if we are not a kernel thread
> + */
> + if (current->mm) {
> + const struct pt_regs *regs = task_pt_regs(current);
> + const void __user *fp = (const void __user *)regs->bp;
> +
> + if (trace->nr_entries < trace->max_entries)
> + trace->entries[trace->nr_entries++] = regs->ip;
> +
> + while (trace->nr_entries < trace->max_entries) {
> + struct stack_frame frame;
> + frame.next_fp = NULL;
Style: put a newline after variable definitions please.
> + frame.return_address = 0;
> + if (!copy_stack_frame(fp, &frame))
> + break;
> + if ((unsigned long)fp < regs->sp)
> + break;
> + if (frame.return_address)
> + trace->entries[trace->nr_entries++] =
> + frame.return_address;
Style: please use curly braces around multi-line conditional
statements.
> + if (fp == frame.next_fp)
> + break;
> + fp = frame.next_fp;
> + }
> + }
Detail: please move the whole "if (current->mm)" into a
__save_stack_trace_user() helper function - that way it reads cleaner.
> +++ b/include/linux/stacktrace.h
> @@ -18,9 +18,17 @@ extern void save_stack_trace_tsk(struct task_struct *tsk,
> struct stack_trace *trace);
>
> extern void print_stack_trace(struct stack_trace *trace, int spaces);
> +
> +#ifdef CONFIG_X86
> +extern void save_stack_trace_user(struct stack_trace *trace);
> +#else
> +# define save_stack_trace_user(trace) do { } while (0)
> +#endif
Bug: this should not be CONFIG_X86. Please introduce (in a separate
patch from other cleanups) a CONFIG_USER_STACKTRACE_SUPPORT in
arch/x86/Kconfig and use that instead.
> +
> #else
> # define save_stack_trace(trace) do { } while (0)
> # define save_stack_trace_tsk(tsk, trace) do { } while (0)
> +# define save_stack_trace_user(trace) do { } while (0)
Style: these should be tabs, not spaces ^^^^^^^^^^^^
> +static void ftrace_trace_userstack(struct trace_array *tr,
> + struct trace_array_cpu *data,
> + unsigned long flags, int pc)
> +{
> + struct userstack_entry *entry;
> + struct stack_trace trace;
> + struct ring_buffer_event *event;
> + unsigned long irq_flags;
Detail: please use the customary ftrace variable definitions style:
> + struct ring_buffer_event *event;
> + struct userstack_entry *entry;
> + struct stack_trace trace;
> + unsigned long irq_flags;
note how it's ordered by line length.
> +static int
> +seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
> + unsigned long sym_flags)
> +{
> + int ret = 1;
> + unsigned i;
Detail: please use "unsigned int" so that we have less type patterns
to look for.
> +
> + for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
> + unsigned long ip = entry->caller[i];
> +
> + if (ip == ULONG_MAX || !ret)
> + break;
> + if (i)
> + ret = trace_seq_puts(s, " <- ");
> + if (!ip) {
> + ret = trace_seq_puts(s, "??");
> + continue;
> + }
> + if (ret /*&& (sym_flags & TRACE_ITER_SYM_ADDR)*/)
> + ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
Detail: do we need that commented-out condition?
Ingo
next prev parent reply other threads:[~2008-11-23 8:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-22 11:28 [PATCH 0/2] tracing: userspace stacktraces Török Edwin
2008-11-22 11:28 ` [PATCH 1/2] tracing: add support for userspace stacktraces in tracing/iter_ctrl Török Edwin
2008-11-23 8:37 ` Ingo Molnar [this message]
2008-11-23 10:39 ` [PATCH 3/3] tracing/stack-tracer: introduce CONFIG_USER_STACKTRACE_SUPPORT Török Edwin
2008-11-22 11:28 ` [PATCH 2/2] tracing: identify which executable object the userspace address belongs to Török Edwin
2008-11-23 8:47 ` [PATCH] vfs, seqfile: make mangle_path() global Ingo Molnar
2008-11-23 21:06 ` Randy Dunlap
2008-11-23 21:24 ` [PATCH] fix comment style on mangle_path Török Edwin
2008-11-23 21:36 ` Ingo Molnar
2008-11-28 10:05 ` [PATCH] vfs, seqfile: make mangle_path() global Al Viro
2008-11-28 17:08 ` Ingo Molnar
2008-11-23 8:53 ` [PATCH 2/2] tracing: identify which executable object the userspace address belongs to Ingo Molnar
2008-11-23 10:39 ` [PATCH 1/3] tracing/stack-tracer: fix style issues Török Edwin
2008-11-23 10:39 ` [PATCH 2/3] tracing/stack-tracer: fix locking Török Edwin
2008-11-23 10:52 ` Ingo Molnar
2008-11-23 10:59 ` Török Edwin
2008-11-23 11:01 ` Ingo Molnar
2008-11-23 11:04 ` Török Edwin
2008-11-23 11:07 ` Ingo Molnar
2008-11-23 11:08 ` [PATCH] tracing/stack-tracer: avoid races accessing file Török Edwin
2008-11-23 11:20 ` Ingo Molnar
2008-11-25 14:40 ` [PATCH 2/2] tracing: identify which executable object the userspace address belongs to Frank Ch. Eigler
2008-11-26 9:59 ` Török Edwin
2008-11-27 10:41 ` Peter Zijlstra
2008-11-27 12:48 ` Frank Ch. Eigler
2008-11-27 13:02 ` Peter Zijlstra
2008-11-27 13:03 ` Török Edwin
2008-11-27 14:10 ` Ingo Molnar
2008-11-27 14:27 ` Török Edwin
2008-11-27 14:51 ` Ingo Molnar
2008-12-09 19:49 ` Török Edwin
2008-11-23 8:26 ` [PATCH 0/2] tracing: userspace stacktraces Ingo Molnar
2008-11-23 9:24 ` Török Edwin
2008-11-23 9:30 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081123083740.GD30453@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=edwintorok@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sandmann@daimi.au.dk \
--cc=srostedt@redhat.com \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox