From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"Paul E. McKenney" <paulmck@us.ibm.com>,
Dave Jones <davej@redhat.com>, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH][RFC] tracing/context-tracking: Add preempt_schedule_context() for tracing
Date: Fri, 31 May 2013 17:56:44 +0200 [thread overview]
Message-ID: <20130531155643.GL5932@somewhere> (raw)
In-Reply-To: <1370013528.26799.49.camel@gandalf.local.home>
On Fri, May 31, 2013 at 11:18:48AM -0400, Steven Rostedt wrote:
> On Fri, 2013-05-31 at 15:43 +0200, Frederic Weisbecker wrote:
>
> > > +void __sched notrace preempt_schedule_context(void)
> > > +{
> > > + struct thread_info *ti = current_thread_info();
> > > + enum ctx_state prev_ctx;
> > > +
> > > + if (likely(ti->preempt_count || irqs_disabled()))
> > > + return;
> > > +
> > > + /*
> > > + * Need to disable preemption in case user_exit() is traced
> > > + * and the tracer calls preempt_enable_notrace() causing
> > > + * an infinite recursion.
> > > + */
> > > + preempt_disable_notrace();
> > > + prev_ctx = this_cpu_read(context_tracking.state);
> > > + user_exit();
> >
> > You can reuse exception_enter()
>
> I originally did use that, but then noticed that everything else in
> context_tracking.c used context_tracking.state directly. I have no
> problems doing it this way again.
It's more about the fact that exception_*() APIs already implement
part of what you're doing. And yeah as a bonus it's also better to keep
context_tracking internals in context_tracking.c
>
> >
> > > + preempt_enable_no_resched_notrace();
> > > +
> > > + preempt_schedule();
> > > +
> > > + preempt_disable_notrace();
> > > + if (prev_ctx == IN_USER)
> > > + user_enter();
> >
> > And then exception_exit() here.
> >
> > I guess this replaces your fix with schedule_preempt_user(). I liked
> > it because it seems that:
> >
> > if (need_resched()) {
> > user_exit();
> > local_irq_enable();
> > schedule();
> > local_irq_enable();
> > user_enter();
> > }
> >
> > is a common pattern of arch user resume preemption that we can consolidate.
> >
> > But your new patch probably makes it more widely safe for the function tracer
> > for any function that can be called and traced in IN_USER mode. Not only user preemption.
> > Think about do_notify_resume() for example if it is called after syscall_trace_leave().
> >
> > Independantly, schedule_preempt_user() is still interesting for consolidation.
>
> And I think that patch is still valid from just a clean up point of
> view. It just didn't cover all the cases needed for tracing.
Right.
Thanks.
next prev parent reply other threads:[~2013-05-31 15:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 19:59 [PATCH][RFC] tracing/context-tracking: Add preempt_schedule_context() for tracing Steven Rostedt
2013-05-31 13:43 ` Frederic Weisbecker
2013-05-31 15:18 ` Steven Rostedt
2013-05-31 15:56 ` Frederic Weisbecker [this message]
2013-05-31 16:01 ` Peter Zijlstra
2013-05-31 16:11 ` Steven Rostedt
2013-06-01 1:30 ` [PATCH v2][RFC] " Steven Rostedt
2013-06-04 12:09 ` Frederic Weisbecker
2013-06-04 12:16 ` Steven Rostedt
2013-06-04 12:29 ` Frederic Weisbecker
2013-06-04 12:27 ` Frederic Weisbecker
2013-06-04 14:16 ` Steven Rostedt
2013-06-05 11:45 ` Peter Zijlstra
2013-06-05 13:41 ` Steven Rostedt
2013-06-06 2:49 ` Steven Rostedt
2013-06-06 10:07 ` Peter Zijlstra
2013-06-06 13:50 ` 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=20130531155643.GL5932@somewhere \
--to=fweisbec@gmail.com \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@us.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/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