Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1322921

Re: [PATCH] s390:ftrace: add save_stack_trace_regs()

From Heiko Carstens <heiko.carstens@de.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH] s390:ftrace: add save_stack_trace_regs()
Date 2016-02-01 10:10 +0100
Message-ID <qXiEG-pe-13@gated-at.bofh.it> (permalink)
References <qW9N8-6pA-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jan 29, 2016 at 10:50:28AM +0530, Pratyush Anand wrote:
> Implement save_stack_trace_regs, so that stacktrace of a kprobe events can
> be obtained.
> 
> Without this we see following warning:
> "save_stack_trace_regs() not implemented yet."
> when we execute:
> echo stacktrace > /sys/kernel/debug/tracing/trace_options
> echo "p kfree" >> /sys/kernel/debug/tracing/kprobe_events
> echo 1 > /sys/kernel/debug/tracing/events/kprobes/enable
> 
> Reported-by: Chunyu Hu <chuhu@redhat.com>
> Signed-off-by: Pratyush Anand <panand@redhat.com>
> ---
>  arch/s390/kernel/stacktrace.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
> index 1785cd82253c..586da400f931 100644
> --- a/arch/s390/kernel/stacktrace.c
> +++ b/arch/s390/kernel/stacktrace.c
> @@ -94,3 +94,16 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
>  		trace->entries[trace->nr_entries++] = ULONG_MAX;
>  }
>  EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
> +
> +void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
> +{
> +	unsigned long sp, low, high;
> +
> +	sp = kernel_stack_pointer(regs);
> +	low = (unsigned long) task_stack_page(current);
> +	high = (unsigned long) task_pt_regs(current);
> +	save_context_stack(trace, sp, low, high, 0);
> +	if (trace->nr_entries < trace->max_entries)
> +		trace->entries[trace->nr_entries++] = ULONG_MAX;
> +}
> +EXPORT_SYMBOL_GPL(save_stack_trace_regs);

While playing around with this, I discovered a couple of bugs in our
stacktrace code. However this patch is also not correct, since it will save
a stacktrace only if being called in process context, but not for interrupt
context.
I will fix this within this patch.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] s390:ftrace: add save_stack_trace_regs() Pratyush Anand <panand@redhat.com> - 2016-01-29 06:30 +0100
  Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-01-29 10:00 +0100
    Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-01-29 14:00 +0100
      Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Steven Rostedt <rostedt@goodmis.org> - 2016-01-29 15:00 +0100
        Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-01-29 15:50 +0100
          Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Steven Rostedt <rostedt@goodmis.org> - 2016-01-29 16:30 +0100
            Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-01-29 17:50 +0100
              Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Steven Rostedt <rostedt@goodmis.org> - 2016-01-29 18:00 +0100
                Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-01-29 18:20 +0100
  Re: [PATCH] s390:ftrace: add save_stack_trace_regs() Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-02-01 10:10 +0100

csiph-web