Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1910160lqp; Sat, 23 Mar 2024 14:41:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXINO9nKf5rTVnqCiPYT83YER6zK5oy2J1yN1c5cEhWLRtLrhpM18Ev2LZVflzcn5FuseIELHv2ZoWBj4odYEmzCrT3C3sRJADxVdEU9g== X-Google-Smtp-Source: AGHT+IFcrmhrjeDL3Abze2yyJKHM5NvhB3Sx9RlrG0HP/ivDSEebxBLnCpcdGq18i2Kn+cmlIash X-Received: by 2002:a17:90a:5504:b0:29d:dd0f:f853 with SMTP id b4-20020a17090a550400b0029ddd0ff853mr2588199pji.26.1711230119185; Sat, 23 Mar 2024 14:41:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711230119; cv=pass; d=google.com; s=arc-20160816; b=Q0Q8yiwXoogTToxLZchYC5kpr6Osr+wEGUYLTdwN1LTn9OOPVYKtTZu89qt2cePnP6 51qPEi+bRH0MOK+ZexNc+LFvJPnhYXgvUQoQE94UZFJpRcFgvQ5YugVGgOzbAClGDArf VYVl6UETxtjHT46WqLQC7qWGht1vxrBytdtt5kroGZTWVjrbOjOpKea7zrWLlEpH7bMQ TC97p5PCpGGm4BOmb5nVJBTuKLU2SH5rdi/U7C2D14YAUscOnS7c5MiVgYITLolD6nIB NbrGVX+sNjZC08JXE9NSsj/dm/ef11Y/lepzVQHISUp0kV2jTqlvLCYoMHn4gTB+16mX Q48Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=gOFRvpRAI+VWx5nUCuNi2VPShTLUPuTZZjdFa31yQSs=; fh=OmtsFkuxN86s66cK9SD0/2QuDpFV2ckrIS1LUPXyKJU=; b=d9ndw3w2/8Rw/z6QAX2yeEB+V2BJYwjkec3Ip3iOtfqLl074kr4/YFFisEphpR1i2C 0NeVD9wUJgqVlK8Owqsg5aCiVUA7WW82lDRoYzB+BudrbFfzBd2tB+vfpvRnRbHp9Whm 9blsNFNEUG1y4Hj9Xec1uxTCe5UEHefjV9GH2cl5YH3QQe2pMejMiJDfZ5ICxMZJtx3s ITNH8UkfEmPo24U3PbYt6svB74xMQ17ESQqIUYVmDydIQ87gc2x3P/rusWf9Cj5C8Zjs CO/0R2MhzGr1VBUemsbZvk4plYeo9RkB+dd34TyFHgYs3EDMS2SdrSGNmmTEmMf63CLR jLmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NXMb9yxg; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d16-20020a17090ac25000b0029a1aaefe30si4602192pjx.188.2024.03.23.14.41.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 14:41:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NXMb9yxg; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E2DABB210D8 for ; Sat, 23 Mar 2024 21:40:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78D4F5B200; Sat, 23 Mar 2024 21:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NXMb9yxg" Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (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 0EC1758104; Sat, 23 Mar 2024 21:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711230038; cv=none; b=I6w12BvQ9ThWqE7Gzd2CMwUiPrzVS6e5OWAf+OLf20tlylLXssSOS25yhf/E/ay3jwg6UsfzsHIpCeuCry4SBeuTsV3ZXP0B8wy6RTjeDpjG9AdeFHcZc8Gwox53aVmMH627SZO5FTiWtyzUazVbrJD3PjHiypiKIquXRuEPbZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711230038; c=relaxed/simple; bh=cxJyvYom9rYpI3v6jLA3KnXUFhHsx7mMzeaboHDdGAw=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=gl4MeZISYW3rpyluuP5pfbpIIYVTvopi+pQdiIHhZW7Dw5RUX19BC/VNhdLMnE9FVUKmy3cioEix+OXanPeWyZPFGebew9ZEQSzag5C+H7C79hA8Y0jFLH+djz0IsXIHXBi3othZ+np2p1yHczEmYrjjMeDl1W44o9XScZEOXfo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NXMb9yxg; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-78822e21a9dso157923385a.2; Sat, 23 Mar 2024 14:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711230036; x=1711834836; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gOFRvpRAI+VWx5nUCuNi2VPShTLUPuTZZjdFa31yQSs=; b=NXMb9yxg9f1ThZQCvxH0Yz456i6L8sYWPjs6mdkgZ/4JogDXuGHkfmzFW7yIvRyv2r QiiNLan+NOuazcUOz1FNm74EWGC1tE5Yci7lYNx/qhkv4X05bc4UhSmml7IBRJWjN4W9 GufUzB2bJYguFdZvDdk94K2etjwTFkAZThzUQBnaMRjSTx4LW9JkDrxxRGbRIq1wnZ4h JqZvjcldI9XTxAIH7W7UZ+L8Ci6uOlURgLiRzLSyMR5Mvb2qZzseAZJq+m2qwMTr0yz6 afY2+fxqKhg7lVBc2rnNp2xpe2dzjP2tYq90NFFc627W8BTTCgyjXvxeUOSwkZSkAPKI 8QdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711230036; x=1711834836; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gOFRvpRAI+VWx5nUCuNi2VPShTLUPuTZZjdFa31yQSs=; b=OgRRjadT4aqEJl2Zs3ZuHo+lN3/G6Cyfx/JEefG7zaDt6NUAJrzHNkbJXmbijz/PV0 mKLwubGRQ5oupv2LDjSgz/oQhXjQJEjsuCa6wP2uWT3HkeJx4OsMwgTvBOKEeXE6W6Dz Vd8x9K+1SHDU85w6L+52ScixRrl1yOiZTGDqyRxYf47r/rDFKnLOwJUcKMAN/2qjHdzX EFf/dHz6rCxtnXGTZ+X6rgNpam182YNzxftDpviGoo2G1L5hF7Gm9ZEnk9gZVgfP1cEX lh3OYdU8nxg6fcsZqbpd01uYBK+N6PvKx2qG1eCER5Sr5k7KWUt0nIAauPP/V5ED1o6s /y7Q== X-Forwarded-Encrypted: i=1; AJvYcCX5MTVgpLXUzR6nsuY+TfS2xXCIiyCr2fCWe7HwVz8crFY4rRC3cOu7xyZKEobHxFJdO0IjSoQpeIIHeQkR3eFDTQ6FvSRLRNZ4+z9k5ZqzFKfe2np+HwESjnVU64NW+A28PEkzF2TURnOQzHBXRD1AP1gE6VZJskqPQJndvmFcYvxQhT6rOnU3YbDcB0bYUpPzEKr+3ClOwe6AhUuNyNin0zy35kyBuw== X-Gm-Message-State: AOJu0YwPR8ed/kpvqOY8Zl4Qj/J6Tr35t5BjvYHzQo5v3ozxz5FqQQk8 ohyNLDcXvbjwvRCinPvVw7bk6HJRBTsWUu/7+cIJGMuAQhXOp8le X-Received: by 2002:a05:6214:1308:b0:691:e21:736c with SMTP id pn8-20020a056214130800b006910e21736cmr3799275qvb.30.1711230035924; Sat, 23 Mar 2024 14:40:35 -0700 (PDT) Received: from smtpclient.apple (pool-162-84-172-44.nycmny.fios.verizon.net. [162.84.172.44]) by smtp.gmail.com with ESMTPSA id kc1-20020a056214410100b00695e602d356sm2450268qvb.46.2024.03.23.14.40.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Mar 2024 14:40:35 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: [WIP 0/3] Memory model and atomic API in Rust From: comex In-Reply-To: Date: Sat, 23 Mar 2024 17:40:23 -0400 Cc: Kent Overstreet , 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 , 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-Transfer-Encoding: quoted-printable Message-Id: References: <20240322233838.868874-1-boqun.feng@gmail.com> To: Linus Torvalds X-Mailer: Apple Mail (2.3774.500.171.1.1) > On Mar 22, 2024, at 8:12=E2=80=AFPM, Linus Torvalds = wrote: >=20 > 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. That may be true, but the LLVM issue you cited isn=E2=80=99t a good = example. In that issue, the function being miscompiled doesn=E2=80=99t = actually use any barriers or atomics itself; only the scaffolding around = it does. The same issue would happen even if the scaffolding used LKMM = atomics. For anyone curious: The problematic optimization involves an allocation = (=E2=80=98p=E2=80=99) that is initially private to the function, but is = returned at the end of the function. LLVM moves a non-atomic store to = that allocation across an external function call (to =E2=80=98foo=E2=80=99= ). This reordering would be blatantly invalid if any other code could = observe the contents of the allocation, but is valid if the allocation = is private to the function. LLVM assumes the latter: after all, the = pointer to it hasn=E2=80=99t escaped. Yet. Except that in a weak = memory model, the escape can =E2=80=98time travel=E2=80=99...=