Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp358003ybb; Thu, 19 Mar 2020 23:57:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuwygr3LnmM/oG5dpNFtVPh+yunESHtoZ1HB0/N90FySq05VD/UX4JRyMH9tCDd2TY1nevT X-Received: by 2002:a9d:23a1:: with SMTP id t30mr5443297otb.253.1584687422495; Thu, 19 Mar 2020 23:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584687422; cv=none; d=google.com; s=arc-20160816; b=pzlcpODp0YvWfLDWWRhJG3na+npdARbq+j4A4SpHI/hILrn1l9eOuUwtSPgIDmZ1ls y2Zq+6Rg0hnhKNDfY/1sp2quFiXc9tmeJwsAw1N5BYAnDvP6nb8uWFUP5jKrlrNhS1Qp ocYfMMMl881TMxVRJiM99UYVNZTFMzTP37AGYAcID31zGvG61cDFqolRzpQVf1EjXlUf oV9dvL/dHZFGjL2zParGqH56/uADotWVkMyYcsM3souPk2qUWDwhLnt9+7zyToJ8gpaw 9hG52HEJdYWGDiIyrItV99hazFbTP0cUAThPT4R9pjGrV53EzLHnL5zFtVMrNi7PKH4+ eeAg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=H7qI0J6UdPPMxMo89bJspgFfE6kReY5LFKqgcFnVjEE=; b=sooadhNZj+7QzCFGS5sV1fCVYLHaIosr1X5V5h84lN6fFrL5cRKpAOoysxhqJPigNN WObRTj78eV+dT6IRd/Fz0WopbMJR1caj9db3h94R61rk/q530lo7yvTy3tIWRlYaz419 4N2rDWnGK5xTQOUMfdw8oisL8/hvRHhDpSKAq3GejWlKv2EIdD2NoGrlFBT6eGkGikmb zfHFWgMIu3MlqPhZ+nIHZKRqu4QsbOVxK7sYeeaaQgi3bVYRQ2fO16ZcRRwy2iFP8MRx wK/4ps/vR7cRpc0ll5Ii/PQdaAhE2cQ8p/GJK5TtfEWsVROBJEoo49S/FBcPrYyAL3pz MHdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=M8wPPWkw; 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 v22si2290352oia.165.2020.03.19.23.56.50; Thu, 19 Mar 2020 23:57:02 -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=M8wPPWkw; 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 S1726789AbgCTG4C (ORCPT + 99 others); Fri, 20 Mar 2020 02:56:02 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:38952 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726602AbgCTG4C (ORCPT ); Fri, 20 Mar 2020 02:56:02 -0400 Received: by mail-qk1-f195.google.com with SMTP id t17so5843219qkm.6 for ; Thu, 19 Mar 2020 23:56:01 -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:mime-version :content-transfer-encoding; bh=H7qI0J6UdPPMxMo89bJspgFfE6kReY5LFKqgcFnVjEE=; b=M8wPPWkw74OJ30O2RObg0NV3Uqad/cBAquf9jWLlhnwkQWlKMsX15vW5/llQc7ZVma kPOuv5pWfIfh9QqyZlJXrNJB4Ux8KA/twWx2iH39XKFkgXxG/T5IhWKyDHPbqnw2gSVe p1+JNPzVnbVxNJz2extJx7+1rarPEomTnUDRs= 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:mime-version :content-transfer-encoding; bh=H7qI0J6UdPPMxMo89bJspgFfE6kReY5LFKqgcFnVjEE=; b=km14IFrqBA86KWesjFjuJbPR1Ctyv2wvXZOmt1marn8bOu6VJSP0oYnzPA/U5EHYHu eBMeqoqUNmKvKzexL51PeFmuUEotiQ11/aU6mJUsfTwxgWshwmAED7a3FlfHBtr4Nq1E 6+LmpIcO9h8Bl0v4sqBrznmbePS8fKYqgvq96goFZ/FZcUcqjANThHP6ciWEzJeH5WYp bNPtteBeaLy8zB6l+y0kmRI0c8wfztkfJ5PuHSQSlZXVW5+G9iZ/KpQuKYipFtZiCq3Y aGQ4HNyxCkimF7INiGp23EwDNxQNgLt4FJLMJT9CjmoS1kYOT6u8q8p3Exv5O2zlGsE5 6F7Q== X-Gm-Message-State: ANhLgQ0oBBbwyNeo6HiuRECI3Nop9ZWZYvB+heR68zwgjRV3ZMOxihSl uFp5tdtT4LknF9eQuklao4yaGJZnZE0= X-Received: by 2002:a37:6556:: with SMTP id z83mr6558870qkb.381.1584687360401; Thu, 19 Mar 2020 23:56:00 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id m15sm419985qkk.26.2020.03.19.23.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2020 23:55:59 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Akira Yokosawa , Alan Stern , Andrea Parri , Boqun Feng , Daniel Lustig , David Howells , Jade Alglave , linux-arch@vger.kernel.org, Luc Maranget , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , Will Deacon Subject: [PATCH 1/3] LKMM: Add litmus test for RCU GP guarantee where updater frees object Date: Fri, 20 Mar 2020 02:55:50 -0400 Message-Id: <20200320065552.253696-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog 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+sync+free.litmus | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tools/memory-model/litmus-tests/RCU+sync+free.litmus diff --git a/tools/memory-model/litmus-tests/RCU+sync+free.litmus b/tools/memory-model/litmus-tests/RCU+sync+free.litmus new file mode 100644 index 0000000000000..c4682502dd296 --- /dev/null +++ b/tools/memory-model/litmus-tests/RCU+sync+free.litmus @@ -0,0 +1,40 @@ +C RCU+sync+free + +(* + * Result: Never + * + * This litmus test demonstrates that an RCU reader can never see a write after + * the grace period, if it saw writes that happen before the grace period. This + * is a typical pattern of RCU usage, where the write before the grace period + * assigns a pointer, and the writes after destroy the object that the pointer + * points to. + * + * This guarantee also implies, an RCU reader can never span a grace period and + * is an important RCU grace period memory ordering guarantee. + *) + +{ +x = 1; +y = x; +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