linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: Joel Fernandes <joel@joelfernandes.org>,
	linux-kernel@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	Josh Triplett <josh@joshtriplett.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	linux-doc@vger.kernel.org,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH RFC] doc: rcu: remove obsolete (non-)requirement about disabling preemption
Date: Mon, 15 Oct 2018 04:21:12 -0700	[thread overview]
Message-ID: <20181015112112.GT2674@linux.ibm.com> (raw)
In-Reply-To: <5151da01-343b-bb37-353e-b6652ae530f5@suse.com>

On Mon, Oct 15, 2018 at 09:05:22AM +0300, Nikolay Borisov wrote:
> On 15.10.2018 05:47, Joel Fernandes wrote:
> > On Sun, Oct 14, 2018 at 07:33:28PM -0700, Paul E. McKenney wrote:
> >> On Sun, Oct 14, 2018 at 07:13:49PM -0700, Joel Fernandes wrote:
> >>> On Sun, Oct 14, 2018 at 07:08:27PM -0700, Joel Fernandes wrote:
> >>>> On Sun, Oct 14, 2018 at 04:17:31PM -0700, Paul E. McKenney wrote:
> >>>>> On Sun, Oct 14, 2018 at 02:29:55PM -0700, Joel Fernandes (Google) wrote:
> >>>>>> The Requirements.html document says "Disabling Preemption Does Not Block
> >>>>>> Grace Periods". However this is no longer true with the RCU
> >>>>>> consolidation. Lets remove the obsolete (non-)requirement entirely.
> >>>>>>
> >>>>>> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> >>>>>
> >>>>> Good catch, queued, thank you!
> >>>>
> >>>> Thanks! By the way after I sent the patch, I also tried Oleg's experiment to
> >>>> confirm that this is indeed obsolete.  :)
> >>>>
> >>>> One thing interesting came up when I tried synchronize_rcu_expedited()
> >>>> instead of synchronize_rcu() in Oleg's experiment, I still saw a multiple
> >>>> millisecond delay between when the rcu read section completely and the
> >>>> synchronize_rcu_expedited returns:
> >>>>
> >>>> For example, with synchronize_rcu_expedited, the 'SPIN done' and the 'SYNC
> >>>> done' are about 3 millisecond apart:
> >>>> [   77.599142] SPIN start
> >>>> [   77.601595] SYNC start
> >>>> [   82.604950] SPIN done!
> >>>> [   82.607836] SYNC done!
> >>>>  I saw anywhere from 2-6 milliseconds.
> >>>>
> >>>> The reason I bring this up is according to Requirements.html: In some cases,
> >>>> the multi-millisecond synchronize_rcu() latencies are unacceptable. In these
> >>>> cases, synchronize_rcu_expedited() may be used instead,.. so either I messed
> >>>> something up in the experiment, or I need to update this part of the document ;-)
> >>
> >> In normal testing, 2-6 milliseconds is indeed excessive.  Could you please
> >> point me at Oleg's experiment?  Also, what CONFIG_PREEMPT setting were
> >> you using?  (My guess is CONFIG_PREEMPT=y.)
> > 
> > The CONFIG_PREEMPT config I am using is CONFIG_PREEMPT=y.
> > 
> >>> So I realized I'm running in Qemu so it could also be a scheduling delay of
> >>> the vcpu thread. So apologies about the noise if the experiment works fine
> >>> for you.
> >>
> >> I used rcuperf, which might not be doing the same thing as Oleg's
> >> experiment.
> > 
> > The experiment is mentioned at:
> > https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg912055.html
> > 
> > If you apply the below diff, it applies cleanly on rcu/dev. And then run:
> > taskset 2 perl -e 'syscall 157, 666, 5000' &
> > taskset 1 perl -e 'syscall 157, 777'
> > 
> > diff --git a/kernel/sys.c b/kernel/sys.c
> > index cf5c67533ff1..b654b7566ca3 100644
> > --- a/kernel/sys.c
> > +++ b/kernel/sys.c
> > @@ -2261,6 +2261,9 @@ int __weak arch_prctl_spec_ctrl_set(struct task_struct *t, unsigned long which,
> >  	return -EINVAL;
> >  }
> >  
> > +#include <linux/delay.h>
> > +
> > +
> >  SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
> >  		unsigned long, arg4, unsigned long, arg5)
> >  {
> > @@ -2274,6 +2277,19 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
> >  
> >  	error = 0;
> >  	switch (option) {
> > +	case 666:
> > +		preempt_disable();
> > +		pr_crit("SPIN start\n");
> > +		while (arg2--)
> > +			mdelay(1);

OK, this is the problem.  When you spin in the kernel for several
milliseconds with preemption disabled, the consolidated grace period
is -required- to wait for this preemption-disabled reader to complete,
whether expedited or not.

So, expected behavior.  ;-)

In any case, please don't spin for milliseconds with preemption disabled.
The real-time guys are unlikely to be happy with you if you do this!

> > +		pr_crit("SPIN done!\n");
> > +		preempt_enable();
> > +		break;
> > +	case 777:
> > +		pr_crit("SYNC start\n");
> > +		synchronize_rcu();
> > +		pr_crit("SYNC done!\n");
> 
> But you are using the console printing infrastructure which is rather
> heavyweight. Try replacing pr_* calls with trace_printk so that you
> write to the lock-free ring buffer, this will reduce the noise from the
> heavy console printing infrastructure.

And this might be a problem as well.

							Thanx, Paul

> > +		break;
> >  	case PR_SET_PDEATHSIG:
> >  		if (!valid_signal(arg2)) {
> >  			error = -EINVAL;
> > 
> 


  reply	other threads:[~2018-10-15 11:21 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-14 21:29 [PATCH RFC] doc: rcu: remove obsolete (non-)requirement about disabling preemption Joel Fernandes (Google)
2018-10-14 23:17 ` Paul E. McKenney
2018-10-15  2:08   ` Joel Fernandes
2018-10-15  2:13     ` Joel Fernandes
2018-10-15  2:33       ` Paul E. McKenney
2018-10-15  2:47         ` Joel Fernandes
2018-10-15  2:50           ` Joel Fernandes
2018-10-15  6:05           ` Nikolay Borisov
2018-10-15 11:21             ` Paul E. McKenney [this message]
2018-10-15 19:39               ` Joel Fernandes
2018-10-15 19:54                 ` Paul E. McKenney
2018-10-15 20:15                   ` Joel Fernandes
2018-10-15 21:08                     ` Paul E. McKenney
2018-10-16 11:26                       ` Paul E. McKenney
2018-10-16 20:41                         ` Joel Fernandes
2018-10-17 16:11                           ` Paul E. McKenney
2018-10-17 18:15                             ` Joel Fernandes
2018-10-17 20:33                               ` Paul E. McKenney
2018-10-18  2:07                                 ` Joel Fernandes
2018-10-18 14:46                                   ` Paul E. McKenney
2018-10-19  0:03                                     ` Joel Fernandes
2018-10-19  0:19                                       ` Paul E. McKenney
2018-10-19  1:12                                         ` Steven Rostedt
2018-10-19  1:27                                           ` Joel Fernandes
2018-10-19  1:26                                         ` Joel Fernandes
2018-10-19  1:50                                           ` Steven Rostedt
2018-10-19  2:25                                             ` Joel Fernandes
2018-10-19  2:52                                               ` Steven Rostedt
2018-10-19  3:58                                                 ` Joel Fernandes
2018-10-19 12:07                                                   ` Paul E. McKenney
2018-10-19 17:24                                                     ` Joel Fernandes
2018-10-19 18:11                                                       ` 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=20181015112112.GT2674@linux.ibm.com \
    --to=paulmck@linux.ibm.com \
    --cc=corbet@lwn.net \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=nborisov@suse.com \
    --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;
as well as URLs for NNTP newsgroup(s).