Received: by 10.223.185.116 with SMTP id b49csp4265342wrg; Tue, 6 Mar 2018 12:39:59 -0800 (PST) X-Google-Smtp-Source: AG47ELt5CaQTG7YvD+O+6TkSWi8icnchFMBbv1a67PuDBfUIyYxiFQcLjSVn2dpji8/Dlvc8w2DT X-Received: by 10.98.198.146 with SMTP id x18mr20055965pfk.22.1520368799648; Tue, 06 Mar 2018 12:39:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520368799; cv=none; d=google.com; s=arc-20160816; b=dbv1ia3EvtquhXGZ5BxrccrHWTaob6iqI3dkvY7CuF7VVPitRikinU8/2hoJyPVHQw fYhYtDSUjw1XFBpjswz6vXXYRO9KOsycEigvleUEjKuSeynVe5KXY/BpOLD00v3B1PGd GcCiN5xGtU+AxgcmvcMIWMqJ4/y85fx4ePhyRz8oe2JWDNnI9Gv6Clal/1kQ3L9J70k2 9CES7lOSHtQXqG2rioY0P1Mclenz2b9XJgEE9P4HH8CvGw7aUNtyN4Wk/u4zRdOapqtM P5O+Ux+tCBQBMw2S0fJWQVnAakQySLpwUJ0tacRLEa9XKkLj0YxOrVUcMWBSbr+vsgZ/ LpOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=c1OgGiaVRQYU0i2RJJtWrbo5/MsAXCe4AD7ClZHEiqI=; b=TiYVTN3HNEdfKAuoYv54hqkTrdNxP9FAnB+ItFBJXYTQgwG7qB693mLu3UvRkmCWZr xJTMhmiMAn3FHW2OzE0TXDrOjouqsTl+hdsu8VeTYz5LJBiwgL6MT8bt8iKmGP58X2Oe dC8nCJTAc5sTBEymghsnPMqGFkpRxms0AwQbk3s5sksEeq+Uw/v0d/eDt/dRpHi98fWs eK2qskMtUos4i4cO8k0tKsyqHj/miGlQ1SIpFmbgHKbTkcMPkQxKIzCDHS0F+pIE5m9d 3LKw4+/GQx+/hcOVSfxC/mG1ySQv6URKIWaKbSjFXUJxxoSWWx5dkOaE50e1YVwcXomB gG3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7si9165589pgp.799.2018.03.06.12.39.44; Tue, 06 Mar 2018 12:39:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbeCFUit (ORCPT + 99 others); Tue, 6 Mar 2018 15:38:49 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41100 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753504AbeCFUir (ORCPT ); Tue, 6 Mar 2018 15:38:47 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w26KclPR107722 for ; Tue, 6 Mar 2018 15:38:47 -0500 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gj0afmeyf-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 06 Mar 2018 15:38:46 -0500 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Mar 2018 15:38:37 -0500 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Mar 2018 15:38:33 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w26KcWI537617836; Tue, 6 Mar 2018 20:38:32 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14900B204D; Tue, 6 Mar 2018 16:40:48 -0500 (EST) Received: from paulmck-ThinkPad-W541 (unknown [9.85.135.94]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id BE09CB2046; Tue, 6 Mar 2018 16:40:47 -0500 (EST) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id D0AFB16C255D; Tue, 6 Mar 2018 12:39:06 -0800 (PST) Date: Tue, 6 Mar 2018 12:39:06 -0800 From: "Paul E. McKenney" To: Ingo Molnar Cc: "Eric W. Biederman" , Linus Torvalds , Tejun Heo , Jann Horn , Benjamin LaHaise , Al Viro , Thomas Gleixner , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: Simplifying our RCU models Reply-To: paulmck@linux.vnet.ibm.com References: <20180305001600.GO3918@linux.vnet.ibm.com> <20180305030949.GP3918@linux.vnet.ibm.com> <20180305082441.4hao2z4dqn2n5on6@gmail.com> <87po4izj67.fsf_-_@xmission.com> <20180305161446.GQ3918@linux.vnet.ibm.com> <20180306084738.tcs4ggbby77phlbh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180306084738.tcs4ggbby77phlbh@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18030620-0048-0000-0000-0000024534F2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008628; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00999341; UDB=6.00508295; IPR=6.00778659; MB=3.00019880; MTD=3.00000008; XFM=3.00000015; UTC=2018-03-06 20:38:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18030620-0049-0000-0000-000044599245 Message-Id: <20180306203906.GA3918@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-06_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803060223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 06, 2018 at 09:47:38AM +0100, Ingo Molnar wrote: > > * Paul E. McKenney wrote: > > > > > But if we look at the bigger API picture: > > > > > > > > !PREEMPT_RCU PREEMPT_RCU=y > > > > rcu_read_lock(): atomic preemptible > > > > rcu_read_lock_sched(): atomic atomic > > > > srcu_read_lock(): preemptible preemptible > > > > > > > > Then we could maintain full read side API flexibility by making PREEMPT_RCU=y the > > > > only model, merging it with SRCU and using these main read side APIs: > > > > > > > > rcu_read_lock_preempt_disable(): atomic > > > > rcu_read_lock(): preemptible > > > > One issue with merging SRCU into rcu_read_lock() is the general blocking within > > SRCU readers. Once merged in, these guys block everyone. We should focus > > initially on the non-SRCU variants. > > > > On the other hand, Linus's suggestion of merging rcu_read_lock_sched() > > into rcu_read_lock() just might be feasible. If that really does pan > > out, we end up with the following: > > > > !PREEMPT PREEMPT=y > > rcu_read_lock(): atomic preemptible > > srcu_read_lock(): preemptible preemptible > > > > In this model, rcu_read_lock_sched() maps to preempt_disable() and (as > > you say above) rcu_read_lock_bh() maps to local_bh_disable(). The way > > this works is that in PREEMPT=y kernels, synchronize_rcu() waits not > > only for RCU read-side critical sections, but also for regions of code > > with preemption disabled. The main caveat seems to be that there be an > > assumed point of preemptibility between each interrupt and each softirq > > handler, which should be OK. > > > > There will be some adjustments required for lockdep-RCU, but that should > > be reasonably straightforward. > > > > Seem reasonable? > > Yes, that approach sounds very reasonable to me: it is similar to what we do on > the locking side as well, where we have 'atomic' variants (spinlocks/rwlocks) and > 'sleeping' variants (mutexes, rwsems, etc.). > > ( This means there will be more automatic coupling between BH and preempt critical > sections and RCU models not captured via explicit RCU-namespace APIs, but that > should be OK I think. ) Thus far, I have been unable to prove that it cannot work, which is about as good as it gets at this stage. So here is hoping! ;-) I will look at your later corrected message, but will gratefully accept your offer of help with the naming transition. Thanx, Paul > A couple of small side notes: > > - Could we please also clean up the namespace of the synchronization APIs and > change them all to an rcu_ prefix, like all the other RCU APIs are? Right now > have a mixture like rcu_read_lock() but synchronize_rcu(), while I'd reall love > to be able to do: > > git grep '\ > ... to see RCU API usage within a particular kernel area. This would also clean > up some of the internal inconsistencies like having 'struct rcu_synchronize'. > > - If we are cleaning up the write side APIs, could we move over to a _wait > nomenclature, i.e. rcu_wait*()? > > I.e. the new RCU namespace would be something like: > > rcu_read_lock => rcu_read_lock # unchanged > rcu_read_unlock => rcu_read_unlock # unchanged > > call_rcu => rcu_call_rcu > call_rcu_bh => rcu_call_bh > call_rcu_sched => rcu_call_sched > > synchronize_rcu => rcu_wait_ > synchronize_rcu_bh => rcu_wait_bh > synchronize_rcu_bh_expedited => rcu_wait_expedited_bh > synchronize_rcu_expedited => rcu_wait_expedited > synchronize_rcu_mult => rcu_wait_mult > synchronize_rcu_sched => rcu_wait_sched > synchronize_rcu_tasks => rcu_wait_tasks > > srcu_read_lock => srcu_read_lock # unchanged > srcu_read_unlock => srcu_read_unlock # unchanged > > synchronize_srcu => srcu_wait > synchronize_srcu_expedited => srcu_wait_expedited > > Note that due to the prefix approach we gain various new patterns: > > git grep rcu_wait # matches both rcu and srcu > git grep rcu_wait # matches all RCU waiting variants > git grep wait_expedited # matches all expedited variants > > ... which all increase the organization of the namespace. > > - While we are at it, the two RCU-state API variants, while rarely used, are > named in a pretty obscure, disconnected fashion as well. A much better naming > would be: > > get_state_synchronize_rcu => rcu_get_state > cond_synchronize_rcu => rcu_wait_state > > ... or so. This would also move them into the new, unified rcu_ prefix > namespace. > > Note how consistent and hierarchical the new RCU API namespace is: > > _[_] > > If you agree with the overall concept of this I'd be glad to help out with > scripting & testing the RCU namespace transition safely in an unintrusive fashion > once you've done the model unification work, with compatibility defines to not > create conflicts, churn and pain, etc. > > Thanks, > > Ingo >