Received: by 2002:ab2:5182:0:b0:1f4:61d5:3ad4 with SMTP id x2csp79457lqi; Fri, 5 Apr 2024 10:14:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX3eC3VFqGIONv0zRG4ZC0j6dOiDpibtQIH+guGCwHa2CzPKD++Uj8/Nrdv/rbJqTMlD0aeWVtsViXi7gEV29Y6fZutxTMf/fXSzRxHPg== X-Google-Smtp-Source: AGHT+IFRaplaCBAhiGWhP7I9Ez8SXfotksKWzq/q0UAYQk//tgC28cQ3Vu1eLff7ElChxdahEA+s X-Received: by 2002:a05:6a00:1acc:b0:6ea:92e3:bd5b with SMTP id f12-20020a056a001acc00b006ea92e3bd5bmr2420441pfv.15.1712337291499; Fri, 05 Apr 2024 10:14:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712337291; cv=pass; d=google.com; s=arc-20160816; b=JcuReJLXyv5XiqXZjyodBycmngPLW4MHT3Wh5c0FYCsQ9FN9T+AtETNxcGV4cdTdM4 Tz2Mc6L+vN2wtYhidU2ZlABdoPPQ0awLAZyXpgAlxqhcGiy+zcW0/DaiKEsjKjCGIypV o72jbamx1nY10GOY+dE5rgJHb7G7q0G9N4oMuz56zyGMA0obl5/tzze/ZS16e0q8Zc1q GpLcm99V1qnnlEH5j+SvInwAYSs3fYkVOp4ZlkDuEDCXADi4569pjv05laGdV5SiVf+F hmQcc5uzEtYNV2rqrX1jxfDDzkSL3sVbo1l7oaKYyrQINJ2SFmMsQwyFx9cqPUkcVwKh aqtw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=lPpM0wT4yWeklYwKPrb4XynteXC/5k41kP/uRm4NnA0=; fh=XRFny8D9C52Fm5natuR+A2aEaJ2411XiXPUEPW/dKmY=; b=Q3++QxudR3xfUT6iAcGHN2owbmYfGKq/8lSMk15oK9VeCzenlb4N4sWXHh6ofpDs9r FKH5SADxBZZCDFSDBN6RR5XNlfSqXCb8IpQhrBsMjwLQBTLlko3N2TPDHsrgv9XL0mw4 Ks+JINCIl/nLF/VLfiMypRqmeu5T8/HvqVtNfCnMLz++Cva7yTfZoastTqnWgcaWRG+J uLTVWBhY4irzKH0xvXZHPclAJpNrcneOLQYgGGn4SNu9r0qeh7QPkt0J3+1izsXrBNQ7 75v/O0Wygpzv32KhJ98qCvG1YFL9oslnXdrguI/1kGwyJOrIycPjguFZ4hFuZbSlJElU w/Wg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C3KuxGcD; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-133411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q13-20020a631f4d000000b005dc42946a85si1640202pgm.214.2024.04.05.10.14.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 10:14:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C3KuxGcD; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-133411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A9359282363 for ; Fri, 5 Apr 2024 17:14:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1818E171654; Fri, 5 Apr 2024 17:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="C3KuxGcD" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 6F99D1E494 for ; Fri, 5 Apr 2024 17:13:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712337235; cv=none; b=D2zlyXp2EGzoe6PXvDyngzosn7Me6+UqTXtoJ+ElRSkJ39TuvEVmbyoGy+tGGYAL/cKytpgNI1rw8y1ooZ9tGJJ2C5Kqv4laPEU9yZfyaHSyYpRTpdY5Jb+abpjcqR+fcaoD/KMb8OfQ8ut0Td1ruBg4mGyRWyfsyAN/gQHyeuY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712337235; c=relaxed/simple; bh=lPpM0wT4yWeklYwKPrb4XynteXC/5k41kP/uRm4NnA0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=h3zNvO6Rz9axNz+Izz1V0yQCNa8kGoJmOHGB42q8loiQBXtuFxwNuSrzL3j56yq7k+bAf/Yyzn5X1Cc1GP0T5KUyPQl3cJTz4GAX4lknf9SAFPIy0pCWAlwg2YP9DLWEoWVfUN1+MKSNNolUVgkcldOCwlTcLz/31hZoSQbFJ+A= 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=C3KuxGcD; arc=none smtp.client-ip=170.10.133.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712337232; 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=C3KuxGcDk8a/F2LtBBiz0Hd0oqcwc/5AFL3d3D0o9wwz67u5xXrd/mLwxFmnwi9N+CH44S RGdsRBZEgPg5eo8BuW06z3dXjOqh5r3HdKX7GaP69/n5EsRS4GXYwEmH2xAAl1gKaCv61K rMYVRM1dkeR7/ubX3/cvnMyIZYlefI8= 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-28-5_USE4OcN4izObdXd8KhXg-1; Fri, 05 Apr 2024 13:13:51 -0400 X-MC-Unique: 5_USE4OcN4izObdXd8KhXg-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2d871ee2f2cso560741fa.0 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=kG8dmoLlrrXrYWIIwalhMooIhf3xe1qLlXPGBhzDxaMXSThrgIh2i0/IwLS7TiFgPj UjCBpiFWhK0Y7KRj4wVP42XbdJQ7FySXnDtBguqAJY6rjMsf8ZV0YWEYP3ARKKuWexkR dznQQkWKOuPfkWlOevGimJhUTiY2fJjgrsg8gTrPJtXO2Ld4Zx8u1YgIq62nk3bbNS3r V7Exyp4AS+ptU14NJjjCAGr7vjU/vSavlFox6/opqMps1fnYvKSqdcP+A1pUmixgrB+q ZJ2mQMTl7b/6QGd0QipxyWBfyzeZVHvbUcbDv/15tscBWahSPnb+VVNEmwH0nTJPgi6R pyFw== X-Forwarded-Encrypted: i=1; AJvYcCXxCmD3UtfSfK15Pm7FEj+1WRAdksTFDvMx6B0Kp2ctTtEC9Iy8oCVsWPtDbdBj/57wy7AjLXMhEryd4MrmMLx549wDwiq/zsjqye3f X-Gm-Message-State: AOJu0Yy+ebh7jIIeLFAAeX5LwklmJu+2FFLcofFszp5z8TRLuYnaNLwI aBcj19nUi1a9TGqHW5pmIKR9EocYaF3TX26GACG1120ZMnNndw9dHmowW22yKRzFtlOiNPDj6eC BMjLKb3uCIRLLAniagjTSo88fb2awmeMbaRI7zRENEtnQ5R1QJz99vRk7pCLnxA== X-Received: by 2002:a2e:8095:0:b0:2d6:c59e:37bd with SMTP id i21-20020a2e8095000000b002d6c59e37bdmr1535987ljg.3.1712337228337; Fri, 05 Apr 2024 10:13:48 -0700 (PDT) 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> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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