From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 4C7ED171659 for ; Fri, 5 Apr 2024 17:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712337238; cv=none; b=FWagTxIBXZq9rKrTFWgy1oTF0mlAwYGgIKKPRwYWzkCvTwba7hIrd3QpXVtGuRpPCYlqPff2dsI0VhwiARjN5Hbpqzw0Bj42Vx1odouJUNFPWaQO4FlqgwxZw/tdkuJ9jAwczICcfWkM3E9gJrze/PoLOBnq8oFR8w8ZYAmmkKw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712337238; c=relaxed/simple; bh=lPpM0wT4yWeklYwKPrb4XynteXC/5k41kP/uRm4NnA0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: MIME-Version:Content-Type; b=ZHe4vhLujOwa7oOQYKQE5frx0Wx74eYX81EO214/f/DWz6rdYgpPGHg+5XB1wyHqXBjX1Ui9FOG/UOViDjiigkeRZxTd2ASGtf7qpIV1h7J+zx7+/l+Wt7N6ayn2kkS/mjdogPt8jv4YLGLQXz2a/+4MA883Y8yml66QVZy2QFA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BxL8UfFQ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BxL8UfFQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712337235; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lPpM0wT4yWeklYwKPrb4XynteXC/5k41kP/uRm4NnA0=; b=BxL8UfFQPRZGYsqZ6y9DV7p1NcPfwcF175mQvnstHeFnhUrcVZAT+lWWxumu0tzCoyDiKW MlaNvt+qWH69A9BmtdS61ywdktEWShF17n06H9ZrOOANTuTbFAGdWQqAKD2wRH2clJPZAp BaOjaUNWgKOKYZ5xNSZGBgUya/vPw0I= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-81-DQKjLUGrNlCT8yLr2vnI-Q-1; Fri, 05 Apr 2024 13:13:51 -0400 X-MC-Unique: DQKjLUGrNlCT8yLr2vnI-Q-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2d851a4d958so4441641fa.1 for ; Fri, 05 Apr 2024 10:13:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712337228; x=1712942028; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=lPpM0wT4yWeklYwKPrb4XynteXC/5k41kP/uRm4NnA0=; b=uM4EwxFDkDRQb370YaE30r5uSOm3emr5P12HdUcbp3QthNe/U5DG7wZn+AuTfGj5or JcFDKEB5XMf0eavlWcSfaa5TfxVJUIzkicNhrSrDTXtFQrxd4vTVtMAAthFQsN8ZlY5u bHENdJehpvigsfazqnOEKQ3RkUkHTWj0ll8TPqjgbyZJ1WBzr/ZJXyTnt30gzC0a2iM5 QrjkNiO5mTA1k6TklQUj9AePgpGYpdCx+ktU1BdDJVu53//BNtdYL4kraN0dGzu37MiZ qFK2aEtKSQ/YQ5rmWco6FRc9A5NIW/4DH+tqYTzSi1n/zWD7tkvawciQwAlYoLbkbxOi 6/+Q== X-Forwarded-Encrypted: i=1; AJvYcCWGTAfTdeSUr46mot7+VvX9dAGJqutM2vuqW7xPkeTz7qxsMAr+cNawNTP8tSuOiRdk8/AE4NySd4faaEeEBUu1zIaRgqZWoyFy4e1NvIY= X-Gm-Message-State: AOJu0Yxi/9fb9OhdUBypj6adAMavnGyWOQU6rXmWs5XMOJq1fFt+SZpp URU42QeiKPPH4kjdtw+LjSlrsmbsY1pErGRI3Ja6WYNQ6n0w7e/Ss7d0VFFTWpfwQh/xs6mNFv5 cI3gP2ijDQdm77JiwP4vmlCOXtVI91jpNz2weaG3VW6muIBHgWwLsAgVtHwgCvM4n X-Received: by 2002:a2e:8095:0:b0:2d6:c59e:37bd with SMTP id i21-20020a2e8095000000b002d6c59e37bdmr1535992ljg.3.1712337228338; Fri, 05 Apr 2024 10:13:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7mr/0zQsW+7ufXN8Cy1V8GjLrwfuTgftu9UYTsupPGSbHO+hK+Reby8puICIcwXAsNILmAA== X-Received: by 2002:a2e:8095:0:b0:2d6:c59e:37bd with SMTP id i21-20020a2e8095000000b002d6c59e37bdmr1535935ljg.3.1712337227885; Fri, 05 Apr 2024 10:13:47 -0700 (PDT) Received: from pstanner-thinkpadt14sgen1.remote.csb ([2001:9e8:32e2:c00:227b:d2ff:fe26:2a7a]) by smtp.gmail.com with ESMTPSA id d2-20020adffd82000000b00343e085fb89sm2317448wrr.2.2024.04.05.10.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 10:13:47 -0700 (PDT) Message-ID: <2aaca204c110d33025c3b4fd7e6f67b78d72ab59.camel@redhat.com> Subject: Re: [WIP 0/3] Memory model and atomic API in Rust From: Philipp Stanner To: Linus Torvalds , Kent Overstreet Cc: comex , "Dr. David Alan Gilbert" , 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 , =?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 Date: Fri, 05 Apr 2024 19:13:45 +0200 In-Reply-To: References: <160DB953-1588-418E-A490-381009CD8DE0@gmail.com> User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2024-03-27 at 12:07 -0700, Linus Torvalds wrote: > On Wed, 27 Mar 2024 at 11:51, Kent Overstreet > wrote: > >=20 > > On Wed, Mar 27, 2024 at 09:16:09AM -0700, comex wrote: > > > Meanwhile, Rust intentionally lacks strict aliasing. > >=20 > > 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? >=20 > Strict aliasing is a *horrible* mistake. >=20 > It's not even *remotely* "tackle this safely". It's the exact > opposite. It's completely broken. >=20 > Anybody who thinks strict aliasing is a good idea either >=20 > =C2=A0(a) doesn't understand what it means >=20 > =C2=A0(b) has been brainwashed by incompetent compiler people. >=20 > 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. >=20 > Nobody should ever do it. The fact that Rust doesn't do the C strict > aliasing is a good thing. Really. Btw, for the interested, that's a nice article on strict aliasing: https://blog.regehr.org/archives/1307 Dennis Ritchie, the Man Himself, back in the 1980s pushed back quite strongly on (different?) aliasing experiments: https://www.yodaiken.com/2021/03/19/dennis-ritchie-on-alias-analysis-in-the= -c-programming-language-1988/ No idea why they can't just leave C alone... It's not without reason that new languages like Zig and Hare want to freeze the language (standard) once they are released. P. >=20 > I suspect you have been fooled by the name. Because "strict aliasing" > sounds like a good thing. It sounds like "I know these strictly can't > alias". But despite that name, it's the complete opposite of that, > and > means "I will ignore actual real aliasing even if it exists, because > I > will make aliasing decisions on entirely made-up grounds". >=20 > Just say no to strict aliasing. Thankfully, there's an actual > compiler > flag for that: -fno-strict-aliasing. It should absolutely have been > the default. >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Linus >=20