From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, mingo@kernel.org,
jiangshanlai@gmail.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, tglx@linutronix.de, rostedt@goodmis.org,
dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com,
fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com
Subject: Re: [PATCH tip/core/rcu 11/20] sched,rcu: Make cond_resched() provide RCU quiescent state
Date: Tue, 17 Jan 2017 18:10:06 -0800 [thread overview]
Message-ID: <20170118021006.GK5238@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170117121146.GK19699@dhcp22.suse.cz>
On Tue, Jan 17, 2017 at 01:11:46PM +0100, Michal Hocko wrote:
> On Tue 17-01-17 04:05:13, Paul E. McKenney wrote:
> > On Tue, Jan 17, 2017 at 11:51:41AM +0100, Michal Hocko wrote:
> > > On Mon 16-01-17 16:54:03, Paul E. McKenney wrote:
> > > > On Mon, Jan 16, 2017 at 06:11:30PM +0100, Peter Zijlstra wrote:
> > > > > On Sat, Jan 14, 2017 at 01:13:12AM -0800, Paul E. McKenney wrote:
> > > > > > There is some confusion as to which of cond_resched() or
> > > > > > cond_resched_rcu_qs() should be added to long in-kernel loops.
> > > > > > This commit therefore eliminates the decision by adding RCU
> > > > > > quiescent states to cond_resched().
> > > > >
> > > > > Which would make: rcu_read_lock(); cond_resched(); rcu_read_unlock();
> > > > > invalid under preemptible RCU. Is it already?
> > > >
> > > > In theory, yes. In practice, I just tested it with preemption and
> > > > lockdep enabled, and it didn't complain. If further testing finds
> > > > complaints, we can either fix those uses (preferred) or revert
> > > > this patch.
> > > >
> > > > > > Warning: This is a prototype. For example, it does not correctly
> > > > > > handle Tasks RCU. Which is OK for the moment, given that no one
> > > > > > actually uses Tasks RCU yet.
> > > > >
> > > > > > --- a/kernel/sched/core.c
> > > > > > +++ b/kernel/sched/core.c
> > > > > > @@ -4907,6 +4907,7 @@ int __sched _cond_resched(void)
> > > > > > preempt_schedule_common();
> > > > > > return 1;
> > > > > > }
> > > > > > + rcu_all_qs();
> > > > > > return 0;
> > > > > > }
> > > > >
> > > > > Still not a real fan of this, it does make cond_resched() touch a bunch
> > > > > more cachelines, also, I suppose that if we're going to do this, we
> > > > > should make __cond_resched_lock() and __cond_resched_softirq() act
> > > > > similarly.
> > > >
> > > > Michal (now CCed) argues that having to distinguish between cond_resched()
> > > > and cond_resched_rcu_qs() is overly burdensome. Michal?
> > >
> > > Yes, it is really not clear which one is meant to be in which context. I
> > > really do not see which cond_resched should be turned intto
> > > cond_resched_rcu_qs.
> > >
> > > > Any thoughts on how we might remove this burden without the additional
> > > > cache misses? I will take another look as well to see what could make
> > > > it lower cost. There are probably ways... Would it make sense to
> > > > have RCU maintain a need-rcu_all_qs() flage in the same cacheline as
> > > > the __preempt_count? Perhaps throttling the writes to this flag from
> > > > the RCU grace-period kthreads to once per 100 milliseconds or so?
> > >
> > > Can the stall detector simply request rescheduling when it gets
> > > dangerously close to the timeout?
> >
> > It is quite possible that half of the stall timeout would be a better
> > choice than my 100 milliseconds, but either way, there would be need
> > for a flag or some such.
>
> E.g. set_tsk_need_resched() on the task currently running on a cpu which
> is preventing the rcu grace period for too long?
>
> That would only require change to the stall detector and the cond_resched
> could be left alone completely.
Thank you!!!
The other complication is that under CONFIG_PREEMPT=y, _cond_resched()
is an empty function. That would be one reason why use of cond_resched()
wasn't always giving RCU the quiescent states that it needs. And that
is a problem with this patch, which I therefore need to defer to 4.12.
That aside, the reason I am reluctant to use the need-resched approach
except as an emergency measure is that the way I have to set that bit
remotely involves IPIs.
But don't get me wrong, it is extremely useful as an emergency meaure.
I am just trying to get cond_resched() to help on a non-emergency basis.
Thanx, Paul
next prev parent reply other threads:[~2017-01-18 7:18 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-14 9:12 [PATCH tip/core/rcu 0/20] Miscellaneous fixes for 4.11 Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 01/20] rcu: update: Make RCU_EXPEDITE_BOOT be the default Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 02/20] lockdep: Make RCU suspicious-access splats use pr_err Paul E. McKenney
2017-01-16 7:53 ` Josh Triplett
2017-01-17 1:06 ` Paul E. McKenney
2017-01-16 17:21 ` Peter Zijlstra
2017-01-16 20:59 ` Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 03/20] Fix: Disable sys_membarrier when nohz_full is enabled Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 04/20] rcu: Only dump stalled-tasks stacks if there was a real stall Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 05/20] rcu: Remove unneeded rcu_process_callbacks() declarations Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 06/20] rcu: Remove unused but set variable Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 07/20] rcu: Remove short-term CPU kicking Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 08/20] rcu: Add long-term " Paul E. McKenney
2017-01-16 7:58 ` Josh Triplett
2017-01-17 1:07 ` Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 09/20] rcu: Once again use NMI-based stack traces in stall warnings Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 10/20] rcu: Add functions to test for trivial grace periods Paul E. McKenney
2017-01-16 8:01 ` Josh Triplett
2017-01-17 0:32 ` Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 11/20] sched,rcu: Make cond_resched() provide RCU quiescent state Paul E. McKenney
2017-01-16 8:08 ` Josh Triplett
2017-01-16 11:38 ` Paul E. McKenney
2017-01-16 17:11 ` Peter Zijlstra
2017-01-17 0:54 ` Paul E. McKenney
2017-01-17 10:51 ` Michal Hocko
2017-01-17 12:05 ` Paul E. McKenney
2017-01-17 12:11 ` Michal Hocko
2017-01-18 2:10 ` Paul E. McKenney [this message]
2017-01-14 9:13 ` [PATCH tip/core/rcu 12/20] rcu: Re-enable TASKS_RCU for User Mode Linux Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 13/20] rcu: Don't wake rcuc/X kthreads on NOCB CPUs Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 14/20] rcu: Add comment headers to expedited-grace-period counter functions Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 15/20] rcu: Make rcu_cpu_starting() use its "cpu" argument Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 16/20] rcu: Enable RCU tracepoints by default to aid in debugging Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 17/20] rcu: Fix comment in rcu_organize_nocb_kthreads() Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 18/20] llist: Clarify comments about when locking is needed Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 19/20] rcu: Eliminate unused expedited_normal counter Paul E. McKenney
2017-01-14 9:13 ` [PATCH tip/core/rcu 20/20] rcu: Add lockdep checks to synchronous expedited primitives Paul E. McKenney
2017-01-16 8:09 ` [PATCH tip/core/rcu 0/20] Miscellaneous fixes for 4.11 Josh Triplett
2017-01-17 1:07 ` Paul E. McKenney
2017-01-18 2:53 ` Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 01/18] rcu: update: Make RCU_EXPEDITE_BOOT be the default Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 02/18] lockdep: Make RCU suspicious-access splats use pr_err Paul E. McKenney
2017-01-21 20:40 ` Josh Triplett
2017-01-23 19:30 ` Paul E. McKenney
2017-01-23 22:33 ` Josh Triplett
2017-01-24 0:13 ` Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 03/18] Fix: Disable sys_membarrier when nohz_full is enabled Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 04/18] rcu: Only dump stalled-tasks stacks if there was a real stall Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 05/18] rcu: Remove unneeded rcu_process_callbacks() declarations Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 06/18] rcu: Remove unused but set variable Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 07/18] rcu: Add long-term CPU kicking Paul E. McKenney
2017-01-21 20:41 ` Josh Triplett
2017-01-21 20:42 ` Josh Triplett
2017-01-23 19:34 ` Paul E. McKenney
2017-01-23 20:25 ` Josh Triplett
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 08/18] rcu: Remove short-term " Paul E. McKenney
2017-01-21 20:43 ` Josh Triplett
2017-01-23 19:36 ` Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 09/18] rcu: Once again use NMI-based stack traces in stall warnings Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 10/18] rcu: Re-enable TASKS_RCU for User Mode Linux Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 11/18] rcu: Don't wake rcuc/X kthreads on NOCB CPUs Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 12/18] rcu: Add comment headers to expedited-grace-period counter functions Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 13/18] rcu: Make rcu_cpu_starting() use its "cpu" argument Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 14/18] rcu: Enable RCU tracepoints by default to aid in debugging Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 15/18] rcu: Fix comment in rcu_organize_nocb_kthreads() Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 16/18] llist: Clarify comments about when locking is needed Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 17/18] rcu: Eliminate unused expedited_normal counter Paul E. McKenney
2017-01-18 2:53 ` [PATCH v2 tip/core/rcu 18/18] rcu: Add lockdep checks to synchronous expedited primitives Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 0/18] Miscellaneous fixes for 4.11 Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 01/18] rcu: update: Make RCU_EXPEDITE_BOOT be the default Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 02/18] lockdep: Make RCU suspicious-access splats use pr_err Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 03/18] Fix: Disable sys_membarrier when nohz_full is enabled Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 04/18] rcu: Only dump stalled-tasks stacks if there was a real stall Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 05/18] rcu: Remove unneeded rcu_process_callbacks() declarations Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 06/18] rcu: Remove unused but set variable Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 07/18] rcu: Add long-term CPU kicking Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 08/18] rcu: Remove short-term " Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 09/18] rcu: Once again use NMI-based stack traces in stall warnings Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 10/18] rcu: Re-enable TASKS_RCU for User Mode Linux Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 11/18] rcu: Don't wake rcuc/X kthreads on NOCB CPUs Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 12/18] rcu: Add comment headers to expedited-grace-period counter functions Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 13/18] rcu: Make rcu_cpu_starting() use its "cpu" argument Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 14/18] rcu: Enable RCU tracepoints by default to aid in debugging Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 15/18] rcu: Fix comment in rcu_organize_nocb_kthreads() Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 16/18] llist: Clarify comments about when locking is needed Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 17/18] rcu: Eliminate unused expedited_normal counter Paul E. McKenney
2017-01-24 21:51 ` [PATCH v3 tip/core/rcu 18/18] rcu: Add lockdep checks to synchronous expedited primitives 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=20170118021006.GK5238@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bobby.prani@gmail.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=dvhart@linux.intel.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhocko@kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.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;
as well as URLs for NNTP newsgroup(s).