Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp824212rba; Wed, 27 Mar 2024 12:57:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV75Rr9su9GR/PReuZPB7B3L6AnuBerK+1dtEZK/TE5R+65c8qJDeswyKDPDbzTLhqaM7JhORIRAOfefOS9AmtyCA3XEQQqdfGmrgLPQw== X-Google-Smtp-Source: AGHT+IEAQr0uxONYO8HlwZUxb0JWFaId9rhMSOdPYH2QpkM7Kl3OJc0nkP6hN5KZrFuKX8skI9++ X-Received: by 2002:a05:6358:3423:b0:17b:85ff:8fe6 with SMTP id h35-20020a056358342300b0017b85ff8fe6mr443871rwd.25.1711569431226; Wed, 27 Mar 2024 12:57:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711569431; cv=pass; d=google.com; s=arc-20160816; b=1LHRS3wN3/7i5uHg6Ibla4XGBVtbHhO5WBAAQsO1UWQE+ibR+Jfx4ESM8WCVCVeOau 3ZrBKXkfd2rHuD0+RkdLlPgkJOlBOWHSZV8x3n4aMO8C7ODrByNe+ZhoBmOUoXHEHfsj PY6zOXp/NoKBOjHHb+iaJnW3sqpwjsfQKxa4afBGSqwkROLdcQAjEj/L5Z/OOivrqoyW u6LbUcXA8mfAuZ2TaWssu5Y3OMPu6NiLaUkiQCVe4yxmCN6F4F2Icfh115Iuna0WPEC0 Iif422w5gupSGUC+GpBKiqc6B912nWi5jB/iMW8ieYrJACVSbQ7BoCEM9UfpwJgbxiHo d3lQ== 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:dkim-signature:date; bh=Zm/x/ZeAIuXqSrAULm8c6bXhsoD6FLOm8Awi8FqLz6Y=; fh=SOmxtNc7LNDORXxo+Uy7824nbgK7IimSMOBleLXjwco=; b=1CJuCEj/BXj0vnuDxJLQL4XLqzhfU814iDh4w8f06942VoEU1vfuITG5jvw05pLAwi K6rjHY22A2dsE+UeIOtR8wIyupU2Gh1RG47kgPDdpLi/InJQ3pgHxZaGwJdTx1VLjm9Z fLd2fB+S+928m7q25fz9yCQhT/mCqHonsToa+t2uFD+qwem/BgiiN9DOvBEDw08DS08v OMFu+c9EnCrq1LJ496h/Do8wQ/675kzfq1ohRNuG7UspFKHBnewrRei7htYOSVWTj0Zl CpYWs01UynDl+56AfRIAGRFdRxKg1TwwYA4wHKd742jY+tpiB+pG9KOa1WqD1n6T9G7t V++w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xGJUKen3; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-121918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121918-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j2-20020a63e742000000b005dc8b2148ccsi11857928pgk.836.2024.03.27.12.57.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 12:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xGJUKen3; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-121918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121918-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C3081B24982 for ; Wed, 27 Mar 2024 19:41:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EB5D152519; Wed, 27 Mar 2024 19:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="xGJUKen3" Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20FBE150995 for ; Wed, 27 Mar 2024 19:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711568488; cv=none; b=XP2WRjgGbyDiIl+UOaMJRSt7UWmjBEwQ+9PCGhVZj+rF780g/jHnocT1Z+YXPe9HTAKYkIsJoL3iRdT8/3i4zlNOVLU5no2Jj6feoquEcYHVch407qGY7U+z4mmHfCDkzZmUwlBonKql67PEBcbDpPfB04pNdNKsCkRCtkJObh4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711568488; c=relaxed/simple; bh=DbVcT/GqVrdr44Z2rkufZ1Y6/S3nUoKZvEfChOqWVTA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=i3zeDGBvM/4ZgNJajbklymfu4WftxWv4hWiSl7CWSdj9cpwtuMKPVXNcmY/OhBJ7pBzG61LSFlVRA9wRSekeVBW+HDMoonXM1rm9NC1uKzupveUyYrR3xSLIHnoXUT8YHgOLbMJh7Vi1LxNs159eiJbooN6GxrZ6XShl/WSohF0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xGJUKen3; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Wed, 27 Mar 2024 15:41:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1711568485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Zm/x/ZeAIuXqSrAULm8c6bXhsoD6FLOm8Awi8FqLz6Y=; b=xGJUKen3fF2NY5gK5gpmGfgRcLbRzTst3KLdtG0DG3xf2Zy93WUNxRSNINO5KHYTBg7ECe g2kaRTQd4bv4SvMaERqJlXyz6eXnbNKoRvXc8XITJEWQSA5ijJkdax3Z89kkvyEghf0E8T JAp3GAHAsmWigw+JmlVQE1cCYwIy05A= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Linus Torvalds Cc: comex , "Dr. David Alan Gilbert" , Philipp Stanner , Boqun Feng , 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 , =?utf-8?B?QmrDtnJu?= 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> 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: X-Migadu-Flow: FLOW_OUT 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 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.