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 C0934C47DD9 for ; Wed, 27 Mar 2024 21:22:02 +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=ve757OpW+WDRxqHx02kq71/TQl3rrLNKKQ/tGDDMWDs=; b=hUx3ysXYL9pKNF gx1KCUqpdoG021xr2gg6ifwgtBYca5aO2x2R7nX/UJS0hAiJ3XNnR3JQwTih7Jrelwdus7aTCgrHJ qNz1vOn45rFY+lHRS5FmF5dI1/2Rg3WIbtszJJCv6LmIe1mTL7ba90TIlw3F/zj6i5YDPzFWIc8Ud /Yp931ehtW3VdiKeeoIr5RTAsEJhu33DH/zZbAUrgahAF2PzfIwER5pniRDuaI8OwVjhFFQnZ1rCD 97tiZZ/xWTUTk4NnYMcghxaxwaPqY5irDZkWbGyVVCfMV/tQJ5oOHbYwLW+/y0oXp8SIxYL5+9976 er7u2ZSv6+eOqmHj0sIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpaiU-0000000BCWF-0Uie; Wed, 27 Mar 2024 21:21:50 +0000 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpaiR-0000000BCUn-1oGC for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 21:21:48 +0000 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6e677008501so167378a34.1 for ; Wed, 27 Mar 2024 14:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711574503; x=1712179303; 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=gPexr1qL1sWHkOO5VvKGmiwPJykaCN4OnZNa3Q9bZFY=; b=H5Ya2PzX295McGuhHW1yqjBcFcmf7B/4mCFBHTtGjMWU3dOC5mXToNCVCkxlGCBXtq 2S9/abK6gyd5tzyJs3WGmBarzP1wD56JS28QsjhErgLaLTDGh6OTLd58ji9FrcAp1OVX PXlzVG040ujGmU50CZrzVSTPp0P25NYDRzW63dkMsRisku7cL02cUp4bQaHEhuL2Qnw8 +Ktw2FatNBJlbsw50n0wpZObAO0kfqgOfAh5sDEhvmLVdfE4U2adEHnxQEUk9oc6exVn 6/uedIkJ7aLdxTlxDeHb2KJfkXV+Z9QNiaMdgZwJfrKviNLl0xCeinBzu47yTyLMNwRw 6bEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711574503; x=1712179303; 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=gPexr1qL1sWHkOO5VvKGmiwPJykaCN4OnZNa3Q9bZFY=; b=HpzsAyMvuILghLzNyZUUI+A5BA73c76M0vb1vSFlfJpORSfdP0zbSiQrKPqODHE4E2 dOcOmg9P1JoXCD6t3Cf4K8hvEQyQy1IYhOEA8H3I0SXSLpMkPdJa+yUMGcLzFBfpQDI7 JwyPOJkjO18pPcoMiwONJIckKsQUfp0F3ncOAfZ5h2BxnzdfPlOEiJsLQp2LndmIYzQk DKTIYqntUNVXyovaD42VDWQr5gAvl8+WfImCoDQOrXMYJ3iIOMYqEj748qr7Vmr2MK7c xFkleo5nkhwZVk7tOc5Nz9sVN0rcJcFAI3QKWD7ay70i5c0V3trbJinZVa0nkZMizrDu bhhw== X-Forwarded-Encrypted: i=1; AJvYcCVWJviI4Ygn8aYwXIZ5QsU2jYEzETWDbZ3b2yu1apwGfR1W1GDQB49dc8kAQ97UqQB8+0NXDHOH9T195OnvPv9qFqoQbBVflsZ83imeCQPABAzyLV4= X-Gm-Message-State: AOJu0YxcK2JqMiHHahjgEgrwETV01I7Ll8QFYkHqjsJJpwlB1RwwxUXq 9NDdhwUA3p+QLMQrOHY8xr4lXL92OPMRt676/kVHZ3IXLvJCgxGd X-Google-Smtp-Source: AGHT+IFwWxghWoZ03Kxvmq00ZJlmOcZRRjCIxBBmZTyM+9J4sTcFCpjAUAyRfv+g/a+r1EiNjL0Udw== X-Received: by 2002:a05:6830:11c6:b0:6e6:a6fb:7a11 with SMTP id v6-20020a05683011c600b006e6a6fb7a11mr1161746otq.6.1711574503519; Wed, 27 Mar 2024 14:21:43 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id b23-20020a05620a119700b0078a4590c62esm16536qkk.87.2024.03.27.14.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 14:21:43 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfauth.nyi.internal (Postfix) with ESMTP id AE07E120006E; Wed, 27 Mar 2024 17:21:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Wed, 27 Mar 2024 17:21:41 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudduiedguddvfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhephedugfduffffteeutddvheeuveelvdfhleelieevtdeguefhgeeuveei udffiedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedt ieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfh higihmvgdrnhgrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 27 Mar 2024 17:21:40 -0400 (EDT) Date: Wed, 27 Mar 2024 14:21:03 -0700 From: Boqun Feng To: Kent Overstreet Cc: Linus Torvalds , comex , "Dr. David Alan Gilbert" , Philipp Stanner , rust-for-linux , 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 , Marco Elver , 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: <160DB953-1588-418E-A490-381009CD8DE0@gmail.com> 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-20240327_142147_501412_563FEFFD X-CRM114-Status: GOOD ( 28.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 Wed, Mar 27, 2024 at 03:41:16PM -0400, Kent Overstreet wrote: > On Wed, Mar 27, 2024 at 12:07:26PM -0700, Linus Torvalds wrote: > > On Wed, 27 Mar 2024 at 11:51, Kent Overstreet wrote: > > > > > > On Wed, Mar 27, 2024 at 09:16:09AM -0700, comex wrote: > > > > Meanwhile, Rust intentionally lacks strict aliasing. > > > > > > I wasn't aware of this. Given that unrestricted pointers are a real > > > impediment to compiler optimization, I thought that with Rust we were > > > finally starting to nail down a concrete enough memory model to tackle > > > this safely. But I guess not? > > > > Strict aliasing is a *horrible* mistake. > > > > It's not even *remotely* "tackle this safely". It's the exact > > opposite. It's completely broken. > > > > Anybody who thinks strict aliasing is a good idea either > > > > (a) doesn't understand what it means > > > > (b) has been brainwashed by incompetent compiler people. > > > > it's a horrendous crock that was introduced by people who thought it > > was too complicated to write out "restrict" keywords, and that thought > > that "let's break old working programs and make it harder to write new > > programs" was a good idea. > > Strict aliasing is crap in C and C++ because we started out with > unrestricetd pointers, and it just doesn't work in C and C++ with the > realities of the kind of code we have to write, and we never got any > kind of a model that would have made it workable. Never mind trying to > graft that onto existing codebases... > > (Restrict was crap too... no scoping, nothing but a single f*cking > keyword? Who ever thought _that_ was going to work?) > > _But_: the lack of any aliasing guarantees means that writing through > any pointer can invalidate practically anything, and this is a real I don't know whether I'm 100% correct on this, but Rust has references, so things like "you have a unique reference to a part of memory, no one would touch it in the meanwhile" are represented by `&mut`, to get a `&mut` from a raw pointer, you need unsafe, where programmers can provide the reasoning of the safety of the accesses. More like "pointers can alias anyone but references cannot" to me. Regards, Boqun > problem. A lot of C programmers have stockholm syndrome when it comes to > this, we end up writing a lot of code in weirdly baroque and artificial > styles to partially work around this when we care about performance - > saving things into locals because at least the _stack_ generally can't > alias to avoid forced reloads, or passing and returning things by > reference instead of by value when that's _not the semantics we want_ > because otherwise the compiler is going to do an unnecessary copy - > again, that's fundamentally because of aliasing. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel