Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3228710ybb; Sun, 22 Mar 2020 18:59:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvGEUD/jXnbrPQN36V/U9aySFiwBaEkEs1B/NfoRCEa67Lm+eUn4wpV+BGsYtjImgv2deE6 X-Received: by 2002:a05:6830:1e55:: with SMTP id e21mr4292650otj.233.1584928741386; Sun, 22 Mar 2020 18:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584928741; cv=none; d=google.com; s=arc-20160816; b=yccJcDsnJm/5M/53w6VYqespB7QR5W/L3OFXASxFrJedTX8RRUdp6g2DG87ECEeKvo +D2+hVUfvh3FWhrxZIZgd+qfHH9/4KIEJSysASX/+qxGXuOhN/ze+nxKqqEnISCt6Ykk +nbsx2wsH0RORiCZB8AZrTViH2xrrK4wj4jph1ig+taJLqhk3uEavnGOAVihfWevGNWp SJ8FpRerDBcNVEW0P3YaCRYMeNoasDD8ejAJy33YZ3ZMbwscEm696m/JPMTghv8u8PXc T+XSwmlnw3JlrV83dz7BJ56kv0EWSxH/hYsRpWJnvebAHBxqToMzCHk4deGY8pL3OPG9 eM0g== 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=CPTNBS3Fi1p/gJitdrGM7rlktRgoXOE8J7X5+PPOovI=; b=cRxVdcI5fsb0A06hBFsX8z7hN68BRUOI0rsCEeIxAU1lSpmnhp2IbhhfAYsO1NqrmJ gdJEB298umPrP6t3C76pXKLBXHY6aZBnyPYfJlkwazHy+mXxGbWtoxYrmbSvGBcR5Agl +6f5Zck+0RlUPqg/I6RK2aCHz3sC3uLWDm05ODHnNgQpAQXBZaKbK+IkZtSqF1Fi1MFS mGtjCNsZBNNhu2kgTXNxjmIECo71Zu1K29lOfuHJS4ztxD5aeTq3yllKNuG+RmdwcyPF ZeLIBTT6/6kWeQLQInwiwJgAj9jgJZKz3dxqsSS854wi4gfrcRvVZvUZljYbl9e7riY/ v9hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=OUqCP+XT; 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 k66si3549349oif.29.2020.03.22.18.58.49; Sun, 22 Mar 2020 18:59:01 -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=OUqCP+XT; 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 S1727048AbgCWB5r (ORCPT + 99 others); Sun, 22 Mar 2020 21:57:47 -0400 Received: from mail-qv1-f67.google.com ([209.85.219.67]:36583 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbgCWB5q (ORCPT ); Sun, 22 Mar 2020 21:57:46 -0400 Received: by mail-qv1-f67.google.com with SMTP id z13so6438989qvw.3 for ; Sun, 22 Mar 2020 18:57:45 -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=CPTNBS3Fi1p/gJitdrGM7rlktRgoXOE8J7X5+PPOovI=; b=OUqCP+XTeWIkHEUTQ6MHdonPY/cGSi2e/kfYesyOU3ynrutAH8Q4VfxvKw0tUXIA/b h8un8v0SlSrOn9Yg6Yhn1DVmJnVOF3dXuHkCd44v1WwL8eUeaN7FcJVa12o6V3kZ6T+2 EOvZv9JCEPxbjA2/e+eFrjr6gYlBsufneUQBc= 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=CPTNBS3Fi1p/gJitdrGM7rlktRgoXOE8J7X5+PPOovI=; b=mQQUmldJEBGle3lwZePshYpzhYXnHdLkTImTUVxkfSNwYZxDTfzZnmmVKCfl09Yyxn jtQwmLFkc+lEXI3KcS+6Qx3MriJnwQxaTyES0enUNJ35bljdSXVtAMw11qX//AfC05fG IffFFfsJxQx1+weqv/lLs2gl+gQWbxnx519Hu27tsQm2QhD6outAoigO+lBtqg2yhw5P bPcMvltNqE5Wg3mGPS3DA3Az6OQ4ymYq9koaN7OqS5f14k2ytU5K/VwrKXIRH4Qc//jj fAQVOESN/1CSX62tuOZkcClEC9WXLKYb2Ia6CNfRjp0NytIZ/W0z4neyBc8goLqcww6m snpQ== X-Gm-Message-State: ANhLgQ3vbywwAU/nqbDSqN/naJsFWF8b8SycMJMwWeyQzjD6j77TNwgn FCbAxg9pZr7kNLuuPsfS+oU8mbfG4M8= X-Received: by 2002:a0c:f849:: with SMTP id g9mr6774944qvo.108.1584928664464; Sun, 22 Mar 2020 18:57:44 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id e66sm10146233qkd.129.2020.03.22.18.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Mar 2020 18:57:44 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Jonathan Corbet , Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , linux-doc@vger.kernel.org Subject: [PATCH v2 2/4] Documentation: LKMM: Add litmus test for RCU GP guarantee where updater frees object Date: Sun, 22 Mar 2020 21:57:33 -0400 Message-Id: <20200323015735.236279-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog In-Reply-To: <20200323015735.236279-1-joel@joelfernandes.org> References: <20200323015735.236279-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 This adds an example for the important RCU grace period guarantee, which shows an RCU reader can never span a grace period. Signed-off-by: Joel Fernandes (Google) --- .../litmus-tests/rcu/RCU+sync+free.litmus | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/litmus-tests/rcu/RCU+sync+free.litmus diff --git a/Documentation/litmus-tests/rcu/RCU+sync+free.litmus b/Documentation/litmus-tests/rcu/RCU+sync+free.litmus new file mode 100644 index 0000000000000..4ee67e12f513a --- /dev/null +++ b/Documentation/litmus-tests/rcu/RCU+sync+free.litmus @@ -0,0 +1,42 @@ +C RCU+sync+free + +(* + * Result: Never + * + * This litmus test demonstrates that an RCU reader can never see a write that + * follows a grace period, if it did not see writes that precede that grace + * period. + * + * This is a typical pattern of RCU usage, where the write before the grace + * period assigns a pointer, and the writes following the grace period destroy + * the object that the pointer used to point to. + * + * This is one implication of the RCU grace-period guarantee, which says (among + * other things) that an RCU read-side critical section cannot span a grace period. + *) + +{ +int x = 1; +int *y = &x; +int z = 1; +} + +P0(int *x, int *z, int **y) +{ + int *r0; + int r1; + + rcu_read_lock(); + r0 = rcu_dereference(*y); + r1 = READ_ONCE(*r0); + rcu_read_unlock(); +} + +P1(int *x, int *z, int **y) +{ + rcu_assign_pointer(*y, z); + synchronize_rcu(); + WRITE_ONCE(*x, 0); +} + +exists (0:r0=x /\ 0:r1=0) -- 2.25.1.696.g5e7596f4ac-goog