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 B1D45C47DD9 for ; Wed, 27 Mar 2024 22:41:09 +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=i1j4oWbmDRPrGrMmVpypQXZcR9qUmQxByd5hPsMIFMc=; b=yNT/BFgbTa98+B TReN+i20/JuO6rpT0Sw0K2rPnNgtjwFw/Y+ZhzvAUU/ppO7vQUgC/qreJKsk5fgoS1keyvjPhyhJD aT5Pgml5xPSdyArCpL47h6RE7W7ueP1EKDxLXc+9wYc3EfYoEpD4fH+PkpNx1c+YXiCW27akZqq7A q/MXz9yo4mEaUD3Twrv7oHGt2efaOU+/DdAA9gZBRxVcmmMmThHOdC1b5BuA6nV7G9UklBwebdh1s vMbNeOLxoEyeNtfIAxPvuD89YHmqaqscWscVV9RpzSVStoMNxbFntcubMzwvmlk099KbIWTQLeit4 MDQMmKZf+qNTGhicmueg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpbx3-0000000BSGE-1LeL; Wed, 27 Mar 2024 22:40:57 +0000 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpbx1-0000000BSFN-0kje for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 22:40:56 +0000 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-5a4a14c52fcso178249eaf.1 for ; Wed, 27 Mar 2024 15:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711579252; x=1712184052; 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=wwkzJWECmlG16QHW6cdxBA+RFUUXDB2JZzSWnyJ9i9M=; b=iNZunEFnjzwXohuouOENQZ6c/zLuRZITei0FQLTcje58AU77tfKtddIEkEODC2rdJ5 OIXjn+MeqhS08j8X5aeNEjsicqAjdB+WnC69flM35sv5bRLS46ml7VfKnaw+gqGoviAt CNLyw20nIpeq0XaDWh6nNmLJ2BlPOJ5Y0Un9Eyj6bPCBm5H3j7MHPf+n0khGR4YDy/Mu XzJ8xY5X8NdnaDxFr+S/wNjhfIlRl/Ho0gDogbcIoJ0KRa8w4V/IPazwpKohJjebxZm/ vURptAAbaImPf+OQRxdZCR1nYIursKI0KgvBkobD3xHlE+rngffDGB1QmdEdGoivttdT bORA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711579252; x=1712184052; 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=wwkzJWECmlG16QHW6cdxBA+RFUUXDB2JZzSWnyJ9i9M=; b=MwvsqC04PfFTNPIfa6SeQXPCuBjb3QDlvA2EUvdBvLLPPlZ6ObCkcJze7rL5ha8JXh Ks2vErkGSJ6n8npD13lB1QDehHcDaWfV7QL+i5j/nzKSSpcu9eTGFFd8xyw3Ro1sVPx2 Sic9WTXvxwZd+Xuju8M37AbFg24U9rVKeZvQntEf/8+AwBKzZkoSluVsDev0sjGyiYO5 f78Z5YALRG5Tx5FrE2UI/70ozmH41vvo/baCl6H6FPb8PzCYQhw0k+rtty+YITS92ZBK hzN+rAGWot+0GrNySV0WksQXaa8BLhyF0lP89DyWPcGXwHcf9wBiHdvXy4eHTdQXm8kn Eb7w== X-Forwarded-Encrypted: i=1; AJvYcCV9DHJ7vcIeoFNzVStEm2DSuvLwrrEXipztyBoO0nyrFnKbSlkSy8LQhiYJbAGZ/s5ViMU8RBvdOuGGrQ29T0dAfgJa35mhl4q0tSGh6y/riiOpxPw= X-Gm-Message-State: AOJu0Yx2upVaBsWNQ7HM/h3PsXV8u9yyqCYWVPylQw5XpbkaS1FPONiP FqNv8itQ8G2xX1jXt0gmqUiOdsNAkdDrBm2B0UIlUdcoN3Aa0CrMGhLnQgDq0i8= X-Google-Smtp-Source: AGHT+IHGjWRkib9W0zZ7sBiv2+oNDjTn8vPgkUQXGuUBpsO88nnHMrIhshfeJQFgUjASDsrFPq59RQ== X-Received: by 2002:a05:6808:1920:b0:3c3:bc13:2ef6 with SMTP id bf32-20020a056808192000b003c3bc132ef6mr1745797oib.43.1711578408539; Wed, 27 Mar 2024 15:26:48 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id cb9-20020a05622a1f8900b00430b907c234sm44446qtb.26.2024.03.27.15.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 15:26:47 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfauth.nyi.internal (Postfix) with ESMTP id BFF2F1200032; Wed, 27 Mar 2024 18:26:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 27 Mar 2024 18:26:46 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudduiedgudefiecutefuodetggdotefrod 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 18:26:44 -0400 (EDT) Date: Wed, 27 Mar 2024 15:26:07 -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_154055_232296_E34DC4CC X-CRM114-Status: GOOD ( 23.47 ) 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 05:49:41PM -0400, Kent Overstreet wrote: [...] > > > 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. > > That's not really a workable rule because in practice every data > structure has unsafe Rust underneath. Strict aliasing would mean that I don't follow, a plain data structure like: struct Point { x: i64, y: i64 } doesn't have any unsafe Rust underneath I think. > unsafe Rust very much has to follow the aliasing rules too. > The point I was trying to say, the aliasing rule on Rust raw pointers is relatively relaxed compared to strict aliasing in C since Rust has references which should have more accurate informatio on aliasing. (but not a language expert). Regards, Boqun _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel