From: Steven Rostedt <rostedt@goodmis.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC][PATCH] kprobes: Add separate preempt_disabling for kprobes
Date: Thu, 30 Jun 2011 12:46:27 -0400 [thread overview]
Message-ID: <1309452387.26417.111.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <20110630161439.GA8508@somewhere>
On Thu, 2011-06-30 at 18:14 +0200, Frederic Weisbecker wrote:
> That's a bit sad we need to bloat preempt_schedule() with a new test, especially
> as kprobes should not add overhead in the off case and then I guess many distros
> enable kprobes by default, so it's probably not just enabled on some debug kernel.
A simple per_cpu var test is not that bad, and that's also why I put it
where I did. It only gets checked after all the other locations fail. I
doubt this really adds any measurable overhead. Note, most distro's
don't even enable CONFIG_PREEMPT so this isn't even touched by them.
>
> Another idea could be to turn current_thread_info()->preempt_count into a local_t
> var which ensures a single incrementation is performed in a single instruction.
Not all archs support such a thing.
>
> Well, in the hope that every arch can do something like:
>
> inc (mem_addr)
>
> IIRC, I believe arm can't... And the default local_inc is probably not helpful
> in our case...
Some archs (I believe) perform local_inc() slower than i++. In which
case, this solution will more likely slow things down even more than
what I proposed. As the impact will be on every preempt_disable and
enable.
And this would not even help for the place that I actually hit the crash
on. Which was in the scheduler. It wasn't the addition of the
preempt_count that caused my crash, it was just reading it.
if (unlikely(in_atomic_preempt_off() && !prev->exit_state))
__schedule_bug(prev);
The in_atomic_preempt_off() is what blew up on me.
#define in_atomic_preempt_off() \
((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET)
What happened was that the reading of preempt_count was single stepped.
And that had preempt_count set to one more due to the preempt_disable()
in kprobes. Even if preempt_count was a local_t, this bug would have
still triggered, and my system would have crashed anyway. (every
schedule caused a printk to happen).
-- Steve
next prev parent reply other threads:[~2011-06-30 16:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-30 13:23 [BUG] kprobes crashing because of preempt count Steven Rostedt
2011-06-30 15:51 ` [RFC][PATCH] kprobes: Add separate preempt_disabling for kprobes Steven Rostedt
2011-06-30 16:14 ` Frederic Weisbecker
2011-06-30 16:46 ` Steven Rostedt [this message]
2011-06-30 19:40 ` Jason Baron
2011-06-30 19:42 ` Steven Rostedt
2011-06-30 21:56 ` Peter Zijlstra
2011-07-01 1:22 ` Masami Hiramatsu
2011-07-01 1:38 ` Steven Rostedt
2011-07-01 1:52 ` Masami Hiramatsu
2011-07-01 5:09 ` Masami Hiramatsu
2011-07-01 11:13 ` Masami Hiramatsu
2011-07-01 12:54 ` Steven Rostedt
2011-07-01 12:19 ` Steven Rostedt
2011-07-01 13:15 ` Masami Hiramatsu
2011-07-01 13:14 ` [RFC PATCH -tip ] [BUGFIX] x86: Remove preempt disabling from kprobes Masami Hiramatsu
2011-07-01 13:43 ` Steven Rostedt
2011-07-01 13:53 ` Steven Rostedt
2011-07-03 2:05 ` Masami Hiramatsu
2011-07-02 6:09 ` Ananth N Mavinakayanahalli
2011-07-01 1:12 ` [BUG] kprobes crashing because of preempt count Masami Hiramatsu
2011-07-01 1:33 ` Steven Rostedt
2011-07-01 2:23 ` Masami Hiramatsu
2011-07-01 11:36 ` Ananth N Mavinakayanahalli
2011-07-01 12:01 ` Masami Hiramatsu
2011-07-01 13:03 ` Ananth N Mavinakayanahalli
2011-07-01 13:19 ` 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=1309452387.26417.111.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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®