public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H . Peter Anvin" <hpa@zytor.com>
Subject: Re: [RFC PATCH tip/master] kprobes: Use synchronize_rcu_tasks() for optprobe wit CONFIG_PREEMPT
Date: Thu, 25 May 2017 18:04:30 +0900	[thread overview]
Message-ID: <20170525180430.ab38cbb7d53cf7bc9b4de065@kernel.org> (raw)
In-Reply-To: <20170525061555.m2ihe2dvjyedyzwn@gmail.com>

On Thu, 25 May 2017 08:15:55 +0200
Ingo Molnar <mingo@kernel.org> wrote:

> 
> * Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -377,6 +377,23 @@ static inline void copy_kprobe(struct kprobe *ap, struct kprobe *p)
> >  static bool kprobes_allow_optimization;
> >  
> >  /*
> > + * Synchronizing wait on trampline code for interrupted tasks/threads.
> > + * Since the threads running on dynamically allocated trampline code
> > + * can be interrupted, kprobes has to wait for those tasks back on
> > + * track and scheduled. If the kernel is preemptive, the thread can be
> > + * preempted by other tasks on the trampoline too. For such case, this
> > + * calls synchronize_rcu_tasks() to wait for those tasks back on track.
> > + */
> > +static void synchronize_on_trampoline(void)
> > +{
> > +#ifdef CONFIG_PREEMPT
> > +	synchronize_rcu_tasks();
> > +#else
> > +	synchronize_sched();
> > +#endif
> > +}
> 
> So that's really unacceptably ugly.
> 
> Paul, I still question the need to have tasks-RCU as a Kconfig distinction, 
> _especially_ if its API usage results in such ugly secondary #ifdefs...
> 
> Why isn't there a single synchronize_rcu_tasks() API function, which does what is 
> expected, where the _RCU_ code figures out how to implement it?

Hmm, if there are only 3 users, kprobes/ftrace/kpatch, and those
use it same purpose (wait for tasks which preempted or interrupted),
maybe we can switch the implementation of synchronize_rcu_tasks()
in RCU level.

> 
> I.e.:
> 
>  - There should be no user configurable TASKS_RCU Kconfig setting - at most a
>    helper Kconfig that is automatically selected by the RCU code itself.

TASKS_RCU kconfig is already a hidden setting. It is selected if
CONFIG_PREEMPT=y && CONFIG_KPROBES=y && HAVE_OPTPROBES=y for kprobes.

Thank you,

> 
>  - Both ftrace andkprobes would use a simple synchronize_rcu_tasks() call.


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2017-05-25  9:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24 12:00 [RFC PATCH tip/master] kprobes: Use synchronize_rcu_tasks() for optprobe wit CONFIG_PREEMPT Masami Hiramatsu
2017-05-24 14:47 ` Paul E. McKenney
2017-05-25  6:15 ` Ingo Molnar
2017-05-25  9:04   ` Masami Hiramatsu [this message]
2017-05-25 15:14   ` Paul E. McKenney
2017-05-26  1:16     ` Masami Hiramatsu
2017-05-26  6:10     ` Ingo Molnar
2017-05-26 15:43       ` Paul E. McKenney

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=20170525180430.ab38cbb7d53cf7bc9b4de065@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --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