Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp29269lqh; Wed, 27 Mar 2024 13:46:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaEzbzgkoqKF82tO/LoXXWqS9oL/xam/Pxp+V2uIhKPb68It/WOY9SRajj0JNBUxhwEFHy+cq4IdYy/Mrn6Zqjk4q3vw2a3/AIIYSF6Q== X-Google-Smtp-Source: AGHT+IFDIZQXPYhk4XhOlxgZjMrExh3PrpFkzeSC3UTOhYEVLXmfMPQGt06IREmCJNO9aWQ6P7ib X-Received: by 2002:a05:622a:201:b0:431:482d:b71b with SMTP id b1-20020a05622a020100b00431482db71bmr770529qtx.13.1711572389614; Wed, 27 Mar 2024 13:46:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711572389; cv=pass; d=google.com; s=arc-20160816; b=boJyfywaz6stmx3slY8nEeDfMDSxQNCO3JzscAJvAgExjN0vKY4drUI5fgO+v4L5+W 9wf5AxIgoUSGJCrzIz+rHjxqtA96UcuIvMUonRP9kGwYiBwmOqeRzu9TeI/vC10k0Ikq MdEqtugAeE7BqfADcYH5kcKrttjWkzREX00X4Js119gqY7VAEw2QENElPzrmONRTQ7wE 1LVMt0VwUcGqdV3eAWIC9XP5ZvGyZRrJu+S0NTVQ6tYwr7Y8HmiF1ph/61uCQpsVRC6c NDSz7IPnqJ45GCfrIjb3cFFWgAOHzrX1Da5qWbejbNX/aQRPfet0oFaKUe1lbExCWoVE X91g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=MmaskrdbVq30uGRTY87iYuCKuy48OuaJH0qBlabGSIs=; fh=V8HzzFGMB65BVo+e8gAP2zK2RxpZXVLZwBbh6k/JsJc=; b=ZiLZ96Z6/U6eDVwG0zrf/EWkYb1UAnKb6gV6UhuQiMbalfMU5mrQNSvHT2cDqpDJjU sFoJdUDhS2rUVS9D3NTLcghmyMP7R/v7LEaa1ii6iW05PoDGZY8Y1+6xMCNOgv4OThba 1zA/7Erg4LwGdQ8lAb5OBnrLZQguHmEnizt+mKu+yXe955GfyfV7JQLlbstGNHIR1xCe SQX7D/BAzVTUYbBVHjvexwYh7HAS7ilsVlJfn21YTFCav6GC/Hn9+AbWKMT8A6J7tvml j7Ud39yvngC78d1FAr5HaFHLOVi8P7J93ax8EIxHuHoTBJ4f/imA1QgOpbhDMyEhhJ2E MC+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=XQs1giFI; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-121994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121994-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z13-20020ac87f8d000000b0043180cb79easi1717950qtj.189.2024.03.27.13.46.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:46:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=XQs1giFI; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-121994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121994-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4BF361C2F856 for ; Wed, 27 Mar 2024 20:46:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0A53152190; Wed, 27 Mar 2024 20:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="XQs1giFI" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67D4154FAC for ; Wed, 27 Mar 2024 20:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711572368; cv=none; b=J2JLTZv8PQ5l26OF8TESYwEETSJEv1AVKkqoMPivJONOYzYIJFgI5DHe5NJlgial7URB7HUIrPyxWxDHByYXdj88PFP7EahMCP3wENiJwnQco62lgh/uUvQ9l78abwspJQbB1bYT3z5PcocJBVL0RKYrjnJRFNKsdc/vfUB1xMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711572368; c=relaxed/simple; bh=RuCWKtbRzqJIEwrREMPn1YstKGaBmUG9LovdmLij8Z8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=li8OF1PMQLnx+g0SBEv7y3WObZZDClwT521JbLBqkgE2wbcierzzSWaObu//utCIxHwcnsecB4SEzqvL98MdjdiaY5E1DrU/JmTXvqnoypxl0WTN9a90/77bdD/k3oq4n2mFfG0Tja/6+jPh0rTFEIAfjwh1rHCeMUtXl0u2lM0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=XQs1giFI; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a46ea03c2a5so53390366b.1 for ; Wed, 27 Mar 2024 13:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1711572364; x=1712177164; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=MmaskrdbVq30uGRTY87iYuCKuy48OuaJH0qBlabGSIs=; b=XQs1giFI0J7NNsHsOw1S0RiylIk496XuMsErC2d87/QnQFjQTx5gtNc0K/3Yk9hl68 ZUvO2xXWqcVUgIBbyh1gxXriBGxVmi3P94cxDNW7IgVhRjBvKiARHyu3/ctnwoqPIg1D CKTV9dFnMOp89PMnaqnm0LYnfYRRJ4Ef5gbQQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711572364; x=1712177164; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MmaskrdbVq30uGRTY87iYuCKuy48OuaJH0qBlabGSIs=; b=jUpNHX0r1r3LTnRSgfsqrK5TBAz99x/uj+poG9qnq1AB+yFVTVLBEwKRsztYinwKlS T3Wt6UzjPohlg6F4/iSGuX3RkVa9zAPgqVGJcIduMrq2n680wnY0LmrL0H8Eu8guUxvc x3XX8ly7S0OculPyHAGosKeSb2aT5XBx4Avyhfyvniqa1N4CDe6YR4HRy95Hp2bLeRnU dKT+Ws5njQ5QXbVkLM1a8frFG1L1iKxFHVSLtLACTrxvlWaJtRlsX/b6zOurEDcENYT0 75LUurc4mBHftdJsxQmHyZWmicITXrtGz9C6djVOcdFyH+XdWSoO3ufa72ev8lBLG7ow PgNQ== X-Forwarded-Encrypted: i=1; AJvYcCVtPTgYei0oGZiPADPlGJ/6Umc6lL3MRsaCZsRr++DRWAXlbIVKOKyY37xfNybcTTH3u5CSDiWWMfP0gEoD43PZ0RS/rjx7IhaHHjPw X-Gm-Message-State: AOJu0YxFivO2+V/yE7Gx4HKqLswzjYHGJRH4m3fgM27fRHcjAcE80cdN EYxoYIbGkqeFsO16sI4xOgH1zOzqqQA3+hRspzVq9DugWZOasxzy9d7LCx0HbG9QU3DD3l2CvT/ xc4KJiQ== X-Received: by 2002:a17:906:b848:b0:a4e:d1b:efb1 with SMTP id ga8-20020a170906b84800b00a4e0d1befb1mr388922ejb.5.1711572364577; Wed, 27 Mar 2024 13:46:04 -0700 (PDT) Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com. [209.85.218.52]) by smtp.gmail.com with ESMTPSA id l12-20020a1709062a8c00b00a45f39b2d16sm5854505eje.200.2024.03.27.13.46.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Mar 2024 13:46:03 -0700 (PDT) Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a47385a4379so245274066b.0 for ; Wed, 27 Mar 2024 13:46:03 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCV1WQFU6lLaIjcRMFB0w9IYJ+0g1HQEQfJQ0zwIenaPdVwYXJWptobQZjhLRkdGX9GUWf++JoYKH6tIa2o2KKv8hupFS09x5q/LBAwH X-Received: by 2002:a17:906:ca59:b0:a45:40e4:8c8 with SMTP id jx25-20020a170906ca5900b00a4540e408c8mr355615ejb.16.1711572362918; Wed, 27 Mar 2024 13:46:02 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <160DB953-1588-418E-A490-381009CD8DE0@gmail.com> In-Reply-To: From: Linus Torvalds Date: Wed, 27 Mar 2024 13:45:46 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [WIP 0/3] Memory model and atomic API in Rust To: Kent Overstreet 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?Q?Bj=C3=B6rn_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 Content-Type: text/plain; charset="UTF-8" On Wed, 27 Mar 2024 at 12:41, Kent Overstreet wrote: > > _But_: the lack of any aliasing guarantees means that writing through > any pointer can invalidate practically anything, and this is a real > problem. It's actually much less of a problem than you make it out to be. A lot of common aliasing information is statically visible (offsets off the same struct pointer etc). The big problems tend to be (a) old in-order hardware that really wants the compiler to schedule memory operations (b) vectorization and HPC and honestly, (a) is irrelevant, and (b) is where 'restrict' and actual real vector extensions come in. In fact, the type-based aliasing often doesn't help (because you have arrays of the same FP types), and so you really just need to tell the compiler that your arrays are disjoint. Yes, yes, possible aliasing means that the compiler won't generate nice-looking code in many situations and will end up reloading values from memory etc. AND NONE OF THAT MATTERS IN REALITY. Performance issues to a close approximation come from cache misses and branch mispredicts. The aliasing issue just isn't the horrendous issue people claim it is. It's most *definitely* not worth the absolute garbage that is C type-based aliasing. And yes, I do think it might be nice to have a nicer 'restrict' model, because yes, I look at the generated asm and I see the silly code generation too. But describing aliasing sanely in general is just hard (both for humans _and_ for some sane machine interface), and it's very very seldom worth the pain. Linus