Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1479557lqp; Fri, 22 Mar 2024 17:13:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVe12JHesBy47AZdLCYQ2OLKRX8w4SaO8TPCmFiJ9gv1Wze6eDDmXOX+N6UdVhlm1f5f6n+pxDfiUC+OQ2h4PtjP0t6MxhqPL9eZdd3ag== X-Google-Smtp-Source: AGHT+IEQzyK0yEPLX2oFmUvRcmgotFt/Y7tSBrXmXayfdMVBtGyr/Z5wyqyhW58T+pSa3Xl8rVbA X-Received: by 2002:a19:2d5a:0:b0:513:2992:bd92 with SMTP id t26-20020a192d5a000000b005132992bd92mr503528lft.11.1711152782129; Fri, 22 Mar 2024 17:13:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711152782; cv=pass; d=google.com; s=arc-20160816; b=fikt2BGT6lyUHjV7wT72JIWMKov3wp5n8RVbOqITa5nNbcuJrxaSRIPHith4ig+1cV llv6dYM/cEmX8jCUGi22VVNWo/oEJN26ZzH1IZHRJzi3gj/S+syV+cVsOIJAAhTb3KaD E9khrX8mL96yEFREpf98Hqbqcd/l/fujLGBBgoz5/vJeQv4P0oMTy3S/VXThyTI8pbTb AuyUQAymENRNMg7k0dmtEWmoNtdwoHVnFkZpUTOsfrNMkaUr6drbpDoy/g06R17O9eJ7 QzgQTq4hAXN3Se/dOHMl79OsyjyzXDkCQKk5nBAzVMcDPGpLIldz+rqM8hT/CwObor5J 1IJA== 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=/DcKs5LOC+9m7c+sQfRFSymnyXVGhlvaNbRKaUaILEw=; fh=5OV7KLmK37MYWsO/NZJeWp6S4Azqeo0FOySnhEyZ/HI=; b=ZwcxPclbRE0o9lfWp93zJKdom1KKb9SwzO8hC7ZU0dDjuw9EmsOK3SHyZd+3np9ore +fCkUYjJCzc1yJ3uV16jxujF4/2ctzEvERWSvitz+mtrP70JuacR12JkJOlIlBgN+k5W xdM4esemuv6EFhBmlSSSUuz8Ig3b0R8LdDD04i5aruP38GqHDYcEaXBmZZxHI9GrnQKN h7x72rR6nxvFilqtPXl5AuKx3KHleCp9oe+UpZS+SRQR0OvH/Y0bJcCw9doQYG67f83X Ka2U0BIf9UC2cGs1odpxs+FAIYqD4CQn9xrwr4iQQVE1VsGUQkMTgS6W6Bqwbwe5JA+J 87Qg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Q6qapZI1; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-112124-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112124-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q18-20020a056402519200b005687b9310e7si298919edd.344.2024.03.22.17.13.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 17:13:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112124-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-foundation.org header.s=google header.b=Q6qapZI1; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-112124-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112124-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A28781F229F9 for ; Sat, 23 Mar 2024 00:13:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8531EC2; Sat, 23 Mar 2024 00:12:52 +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="Q6qapZI1" Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 ECAA537C for ; Sat, 23 Mar 2024 00:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711152771; cv=none; b=udiymNpjwVw/TZ/i7u92sUCrQ7+bsYR9WNGay7UAL9p+AnzFA8/EcmnQmp7VJmOV2HzJDsmf+66viAvppL172beJVxZIGpChcJ13gHZHzL17KUfb9LeyUARBoPsIfECFqrJxxTxG5xsIBwTYnkAJxDWC60J/DWBQs08pKVvM/y0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711152771; c=relaxed/simple; bh=buaytYj6XnQEMslfX8wQQCXJQT/19Ph5hoNeBiv9PMs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=VqvkkNlKTz2KyPixfl7/jK9yHu97AufDU2mCJ4+rSyR5BU0qU+s+c7fRbawRP+3/DlAYgb3/kz1xOq0B6OulXs8We40q3K2QK+CLzMHmpQQBQiKfKqVoLp0EkpPOdlWBaEGxaDel3UYcQbWMV2JDQSYtTjMEmt0+2AcECfx44zg= 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=Q6qapZI1; arc=none smtp.client-ip=209.85.208.42 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-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-56be4efb63fso1389286a12.1 for ; Fri, 22 Mar 2024 17:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1711152768; x=1711757568; 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=/DcKs5LOC+9m7c+sQfRFSymnyXVGhlvaNbRKaUaILEw=; b=Q6qapZI1NYRMQNNYtZidytYsBkiU2qaesQdjci/F7s0ZJE1Qj656NZyCKi8Jei6w0/ za8b07IjJ9Ry5yQLCiWdVLof2zCHQ74ZcG3zM5D7FRqUjFCtCzelfadqnnycszhSt822 trnFNO87MaVjDHsjBsPFvIHZw6nSBgRRLSvUg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711152768; x=1711757568; 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=/DcKs5LOC+9m7c+sQfRFSymnyXVGhlvaNbRKaUaILEw=; b=iCATbtWYXoYNe29PdDTKVPYANmfpLiUcbQ1dQ7YhxPzGcmAJFxeEWkV07fEfrbh1GK xYkimVemFy/jg+dT4a7GQ++8W5Y4YkcOHlm+fwueqeJCYtDZXrZ3aNx2X/FB0TbKWhpp 5TbLAky5EGHwtGmhUhiGGkZinNc7YFLdN9v4TdgJtWD0bHg1s8Bs9Oq5QS7ZPhEsHXL9 1suSoxx6fOAMr7Ryf7XaXQSIAFV1k3EqXwecSyk1at3Cv029QV/l77KtLXM2PXOL+4mS 4EvDSPInxHyt9ACZmuxHH7nn3hxYeO4QNZW0Zq2lrz3T8oQXxbkOSbEsZKrqRPPMyYP8 zyyQ== X-Forwarded-Encrypted: i=1; AJvYcCX6B52bc0U1XYvNpq2LmHIT0+bAdgZ1CqsPmv+YQmE5jxb63VwlmikwuGL9HrBHWDxSCE1bq4DyRzMVdR+1iLXx/E424Km4E0+vRRfv X-Gm-Message-State: AOJu0Yy5/sf3SKvwLC4LQ4dGbI6qL3xSNpq8FH7NFHe8sV/WmqM2JnYs 9xiGl4gymVlSvz/Cb6d0oMOiNtzLbT3rCbGrBsUJwPfiOEBxhfQpuzZRmit5ubMAJwQCiqpPHlv Zuu4= X-Received: by 2002:a50:bb47:0:b0:56b:d139:490 with SMTP id y65-20020a50bb47000000b0056bd1390490mr677619ede.6.1711152768231; Fri, 22 Mar 2024 17:12:48 -0700 (PDT) Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com. [209.85.218.51]) by smtp.gmail.com with ESMTPSA id u21-20020aa7db95000000b005689a4b250fsm332338edt.48.2024.03.22.17.12.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Mar 2024 17:12:47 -0700 (PDT) Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a46ba938de0so370965366b.3 for ; Fri, 22 Mar 2024 17:12:46 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW9Cy9akqwVDvrGjg6WhX8OJX2qeIH4deyZzzImkE9jXzQ4+nSX/2uRr0Np0hvRlSItTxhbryLAR7jH8ciTSV5fGYJXCuGm+1jRhB7a X-Received: by 2002:a17:906:6b0b:b0:a46:7ee2:f834 with SMTP id q11-20020a1709066b0b00b00a467ee2f834mr791117ejr.11.1711152766110; Fri, 22 Mar 2024 17:12:46 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240322233838.868874-1-boqun.feng@gmail.com> In-Reply-To: From: Linus Torvalds Date: Fri, 22 Mar 2024 17:12:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [WIP 0/3] Memory model and atomic API in Rust To: Kent Overstreet Cc: Boqun Feng , rust-for-linux@vger.kernel.org, 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 , elver@google.com, 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 Fri, 22 Mar 2024 at 16:57, Kent Overstreet wrote: > > I wonder about that. The disadvantage of only supporting LKMM atomics is > that we'll be incompatible with third party code, and we don't want to > be rolling all of our own data structures forever. Honestly, having seen the shit-show that is language standards bodies and incomplete compiler support, I do not understand why people think that we wouldn't want to roll our own. The C++ memory model may be reliable in another decade. And then a decade after *that*, we can drop support for the pre-reliable compilers. People who think that compilers do things right just because they are automated simply don't know what they are talking about. It was just a couple of days ago that I was pointed at https://github.com/llvm/llvm-project/issues/64188 which is literally the compiler completely missing a C++ memory barrier. And when the compiler itself is fundamentally buggy, you're kind of screwed. When you roll your own, you can work around the bugs in compilers. And this is all doubly true when it is something that the kernel does, and very few other projects do. For example, we're often better off using inline asm over dubious builtins that have "native" compiler support for them, but little actual real coverage. It really is often a "ok, this builtin has actually been used for a decade, so it's hopefully stable now". We have years of examples of builtins either being completely broken (as in "immediate crash" broken), or simply generating crap code that is actively worse than using the inline asm. The memory ordering isn't going to be at all different. Moving it into the compiler doesn't solve problems. It creates them. Linus