Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1012667imm; Fri, 5 Oct 2018 16:20:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV635HabhDKegIb9bdTIPg7OWRj+Cc8skNpHT6vG65Fa4tnCK6ln6+wgKayVvFTK/INRy9Fip X-Received: by 2002:a63:2ad4:: with SMTP id q203-v6mr11693704pgq.356.1538781631001; Fri, 05 Oct 2018 16:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538781630; cv=none; d=google.com; s=arc-20160816; b=H2p0gwn4DbSsCzfXAuY6dMdOoTmXS9PMOo8bVG0o5FqNI5f5pHQeQK8VbzHNAKeUrW LcQPMvdk/umCiMDwPiZwnXjGrMwxZd8GTxt+IVpeJfwurCEtkW4s4vp+ZBaOGTHcGFps ko1O5UPM4erfpZmJCiD8qFs00nErwXTtdXksXCzZbotsu/+IpSl1ywLjUUK+j5vaU4Cr z+djfp9O80OrdQhvkLjyYNo45JyYv+k36NcQZ9me7ESuE/FxuBEy3/4Ivt54YxwmUBh2 P+jAtRC3dHdxlOjOhqWqQFISA7Qs/OrzXSXot8BNC6w4DjrDYe1wCBsctdR21WDileK3 GB4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j29U8JQnih/0IvhrWQU7iPNzapwYGDDk3J+T5RCZwvY=; b=Ul7MJu2Nt7CQpw4te1mqvez8cFhC8QkOp+5pr++3qt8a7EDmxHCOf0RzYGldMqIXmP dfKdi+pRjm4KxHkqc/+YwBtwPnJYx0DFyzywpzZWPDHOgaezDdzJfVnkheNbGq/RPoL4 zVaF7joGXBtCPSkmaxnbeCPZ64igeG4a/TpG2yVVA5nSaprZYyOmccPrdedgDKY3WaMZ pWIKFCDW84u+XCv6+ciWn/aHVHzstLydKlmRG6FoIr1S5hhaMh+8jN8QdVdSmBHfB4UZ j1aGZ3Wt1T4h/THsPs3l2f+WNvJ10B7FzQAjOJe73N1EEsiWlWWZC43wo/oF4U1OUTNZ B8bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=aMkoVR+p; 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 16-v6si8891022pgw.208.2018.10.05.16.20.15; Fri, 05 Oct 2018 16:20:30 -0700 (PDT) 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=pass header.i=@joelfernandes.org header.s=google header.b=aMkoVR+p; 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 S1728946AbeJFGT0 (ORCPT + 99 others); Sat, 6 Oct 2018 02:19:26 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35905 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728403AbeJFGTZ (ORCPT ); Sat, 6 Oct 2018 02:19:25 -0400 Received: by mail-pg1-f193.google.com with SMTP id f18-v6so5356011pgv.3 for ; Fri, 05 Oct 2018 16:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j29U8JQnih/0IvhrWQU7iPNzapwYGDDk3J+T5RCZwvY=; b=aMkoVR+pEgL2tFS3HBxRLn6jJ2z+wF43kpa9cl2Hljty+Hh5S3g9pPagp42NJFs8/G 3zzdncwdNkOmchInZum09BlkhcWTUGWVcGExDsjG/wjh05nOfWFBXn4JHeaMfpWz9owB CjSierXYLuo3xhSpR5jdRg5biUomrTlViHvZ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j29U8JQnih/0IvhrWQU7iPNzapwYGDDk3J+T5RCZwvY=; b=ZadfkTwpCVFb5pxDarXN35dplWlzKoYkwlHyJH8tyTm6v+eTnyPS9r4KYB2xiUou27 Wqr5hTo0KQRrWMTdZoRNKHrXmTcF1o4A2mAWpvasnqr/ER4Ywa3heTurDaIx1IZHAai1 cyjtUzX9QDJE/tSQnbNcBeKAc2yuifOq2jwTLp9RVGLHoarup7GTZcCkuVjVDG7JrAgi al9ax6XKrk/gYcSuPtGrJEtlIArr6y88uZEvuRlVtcXZ/DL0aytpzO7EEYfX9YEu7eL6 CvW+t5QMrqtbpIfJCDmtY+xTJ4iUp1Wlme2Iil8LIsTcLTy5byze1GAZt83SYhy2JAWq pwsQ== X-Gm-Message-State: ABuFfoiIfMpQ2Um0uMp9p6LswFqr52G1NbkrdgXpKV4UcEIwovJz8+CH aKfwXlYfbZz4uiu4t7LRFlKu8OBZarc= X-Received: by 2002:a63:4343:: with SMTP id q64-v6mr12329067pga.276.1538781509185; Fri, 05 Oct 2018 16:18:29 -0700 (PDT) Received: from joelaf.mtv.corp.google.com ([2620:0:1000:1601:3aef:314f:b9ea:889f]) by smtp.gmail.com with ESMTPSA id q76-v6sm16641028pfa.18.2018.10.05.16.18.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Oct 2018 16:18:28 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Jonathan Corbet , Josh Triplett , Lai Jiangshan , linux-doc@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Steven Rostedt , pantin@google.com Subject: [PATCH RFC 1/5] doc: rcu: Update core and full API in whatisRCU Date: Fri, 5 Oct 2018 16:18:10 -0700 Message-Id: <20181005231815.170433-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181005231815.170433-1-joel@joelfernandes.org> References: <20181005231815.170433-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RCU consolidation effort causes the update side of the RCU API to be consistent across all the 3 RCU flavors (normal, sched, bh). Update the full API in the whatisRCU document accordingly so we are encouraging folks to use the consolidated API than using the ones for the individual flavors (which if I understand correcty, could be removed in the future). Also rcu_dereference is documented to be the same for all 3 mechanisms (even before the consolidation), however its actually different - as using the right rcu_dereference primitive (such as rcu_dereference_bh for bh) is needed to make lock debugging work correctly. This update also corrects that. Also, add local_bh_disable() and local_bh_enable() as softirq protection primitives and correct a grammar error in a quiz answer. Signed-off-by: Joel Fernandes (Google) --- Documentation/RCU/whatisRCU.txt | 55 +++++++++++++++++---------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt index 86d82f7f3500..2e8d1c0a824f 100644 --- a/Documentation/RCU/whatisRCU.txt +++ b/Documentation/RCU/whatisRCU.txt @@ -322,28 +322,27 @@ to their callers and (2) call_rcu() callbacks may be invoked. Efficient implementations of the RCU infrastructure make heavy use of batching in order to amortize their overhead over many uses of the corresponding APIs. -There are no fewer than three RCU mechanisms in the Linux kernel; the -diagram above shows the first one, which is by far the most commonly used. -The rcu_dereference() and rcu_assign_pointer() primitives are used for -all three mechanisms, but different defer and protect primitives are -used as follows: +There are atleast three flavors of RCU usage in the Linux kernel. The diagram +above shows the most common one. On the updater side, the rcu_assign_pointer(), +sychronize_rcu() and call_rcu() primitives used are the same for all three +flavors. However for protection (on the reader side), the primitives used vary +depending on the flavor: - Defer Protect +a. rcu_read_lock() / rcu_read_unlock() + rcu_dereference() -a. synchronize_rcu() rcu_read_lock() / rcu_read_unlock() - call_rcu() rcu_dereference() +b. rcu_read_lock_bh() / rcu_read_unlock_bh() + local_bh_disable() / local_bh_enable() + rcu_dereference_bh() -b. synchronize_rcu_bh() rcu_read_lock_bh() / rcu_read_unlock_bh() - call_rcu_bh() rcu_dereference_bh() +c. rcu_read_lock_sched() / rcu_read_unlock_sched() + preempt_disable() / preempt_enable() + local_irq_save() / local_irq_restore() + hardirq enter / hardirq exit + NMI enter / NMI exit + rcu_dereference_sched() -c. synchronize_sched() rcu_read_lock_sched() / rcu_read_unlock_sched() - call_rcu_sched() preempt_disable() / preempt_enable() - local_irq_save() / local_irq_restore() - hardirq enter / hardirq exit - NMI enter / NMI exit - rcu_dereference_sched() - -These three mechanisms are used as follows: +These three flavors are used as follows: a. RCU applied to normal data structures. @@ -867,18 +866,20 @@ RCU: Critical sections Grace period Barrier bh: Critical sections Grace period Barrier - rcu_read_lock_bh call_rcu_bh rcu_barrier_bh - rcu_read_unlock_bh synchronize_rcu_bh - rcu_dereference_bh synchronize_rcu_bh_expedited + rcu_read_lock_bh call_rcu rcu_barrier + rcu_read_unlock_bh synchronize_rcu + [local_bh_disable] synchronize_rcu_expedited + [and friends] + rcu_dereference_bh rcu_dereference_bh_check rcu_dereference_bh_protected rcu_read_lock_bh_held sched: Critical sections Grace period Barrier - rcu_read_lock_sched synchronize_sched rcu_barrier_sched - rcu_read_unlock_sched call_rcu_sched - [preempt_disable] synchronize_sched_expedited + rcu_read_lock_sched call_rcu rcu_barrier + rcu_read_unlock_sched synchronize_rcu + [preempt_disable] synchronize_rcu_expedited [and friends] rcu_read_lock_sched_notrace rcu_read_unlock_sched_notrace @@ -890,8 +891,8 @@ sched: Critical sections Grace period Barrier SRCU: Critical sections Grace period Barrier - srcu_read_lock synchronize_srcu srcu_barrier - srcu_read_unlock call_srcu + srcu_read_lock call_srcu srcu_barrier + srcu_read_unlock synchronize_srcu srcu_dereference synchronize_srcu_expedited srcu_dereference_check srcu_read_lock_held @@ -1034,7 +1035,7 @@ Answer: Just as PREEMPT_RT permits preemption of spinlock spinlocks blocking while in RCU read-side critical sections. - Why the apparent inconsistency? Because it is it + Why the apparent inconsistency? Because it is possible to use priority boosting to keep the RCU grace periods short if need be (for example, if running short of memory). In contrast, if blocking waiting -- 2.19.0.605.g01d371f741-goog