From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDE10C54E58 for ; Sat, 23 Mar 2024 14:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=U9wEDFl4FajERSGBH7l9+c3qtA9JJj4TIvpCwas8u68=; b=2Sy8k7d9c8uEvg T4h7wzbEB9cQRLme0SKr/CUOUqhMhmn4GNnRRVI7w0KC2KXT71cCIk7MikvdW2iJ9QwEkn87wfBU6 sRp/PCqFGtw2hNVBfGLor8t6LB/xBTu3kD7WFXsqQvoPVDip0JWcPsddRZwrV+91wA/ZdjHlWBNxK A9kPpLzOd+80wzvsOCeoATNLILwECrFjiwe8/TsuJeYtkvfAH6pHL6R4NKF7gdDJ7JMbKsynKvnbc T5J9KQr70RvRzYq7vHys5mzrNxGIBkKA80kVSycGBHocQb74wRNappk675RFN2i8c/3iqVWfzJ4gI 6T0k0VNUwYtniYZeh6dQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ro2mK-0000000Aahs-2TKw; Sat, 23 Mar 2024 14:55:24 +0000 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ro2mH-0000000AagX-0WBF for linux-arm-kernel@lists.infradead.org; Sat, 23 Mar 2024 14:55:23 +0000 Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-430ca04b09bso22546681cf.1 for ; Sat, 23 Mar 2024 07:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711205718; x=1711810518; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=VRfoDMeQr45A3YPnCIYGOXROndTyGMuSPLDLPYakgoQ=; b=ITnV63hTI945dERpx2losNyXg+pZgQRslRe+r67uTHavxdjMyJeXRdKPmECXmle+wG 84Z1mYe2IbCVm0wi/JUrDVNsgn+9C3r/PVTw4i0ablO6BVWGUpMS1A7U1b+UuG3bF1mN SEmzlqN/IjVEXt+YeGrj6frWrYsEC3wz749UWbI5TopW33PM8V3wkJuxYDuZPKlBbL8n DggDpvW9vp83cgXatrwdDSSFRloefRlwn1VJrkIm9DWi2VQR2TDESUyqZgMgIIsWriQj CwxbxwHlio2IrE+HM7cq25aI7VGW7h9l0n8Abiu8q0SuX/lOUbEU/aO75zwm3ZqWRoJ0 wYhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711205718; x=1711810518; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VRfoDMeQr45A3YPnCIYGOXROndTyGMuSPLDLPYakgoQ=; b=fUELYJ2wwsPqKJiUhS3cwCitxaBbSH2fZ6iJgm0SLP4Ap8M1OjAxsXSpets1JFHMVr Or2BO/ILvB9HyyQQdgRA9T20FS+beLmUMri76tyYXdgxPiQVvVcuEdTgN7uJiOt7d/gU 7wdVCXsLXbsZD1hpVFRk4NkTCW6GCTCc8yqRQEMuKedUMLcb1HMFX/n2i1ofyJo7vTEx ok227NiwLqJw5oTNqMsnWfJhX0hrTm+zmvclRWsazz1WsBJQrbSk8sK36qIidOdjLNOX fJrqxDHmSbWtkLeqrvwTrSIp2GgTtOkfwOzVP2xwQSj+cs5hjCrNwnGnWvwFivxfjvko 4rqQ== X-Forwarded-Encrypted: i=1; AJvYcCUPzKF8m4L0Me81Bg3FrEssqIOkF+IePU+/ZVNf8erp2pVRjp5MQywn5SuKmcp1CppYTBU5PcqVYWgDEhVYTjaLJ76d3T8PxOJSlyWvBzHdNihZSxA= X-Gm-Message-State: AOJu0Yyo4uprzztSzUCVcYiFp9KnDwLzr4neQsEOJlbGLMJbZqP3Ra8v spGVKZoVGD7qS/aqjoqpSiOxqOKhV84BgDtBXUfu2215S+6gmhuU X-Google-Smtp-Source: AGHT+IGOG5dTcaGFgWmVDZ1YjnIERFJGHFMnBnYOLUtIpJuvddeQMaprbzxm238UN7Y+D20JT0d1mw== X-Received: by 2002:a05:622a:1994:b0:431:3e65:3bd7 with SMTP id u20-20020a05622a199400b004313e653bd7mr2246075qtc.47.1711205717718; Sat, 23 Mar 2024 07:55:17 -0700 (PDT) Received: from fauth2-smtp.messagingengine.com (fauth2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id r12-20020ac85e8c000000b00431236d1f56sm843488qtx.30.2024.03.23.07.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 07:55:17 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfauth.nyi.internal (Postfix) with ESMTP id 551D41200032; Sat, 23 Mar 2024 10:55:16 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 23 Mar 2024 10:55:16 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddtgedgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 23 Mar 2024 10:55:13 -0400 (EDT) Date: Sat, 23 Mar 2024 07:55:12 -0700 From: Boqun Feng To: Andrew Lunn Cc: Kent Overstreet , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, llvm@lists.linux.dev, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Nathan Chancellor , Nick Desaulniers , kent.overstreet@gmail.com, Greg Kroah-Hartman , elver@google.com, Mark Rutland , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Catalin Marinas , torvalds@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [WIP 0/3] Memory model and atomic API in Rust Message-ID: References: <20240322233838.868874-1-boqun.feng@gmail.com> <03f629b6-1e4e-4689-9b69-db0b75577822@lunn.ch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240323_075521_213985_45B80CFD X-CRM114-Status: GOOD ( 21.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Mar 23, 2024 at 07:41:28AM -0700, Boqun Feng wrote: > On Sat, Mar 23, 2024 at 03:29:11PM +0100, Andrew Lunn wrote: > > > There are also issues like where one Rust thread does a store(.., > > > RELEASE), and a C thread does a rcu_deference(), in practice, it > > > probably works but no one works out (and no one would work out) a model > > > to describe such an interaction. > > > > Isn't that what Paul E. McKenney litmus tests are all about? > > > > Litmus tests (or herd, or any other memory model tools) works for either > LKMM or C++ memory model. But there is no model I'm aware of works for > the communication between two memory models. So for example: > > Rust thread: > > let mut foo: Box = ...; > foo.a = 1; > let global_ptr: &AtomicPtr = ...; > global_ptr.store(foo.leak() as _, RELEASE); > > > C thread: > > rcu_read_lock(); > > foo = rcu_dereference(global_ptr); > if (foo) { > r1 = foo->a; > } > > rcu_read_unlock(); > > no tool or model yet to guarantee "r1" is 1, but yeah, in practice for > the case we care, it's probably guaranteed. But no tool or model means > challenging for code reasoning. > There are also cases where two similar APIs from C++ memory model and LKMM have different semantics, for example, a SeqCst atomic in C++ memory model doesn't imply a full barrier, while a fully ordered LKMM atomic does: Rust: a.store(1, RELAXED); x.fetch_add(1, SeqCst); b.store(2, RELAXED); // ^ writes to a and b are not ordered. C: WRITE_ONCE(*a, 1); atomic_fetch_add(x, 1); WRITE_ONCE(*b, 2); // ^ writes to a and b are ordered. So if you used to have two parts synchronizing each other with LKMM atomics, converting one side to Rust *and* using Rust atomics requires much caution. Regards, Boqun > Regards, > Boqun > > > tools/memory-model/litmus-test > > > > Andrew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel