mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "H. Peter Anvin" <hpa@linux.intel.com>
Cc: Dave Jones <davej@redhat.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@redhat.com>, Andi Kleen <ak@linux.intel.com>
Subject: Re: BUG - function tracing with breakpoints (was: Re: tracing ring_buffer_resize oops.)
Date: Fri, 25 May 2012 11:29:06 -0400	[thread overview]
Message-ID: <1337959746.13348.264.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <1337956262.13348.257.camel@gandalf.stny.rr.com>

On Fri, 2012-05-25 at 10:31 -0400, Steven Rostedt wrote:

> Looks like we set RSP to code. Again pointing to a corrupted iretq.
> Maybe we are having nested debug stack usage, where we are hitting a
> breakpoint before setting the idt to not change the stack?

Another clue. If I do not trace the following functions:

func_ptr_is_kernel_text
kprobe_exceptions_notify
hw_breakpoint_exceptions_notify
notifier_call_chain*

it works fine.

# echo func_ptr_is_kernel_text kprobe_exceptions_notify \
 hw_breakpoint_exceptions_notify notifier_call_chain* > set_ftrace_notrace
# echo function > current_tracer

works!

These notifiers are being called by the breakpoint. So perhaps the
breakpoint is still being called by int3 when it shouldn't be. It
shouldn't because we have:


dotraplinkage void __kprobes notrace do_int3(struct pt_regs *regs, long error_code)
{
#ifdef CONFIG_DYNAMIC_FTRACE
	/* ftrace must be first, everything else may cause a recursive crash */
	if (unlikely(modifying_ftrace_code) && ftrace_int3_handler(regs))
		return;
#endif

The fix I added (but hasn't fixed it completely) was:

 void arch_ftrace_update_code(int command)
 {
        modifying_ftrace_code++;
+       /*
+        * Make sure that all CPUs see this before we start
+        * adding breakpoints.
+        */
+       smp_mb();
 
        ftrace_modify_all_code(command);
 
+       /* Finish all breakpoints before clearing */
+       smp_mb();
+
        modifying_ftrace_code--;
 }


This would make sense for this bug, as if modifying_ftrace_code was not
seen by other CPUs, it wouldn't go into the ftrace_int3_handler() path.
That would cause this issue. But the bug remains after the smp_mb()'s
were put in place. Although it behaves a little differently not. Maybe
there's something else I missed?

-- Steve



  reply	other threads:[~2012-05-25 15:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 16:01 tracing ring_buffer_resize oops Dave Jones
2012-05-24 16:19 ` Steven Rostedt
2012-05-24 17:22   ` Dave Jones
2012-05-24 17:35     ` Steven Rostedt
2012-05-24 18:47       ` Dave Jones
2012-05-24 18:54         ` Steven Rostedt
2012-05-24 19:11           ` Dave Jones
2012-05-24 19:24             ` Steven Rostedt
2012-05-24 20:05               ` Dave Jones
2012-05-24 20:18                 ` Steven Rostedt
2012-05-24 20:33                   ` Steven Rostedt
2012-05-24 21:15                     ` Dave Jones
2012-05-24 21:25                       ` Steven Rostedt
2012-05-24 22:49                 ` Steven Rostedt
2012-05-24 22:57                   ` Dave Jones
2012-05-24 23:40     ` Steven Rostedt
2012-05-24 23:53       ` H. Peter Anvin
2012-05-25  1:32         ` Steven Rostedt
2012-05-25  1:39         ` Steven Rostedt
2012-05-25  1:41           ` Steven Rostedt
2012-05-25 14:31             ` BUG - function tracing with breakpoints (was: Re: tracing ring_buffer_resize oops.) Steven Rostedt
2012-05-25 15:29               ` Steven Rostedt [this message]
2012-05-25 17:40                 ` BUG - function tracing with breakpoints H. Peter Anvin
2012-05-25 18:46                   ` Steven Rostedt
2012-05-25 20:51                     ` Steven Rostedt
2012-05-26  1:36                       ` Steven Rostedt
2012-05-29 11:37                       ` Steven Rostedt
2012-05-29 13:26                         ` Steven Rostedt
2012-05-25  0:14       ` tracing ring_buffer_resize oops Andi Kleen
2012-05-25  1:31         ` Steven Rostedt

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=1337959746.13348.264.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=ak@linux.intel.com \
    --cc=davej@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /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

all inboxes | Powered by JetHome®