Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3068115lqp; Mon, 25 Mar 2024 19:51:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBihqMpWsHh5EvrS2+t7jLzbdIZJlle3ldZ1UQQx8ewaYh/yRcUROIIyZFk60MVcunexH6uEr1O1vrpWsqUWkwYw9iAK+GxMiby8VmCg== X-Google-Smtp-Source: AGHT+IHb3ZRE04oM59YfASmDUepDIH2wQuWRor/W3puieCz36+0dJsxt5tOHgcqtATik4U1S4fe8 X-Received: by 2002:a17:906:e247:b0:a46:c4c6:38 with SMTP id gq7-20020a170906e24700b00a46c4c60038mr5728402ejb.10.1711421510005; Mon, 25 Mar 2024 19:51:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711421509; cv=pass; d=google.com; s=arc-20160816; b=Q4ZBY0nvPRTL46u4SdPZ3h9u+EZg4y4ItpWef5eMy6w+SC8RgvWQqDZsAY9HJGXvID cB2CvRTganAUi0AfSRcNxxoCbcVn5B1yPyGAG7vC9UKb4To7OolL2YTlyJu+VPCI2NVr eIfN9NZBkQ6/v62DcWzgIST9uYp5jQMloZJqK/gIKfckAfqmt2/TtDkAay/1Ry10dXy2 yGyvEgoPrSykWE6BaGm7sssrPgu7PrfgzXdjiGJwfqjUIw86M43TjsaZlgOC6Z+/8bol MK4HwkN/DjpAcf4KC7E43nY0O6IHBL/k1mmPChkazCpGtTqLPhPwebaYTvaga3EFZ1d3 JPgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature; bh=fcNhvrzgAeTv+RtaHHdMdJGRePwYOV19cay72dN5zG0=; fh=Avo1w3nosfCwc0RpNUPz9AtUyqXR9Wkn40Q9RASv2pg=; b=cPGKsIucwMYBiktNRa3BxG4LzH7JHwU2PrpW+CoyhUIZfXmUWDB7rV09bIgSwvULYc kC+OLJOo2kUFN9lm6nzIx1HZXRRHrip4dj7AIp55HGjkPMb+dWguYGT0q6FZ773F8K/r sk20cIDtP7NcTi0RCFG7D+QaTw6CEgsBVgC8gWBOPC3iZZzmQAMigCYDL3oavBvyBDWD R+6KEHJFRXOGp/LPBJMHBhFN0eUf+aR+TwuP0o+W27nRPhgpEV0JT4MwtUeOtSH2BjZ8 LTAWam+TKW5fDRWwZi8dUtBQNUx0mQM58UsR7XgoRseFDpxePGEXE9CoxL6N0hj4Z+4A Qs3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AgRVmiR3; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-118315-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118315-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kn1-20020a170906aa4100b00a47340c3f59si2937062ejb.879.2024.03.25.19.51.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 19:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118315-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AgRVmiR3; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-118315-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118315-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 69EB81F39DF7 for ; Tue, 26 Mar 2024 02:51:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC181129E62; Tue, 26 Mar 2024 02:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AgRVmiR3" Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23FCD128392; Tue, 26 Mar 2024 02:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711421478; cv=none; b=KQqhNg+/DSruGz+Y46b9fO1GSNIVUEaWs+BEyw3ffBfSwm0f8Z/36RFo/HqZECdln0wIMVhP9ewJ0mYg/nyXIxjPfnDxmb6UAtEkrqBqJfpHZ/zG/+U+bOuy8k04wgctsAfKb71MCI451jDb0Re8HpiB1H53uAeK11eaorHjPzY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711421478; c=relaxed/simple; bh=N5UUxAKoTPcBjWK+QOUVolTBhb8j694WCAv1Ly4a9d8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L5tMG7x0fHI0PfYHO0UTIpL4dweMwpCNmjLWypEVR0cVDiTJcmcfUXvYQL6ipBSEgpuLVdxHhSQHqYKhfx+DM7Kp33pLF0jFRW7di8NsjTUZyUimaWgWoHgCg98FzrcwnkL9RHisn7UHqFyQKhJata2X6f8z8O4KsJ3cLeQImSY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AgRVmiR3; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-789db18e169so390188585a.1; Mon, 25 Mar 2024 19:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711421476; x=1712026276; darn=vger.kernel.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=fcNhvrzgAeTv+RtaHHdMdJGRePwYOV19cay72dN5zG0=; b=AgRVmiR3D9mf+k/NIj7NXanJ7ArXrV15PnMeE+XYF7mcljRYdW1oRo/62fH5xlVOi2 62ZwhmqBWXuF064QyMpofaqV3O+SAMnR28Q4F2YRRRxuAoGRke5Kwn/K1FGbLpaAxFqB LP383lgMqVmmxIlv+bXPMkU/na6aXv+eGCN6qbT+ft2e+L1IUBd0UCLonN0tduEFYnjQ qK91OCpohVl1OCiLL2Q/UJiCylRks1wiulToJO+DPOmifF7COeY1v3ihjHr5GQ0+UeEv NmjEqM6fP030GmlNEC2l5t966WR+oFUCDGkR8tPlzRl52dO4o72axc7F57ja+qVfWxuN urwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711421476; x=1712026276; 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=fcNhvrzgAeTv+RtaHHdMdJGRePwYOV19cay72dN5zG0=; b=blgRtuiA4rhqJ1mFlqsNBZR3BI/PApnZVCzIl+KNHazfxJ7YdODOtup9TAWAk9cBzp rL581AhhS6Eh9B2cXTxncaY6i6PIxBo2twCaRuRg0urNBUHxfEfkQwbzJ1GIV0NTw93F vMQAkpi3zAzdCBEQcz/U7mqN6ZOnBVEOnicz35ejGP5l/hQvz4W2Wrk+yXeNOLpYiLB6 5sjCNthrgiVZ3UCc8nEGlrpmuDW1D/FBtnoPZCzgFAm5VKVIB5bHqJqOx9xdEaIKYpMy d78lefI+I+1Ai7/1lyaciiyph3Artz7DZT+q2sAPnfSJMgzfThJkKvdnmHgl9gw/4DeO RnUA== X-Forwarded-Encrypted: i=1; AJvYcCUnKONaU6Nu8smKLOfS4ezzEDblRm2lstaanyoq9Rfr2iR6uQypaAhJFhY6i2aZaYLuMEvQcw0E5K71+z2ibMInmob5C44jNUjnfq5wvpmVzIgFp7iW2ET1SDS/DFqagRmGw66vCf0RxLYrK2KAD+T6DepForZulefbUCsW46K+e/4BxCmDpq0SRHT05oSsvkwea+ZAob14JGHq9tAk7pR3THTEZKhZkg== X-Gm-Message-State: AOJu0YyLq8fi13jBwHD7FOf5Xot+UygwCeTENjP+zwpx78prsCT8peGe 5KO1wERCLwpfDilLep4k7WTho/Ya/C2DGdJ2Blb4a2yIgEyjAj+Y X-Received: by 2002:a05:620a:1d99:b0:78a:45b9:c96f with SMTP id pj25-20020a05620a1d9900b0078a45b9c96fmr8386956qkn.59.1711421476022; Mon, 25 Mar 2024 19:51:16 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id f23-20020ae9ea17000000b00789e800c204sm2642313qkg.62.2024.03.25.19.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 19:51:15 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfauth.nyi.internal (Postfix) with ESMTP id 6C02F1200032; Mon, 25 Mar 2024 22:51:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 25 Mar 2024 22:51:14 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudduvddgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpedvudfgheeikeehiedugfdugfegjeegvdelteeffeejfefgkeduteekgfev keeitdenucffohhmrghinhepthhrvggslhhighdrohhrghenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhht hhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquh hnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Mar 2024 22:51:12 -0400 (EDT) Date: Mon, 25 Mar 2024 19:51:11 -0700 From: Boqun Feng To: "Dr. David Alan Gilbert" Cc: Linus Torvalds , Kent Overstreet , Philipp Stanner , 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 , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Mar 26, 2024 at 12:05:48AM +0000, Dr. David Alan Gilbert wrote: > * Linus Torvalds (torvalds@linux-foundation.org) wrote: > > > > > IOW, the whole access size problem that Boqun described is > > *inherently* tied to the fact that the C++ and Rust memory model is > > badly designed from the wrong principles. > > > > Instead of designing it as a "this is an atomic object that you can do > > these operations on", it should have been "this is an atomic access, > > and you can use this simple object model to have the compiler generate > > the accesses for you". > > Isn't one of the aims of the Rust/C++ idea that you can't forget to access > a shared piece of data atomically? > > If you want to have 'atomic accesses' explicitly, how do you tell the compiler > what you can use them on, and when it should stop you mixing them with > normal accesses on the same object? > Well, you can just wrap it in your own atomic types, can't you? If the atomic primitives that a language provides is access-based, users can create their own atomic types or language can provide via standard library, but mixed usage is still allowed when it makes sense (debug functionality, low level concurrent code that utilizes races, etc.) But if the atomic primitives that a language provides is type-based, then you're limited to what you can do. It might be totally fine as Linus pointed out, if you just write a portable library, and don't want to care about architectural details. But that's not the case in Linux kernel. Regards, Boqun > Dave > > > This is why I claim that LKMM is fundamentally better. It didn't start > > out from a bass-ackwards starting point of marking objects "atomic". > > > > And yes, the LKMM is a bit awkward, because we don't have the > > shorthands, so you have to write out "atomic_read()" and friends. > > > > Tough. It's better to be correct than to be simple. > > > > Linus > > > -- > -----Open up your eyes, open up your mind, open up your code ------- > / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ > \ dave @ treblig.org | | In Hex / > \ _________________________|_____ http://www.treblig.org |_______/