Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1979922imm; Thu, 7 Jun 2018 03:33:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKTyTOiB9n1Sg938EdbC31ez/g/CzS99nbWU1cAwFcptEt3T2ns9B6EL6oNExrfyWqsYviT X-Received: by 2002:a62:5911:: with SMTP id n17-v6mr1267793pfb.162.1528367589943; Thu, 07 Jun 2018 03:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528367589; cv=none; d=google.com; s=arc-20160816; b=0yv7tua78ngd2Bsr6qbZRENk5Dt7B57AxU3h+pKuO1FFEF/w7IgbYRR9MucW1LVct5 EdkF/3phJ91UHar+OcVMqKvCfmPrOPRXw9OER6ETn4ZphRGa4yIukbkiQKlzE14+JBVy SI/Dcipoim4izIcsEVjdt27qrjGjHc17mzkdeGwrm7k+Ljtj1dSh7A6t+IKeEBc/Sh19 +EjoHs9AJJa8nd0y69jsCti9qljbyOoSZbbIMQiUePGAFrdpeSmKRR1dIJKRtM6BXMmm SSQbQf9UCYy35je9NAmyUtp2Pyg/bQyvvy7SxhFsmcCyq5im/2rIFwpBCZ/vQMZ8JeF0 mM0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=X16pk0Ml23pL4XoS0LJ114RDqw7fQNqIijYPiOAf2eg=; b=qWMGyEwhK0lFPQBOrsYBb95YZU75b9Gv5ArqxBdcHw/TTtMLMZ5Q04iZ4Z83ZVoQ1M sdbeZ0GhLFtyt6AuAnCwFj8jRpIppge/u+y58LbmCR/H+9bF6BpS2Wdiw2wJgT4G19xT Ak7vezoVz8vVV6whBinui/OzCCOU042fqSpgVq7QuG+LyHQnniLtD0S4ZvsKy1c6B0+w RG2nGUebBCwTyEe6K5p/f4txYtwq5waHA0s02jE+flWAO8RLgQtd4rXGxxjZvsDKUGc3 K/9cY1hWl+FCCNk4GEB2fzxpPDnC/HLisxm2uHTjQKqSDeViVmAF863nIPWYZHwINXrS Szcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hlHO9gtR; 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 x61-v6si52462701plb.560.2018.06.07.03.32.55; Thu, 07 Jun 2018 03:33:09 -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=@amarulasolutions.com header.s=google header.b=hlHO9gtR; 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 S1753560AbeFGKCR (ORCPT + 99 others); Thu, 7 Jun 2018 06:02:17 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52778 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753012AbeFGKCP (ORCPT ); Thu, 7 Jun 2018 06:02:15 -0400 Received: by mail-wm0-f68.google.com with SMTP id p126-v6so16793258wmb.2 for ; Thu, 07 Jun 2018 03:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id; bh=X16pk0Ml23pL4XoS0LJ114RDqw7fQNqIijYPiOAf2eg=; b=hlHO9gtRedmyvuH6CHklUNngEGgzS2QkGqbiGXI82d4nL48dsB7wviNWQOtdG6cjz9 4xbwietGMWJ3/eWXy0yrLSQroMXzyax5YpTdn4O0FE1Qc6w81AY5jGUsUWYRGXHv1Tz/ vc3JtPJDkOyLf/lwFqYCEek+y81V8AfJnsh3w= 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; bh=X16pk0Ml23pL4XoS0LJ114RDqw7fQNqIijYPiOAf2eg=; b=NopJtI8l4Jiq4fCj49Zo/Sg1gW21jSanLHcb2Zh7BICgaK2rnQKigR1r15qQyYnbk/ vAs37zzOGtuV0gLtKrfhNix2Ep3C6zxHSXo4vPtVul8sLKjmX9mn6Yy3LSfy7huwlTE9 rtLoXa13RGZex5BrNItLJXF2jTkY/XXNP3gKNALKqyd4KKNLmfTYl3NgDQSDW9HVnYNp 6yeuRvFVKI46qxz5i2pIeic8QkKSqqhp6B+f6EmGrL1iLCQIwJNx4/b5MFT2l5AYBVTn m77zCb4CEdKFHTwO6NRq2BXN3WGS8nnhjESqc3E2SVmUeCkOVtHUelsTyQqRc3rNhgVr oYXQ== X-Gm-Message-State: APt69E3bpWdEDTNXTgqAI2hZ1s05H6sj2vlf1s3b7ABZsNtH6EyG0gr/ fjWTeqBoyI/YjGxgkh5wrPdqNN9d X-Received: by 2002:a1c:581:: with SMTP id 123-v6mr1177187wmf.58.1528365733231; Thu, 07 Jun 2018 03:02:13 -0700 (PDT) Received: from andrea.amarulasolutions.com (85.100.broadband17.iol.cz. [109.80.100.85]) by smtp.gmail.com with ESMTPSA id b80-v6sm2161583wmf.2.2018.06.07.03.02.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jun 2018 03:02:12 -0700 (PDT) From: Andrea Parri To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Andrea Parri , "Paul E . McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Jonathan Corbet Subject: [PATCH] doc: Update synchronize_rcu() definition in whatisRCU.txt Date: Thu, 7 Jun 2018 12:01:57 +0200 Message-Id: <1528365717-7213-1-git-send-email-andrea.parri@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The synchronize_rcu() definition based on RW-locks in whatisRCU.txt does not meet the "Memory-Barrier Guarantees" in Requirements.html; for example, the following SB-like test: P0: P1: WRITE_ONCE(x, 1); WRITE_ONCE(y, 1); synchronize_rcu(); smp_mb(); r0 = READ_ONCE(y); r1 = READ_ONCE(x); should not be allowed to reach the state "r0 = 0 AND r1 = 0", but the current write_lock()+write_unlock() definition can not ensure this. Remedies this by inserting an smp_mb__after_spinlock(). Suggested-by: Paul E. McKenney Signed-off-by: Andrea Parri Cc: Paul E. McKenney Cc: Josh Triplett Cc: Steven Rostedt Cc: Mathieu Desnoyers Cc: Lai Jiangshan Cc: Jonathan Corbet --- Documentation/RCU/whatisRCU.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt index a27fbfb0efb82..86a54ff911fc2 100644 --- a/Documentation/RCU/whatisRCU.txt +++ b/Documentation/RCU/whatisRCU.txt @@ -586,6 +586,7 @@ It is extremely simple: void synchronize_rcu(void) { write_lock(&rcu_gp_mutex); + smp_mb__after_spinlock(); write_unlock(&rcu_gp_mutex); } @@ -607,12 +608,15 @@ don't forget about them when submitting patches making use of RCU!] The rcu_read_lock() and rcu_read_unlock() primitive read-acquire and release a global reader-writer lock. The synchronize_rcu() -primitive write-acquires this same lock, then immediately releases -it. This means that once synchronize_rcu() exits, all RCU read-side -critical sections that were in progress before synchronize_rcu() was -called are guaranteed to have completed -- there is no way that -synchronize_rcu() would have been able to write-acquire the lock -otherwise. +primitive write-acquires this same lock, then releases it. This means +that once synchronize_rcu() exits, all RCU read-side critical sections +that were in progress before synchronize_rcu() was called are guaranteed +to have completed -- there is no way that synchronize_rcu() would have +been able to write-acquire the lock otherwise. The smp_mb__after_spinlock() +promotes synchronize_rcu() to a full memory barrier in compliance with +the "Memory-Barrier Guarantees" listed in: + + Documentation/RCU/Design/Requirements/Requirements.html. It is possible to nest rcu_read_lock(), since reader-writer locks may be recursively acquired. Note also that rcu_read_lock() is immune -- 2.7.4