From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751155AbdAQMGJ (ORCPT ); Tue, 17 Jan 2017 07:06:09 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52726 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbdAQMGF (ORCPT ); Tue, 17 Jan 2017 07:06:05 -0500 Date: Tue, 17 Jan 2017 04:05:13 -0800 From: "Paul E. McKenney" To: Michal Hocko Cc: Peter Zijlstra , 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 Reply-To: paulmck@linux.vnet.ibm.com References: <20170114091255.GA20854@linux.vnet.ibm.com> <1484385201-22227-11-git-send-email-paulmck@linux.vnet.ibm.com> <20170116171130.GC6500@twins.programming.kicks-ass.net> <20170117005403.GW5238@linux.vnet.ibm.com> <20170117105141.GI19699@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170117105141.GI19699@dhcp22.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17011712-0016-0000-0000-000005E34F61 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006449; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000199; SDB=6.00808824; UDB=6.00393956; IPR=6.00586182; BA=6.00005064; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013948; XFM=3.00000011; UTC=2017-01-17 12:05:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17011712-0017-0000-0000-0000368DED68 Message-Id: <20170117120513.GB5238@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-17_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701170167 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanx, Paul