Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp54726lqh; Wed, 27 Mar 2024 14:42:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaZVTog5v0UMz+evw3ai/nc0Y0QxJSJf9ULdb6FLIpjqnEBOBO2vstQ1CRGDFKKcShHDpda7xAYI0GCsK9lJWRNxRXGZkVJwyqJ3r4NQ== X-Google-Smtp-Source: AGHT+IFstZfYteh9EL41d6efPvYvisOBhEV5wSJgtJojUgrero4feGoQCUktxiFtImh4eEDY+S6Z X-Received: by 2002:a2e:3806:0:b0:2d6:a9be:19d with SMTP id f6-20020a2e3806000000b002d6a9be019dmr508544lja.27.1711575731640; Wed, 27 Mar 2024 14:42:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711575731; cv=pass; d=google.com; s=arc-20160816; b=QGoUIfj6nu3+Z+gcTIALaD37aXPez67lhZtjkVi2hUubIhMSMRPFTV9XkVbMmbIDrM c4HHzb1okSRqqM9T4hHNu+Mcl46pUOLd+py2bWzSpvf8qnn+It5Od+BLzSGhDmd2tEM3 ndvXFrozGvSy77RYoNzyEiOWj5k+LkUVSX3lXnrw7MMB9WBgZjVXfUjkGMwfDdU/ljJD T8idox9qgb09qqqwWuAExNhKSAEgEDCfcGfYP7CyyRPSFSpsj/doz7l/Dp+5BSYP/npe UEE5JnIyvMKwn7dqZz5FPw6jyfXt/By/MnwqfcVq1s0U14vYr5A/FvQta11pO9eQICly lbAA== 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=dfpvhmi8rKro1b2dyL3uY2Ed1/z/apHoJwqWNRmO5B4=; fh=SOmxtNc7LNDORXxo+Uy7824nbgK7IimSMOBleLXjwco=; b=O//zVM3NTTUyUtdL2zYggoih/eXs+oAlzmiAwNWr4vN15Wrlk6MxZtki2zuhDDkUb9 pRsllXPGM0rlD24i8cwBArCFsZi7as7dRagGaiPst03r6fIFApJDyCuh0X9N0RKD1HaJ vdpZ8DDqKG+uxwERydExYuQFOQ7T/Q/s8yqEou21ayfeu4xqXbVyMvCZk5GroVxWlI1+ zE3UsqKdxIQIeNNQzrE+z/5/e5YiROwV01vf4z3G5ILofmS/KztkY8xhkzmJYXQKtXGU 9hR0ocuIbaDYME+Te9zbvQJ7mysIjmKmOEtx3sFqUnbOvIfKqzhmjCqXZGptsHKcuIzl ejsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=P9fz0LZ6; 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-122041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i21-20020a50d755000000b0056be88a1eb8si44551edj.133.2024.03.27.14.42.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 14:42:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=P9fz0LZ6; 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-122041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122041-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 181B81F2517B for ; Wed, 27 Mar 2024 21:42:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 340C915381D; Wed, 27 Mar 2024 21:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="P9fz0LZ6" Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.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 4601115359D; Wed, 27 Mar 2024 21:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711575716; cv=none; b=oANa7k0tNGRTs52yyYGE4EOGW/ffk83alwdY/KLbr8JC+xlVN/i1dYJFToDXdACsXsHIAJnM+1DBqwLt5M1Ge5VR9Un/9pP91NwmY1XraSjjggiRotdoyzCxcj8WHed01DgYBdZt/tcTHS2B9cvvIbZtEBUkEwkcXf87TyuI2to= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711575716; c=relaxed/simple; bh=Ka4yhsa8pA7IN8JWhrFeenVCI3gTYxePnH/a155TeVE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n6JkD5zNzAxJe6z3yVu174hXuzi9ffWbD5CPwlfsYxGbR5/QQ7dDeoQBLgI0pSU5EhXNVfM8OgqEkhqgNXWljbHRnCVZRfsojX8BCE8xHqUklktSsAgKvph26AS880MO4Z1gko95XE6o7v5mIHuMkaYXlC9rCZpxXVkdA/k9DHI= 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=P9fz0LZ6; arc=none smtp.client-ip=91.218.175.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 17:41:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1711575711; 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=dfpvhmi8rKro1b2dyL3uY2Ed1/z/apHoJwqWNRmO5B4=; b=P9fz0LZ6KX4HbsV78Toh0xVvAAPtEhIh/vnyagTO6/lh+tTBkoFPRjJ/AFAokCzLbmN29U CulIj0vF4mNJoUBAND7yLvIraMiM91VioMqDNlE8vn0vuML+CofPaw07zpuXQQmW+GZP2G 68JzFd6/7l4lnSoUl7RV9RRY1Pn48F8= 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 01:45:46PM -0700, Linus Torvalds wrote: > 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 Yeah, I was being a bit dramatic given the current state of the world - OOO machines _mostly_ do a reasonable job of hiding the negative effects of this (although not always, when memory barriers are involved). But I think this is going to become important again in the future, for a couple reasons. On the hardware end, the Mill guys were pointing out years ago that register renaming is a big power bottleneck in modern processors; the actual functional units consume practically nothing compared to just moving data around. They never built anything, but there's at least one new startup I know of that's continuing their work. Yes, VLIW has been a bust repeatedly, but as we keep going wider and wider (because what else are we going to do?) I think it's going to happen eventually. On the compiler side, I'm taking the long view: it's really not just about a few reloads here and there, it's that you fundamentally can't do that much with code that's mutating arbitrary state; analysis that optimizations depend on is impossible. In the compiler you really want to be working with code that's pure functional - then all your optimizations are just algebra. And internally, compilers do this as much as they can (SSA form...), but - unrestricted pointers really put a limit on what they can do. The beautiful thing about Rust to me is that we finally might have a path out of this; the rules of Rust references constrain mutability in such a way that's almost as good as being purely functional, yet it's something we can actually do systems programming with. I think this is going to lead to substantially better code optimization in the future, and based on a much more sound model that means we won't constantly be fighting with compiler people because they're doing shady shit and breaking previously working code. Based on my experiences with writing iterator heavy code in both C and Rust, I think it already is.