Received: by 10.223.185.116 with SMTP id b49csp3559815wrg; Tue, 6 Mar 2018 00:48:52 -0800 (PST) X-Google-Smtp-Source: AG47ELuRQJBeFelaJT9YqdAebJ6HFzk5tfnnz1KOXNYEbSAb2NVpM1hj21RJPD4UQusS6M1DBWEz X-Received: by 10.98.86.151 with SMTP id h23mr18054451pfj.79.1520326132195; Tue, 06 Mar 2018 00:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520326132; cv=none; d=google.com; s=arc-20160816; b=CPElkywPNx0u2F6quJl3SQevHCJA67Ak+wzuS5t3BT5h5vz07ItocjJaVknBerj/9c wt/YCUu+bJ2cwOKBh9TKy0NST7IRZwTXzjjHCnTKHeIirlMkZt++P5d9JCQiE91Hdc0R kkAQLq7Np3bllqoepwATM3lHEhNjInXHou0/Wmr8qTJgIG+YzNyyBHXN7MzW5LGqwrXF +E99dHZpQEc9nXyRl+rQ3CUGN41Ii4lTlfGJZfLV7qHFvCQdA0GY06mh0Y63OU4tOCev M0W5flx/xEfrOHFo5st+z7oKj/FmhfcMuhv65jbkLXtzDUALVrCvYDS8PlS8Sn+c9HpY gyhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=J04e0jDNDGzvOcNSu7SnpSGgQW71RIwjHaOrmpFrdwQ=; b=hREVqr/DGMvaACOdF/TKg/+Ocirhw9jy7ZwIwf+GBzZFCyppDdBFHZ9CRMohgmif2O RgBH/oIvgv29Ic8ZCMgZnNHZ1+l9vq4HNmQ/kwWRblyxh9Nwg4qwmSRXsv3bQk4Tg4Mm 9D5FzUh8PcQsJmWvXhKnmkoq28xaw9/ErmQqy5t4V8I/hGN+lyUV2two+9l0KSfZoSWm nn8P82PCjbzPm2XPLSkp79Wy8KYMtcGvgbz04zpIch8mtUvZkn7rmRjuzfmBog09tlvf WhTTTygn1L0TudzXfHJK1mAajboh0NFErDG+tGz4bvB5xs+xckMGabvfuy7En06hZzgP BNjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=FUZiAdW1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11-v6si10741918plt.580.2018.03.06.00.48.37; Tue, 06 Mar 2018 00:48:52 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=FUZiAdW1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752908AbeCFIro (ORCPT + 99 others); Tue, 6 Mar 2018 03:47:44 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:55683 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbeCFIrn (ORCPT ); Tue, 6 Mar 2018 03:47:43 -0500 Received: by mail-wm0-f53.google.com with SMTP id q83so21158472wme.5 for ; Tue, 06 Mar 2018 00:47:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=J04e0jDNDGzvOcNSu7SnpSGgQW71RIwjHaOrmpFrdwQ=; b=FUZiAdW1kWqd4yopp/LzD9G4KocY+6mzpOWPrBo2AR8Cyo33RonANC5lk/gTgl2HPG gEqQ7Tb6RWzuhXgY2LKWBO5EhMXBB/E6bwwL2fCXDG+FZbwbNfC1zpELU6fR7SsYYHZ0 bK01jv8Z8HA+pRkGB/ffscHxWYW9FNkcUis7bpKqWF/MxpWDt8/wS3SoGPQxMnmFsa+H /kO3/8pvpo41lrwrqzaBGr16nFUEr6MkKmKqrP3L3Rd84DP52osnpuY7MAtDwUeW3ukt FCi6QCrXc4cnzkHxfdzYehwvDlqmXcEr7kVFKBsBPkrOQCKpU9Ebx190ATVU0OpYJ4C7 cU6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=J04e0jDNDGzvOcNSu7SnpSGgQW71RIwjHaOrmpFrdwQ=; b=D4LPloDuJuFKfgxZjXnemaNYN1aZL/UDncNuaNHxNRazteMLYRUybPPrtFZp3c3HSz MA3dVhI8wFn73X3V8lOHL2SFrmAaXsTnXNCTj2hyckbvSw1d72i+w4Y8oUY6KC0gHRsJ O0Q1osvGKigz0sTDR4fmAgF4UziW9MeMYg5GS6CIHgzN5r/M/jUqCJxOZyt5+dV8CshI KYsqu7zNCQmk+YJds4RaHmdOxlYN273lc4rxfvzp3vOPdSk+h979U2SFtCE01UyjTfqN xLyXH6l5zI/TUaklsaii4V+jKc66Hh3x96pKHO3Ue/kfDo4sutXOPI+pR+TWDJPlnmg6 LiuA== X-Gm-Message-State: AElRT7FMZHk21x6RCETLQp5NV9hCx1aeDiOBRLwD+u4ksbuLK1HIxYJO WQ+UUyDfkmnpFP/j1FFpJyFmrw== X-Received: by 10.28.195.133 with SMTP id t127mr10424498wmf.156.1520326062075; Tue, 06 Mar 2018 00:47:42 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id y129sm8146761wmg.5.2018.03.06.00.47.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Mar 2018 00:47:41 -0800 (PST) Date: Tue, 6 Mar 2018 09:47:38 +0100 From: Ingo Molnar To: "Paul E. McKenney" 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 Message-ID: <20180306084738.tcs4ggbby77phlbh@gmail.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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180305161446.GQ3918@linux.vnet.ibm.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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. ) 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 '\ 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