Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp87221pxb; Thu, 15 Apr 2021 23:51:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKPHRBXEPRvuvCgctWDkErCV8wjq3bo9C2VOJsV9x90b3k8Lwu5BzgKfB2twViyx3CMOPG X-Received: by 2002:a17:90b:4c02:: with SMTP id na2mr8032424pjb.77.1618555899520; Thu, 15 Apr 2021 23:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618555899; cv=none; d=google.com; s=arc-20160816; b=rXDSBZqKvZlL0pHA0G8EGZDoQrKmkPFyBpHpkfKAasFg5+/FGfvu8T1hYSzbLPpxKh lo7caoFZXQbSj79U5Xg9s1/pCEI4caxvC1wT4TSxw1IRf7SwfmzRjN27/vurZ8MGV6xg /uitxn+hckDnC+06xsFCglCUsXTA5fX5jA6gj/tEoi9hgsdpKM0gpdJa93CLsI5TE33I CljN8GoBEAcmEAj55XGadG7Oh0C7ANCD99+jfKErf3tbldOKCQYZ44INnISLijxJZ558 x7jY7Up57YZJ+Nva8hDdyseghMIHBsImyfjkUhNZlzIC6G0sNZa23A+oQO/pqAA5xDcn Uwfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gbzaa2Ai7xXdaJk+SuOzDr1sDQqCY9sqWL6R/1Zrh+s=; b=qrsX6hjFteAb4DcD54z+MeEdm3znjM6jB5PapulfgRxzow0Q4RzvpnaTq74kggVJNx AqnCi+WwIcGvEE405a4+LM0msZzFQr5CY9/4Wb/bbuYCg1EWLhJ0TetnMee1KYKO9pZh 3lXe7wGZyTehzN1Rb2Rmv5ys19HeLs8T5oHQgXD9mUx5tHlNhAAeBByzb26ms9NHX+hL viAHe+JGojZm1UwJq6Y/sdFZUAl0qgY0Ww+ZuLsa1yeUSRYRhkBnOpzDlKQDmvF0K7sb I7nAPAT2ODBbgeH0gZEZE9zpvPAUo8CI+GuwiwXFQzMMH1jKETq55rAKxhuWRs65kDoz d2Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="W5/QWZWF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si6458738pfu.100.2021.04.15.23.51.26; Thu, 15 Apr 2021 23:51:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="W5/QWZWF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234662AbhDPGFR (ORCPT + 99 others); Fri, 16 Apr 2021 02:05:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbhDPGFQ (ORCPT ); Fri, 16 Apr 2021 02:05:16 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7511C061574 for ; Thu, 15 Apr 2021 23:04:50 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 12so42782558lfq.13 for ; Thu, 15 Apr 2021 23:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gbzaa2Ai7xXdaJk+SuOzDr1sDQqCY9sqWL6R/1Zrh+s=; b=W5/QWZWFFaSWg9idKZ6DJEpPmhh/eOS3XCiS0GJpjJR7c/9hO/bPRnbhDx6fcqOh/0 sp9nz3xawBALOHCXGcN4jIih6Lo7LRUhWSYjVKt/IE7M5QZMCikdUSMKXXJqXnNorxIu UcotZdbyz0htz+FRuAF9BYmaG3K/gWMFAT/A8/JmQBFrNNVdGLgxB72JzOcS3dWuBrUO pLLR3MAXjECLXZHF0eu89BJvQwappXx3P0EcpPXDjPCJULvqxF+y1iSxNPQzfc3EiG4c rSb/0coU8nEO5IvdaN3SjfYFjNy5PzO32XHT/eoBVhUpxXlkT2FrApLCrpZqzbcHuazj 0Naw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gbzaa2Ai7xXdaJk+SuOzDr1sDQqCY9sqWL6R/1Zrh+s=; b=FYBRh+F/gZRNVlQ0fpcwg4DVqLXM5lyCYfyt9w5l3LRWAuqM6vNrPPmexT/lCWM2lP MH/vPjgrc9mSKRxdzC7ouqYkjbz77Fm+ILAj3ml1mjhZ/jihw/ND2XT2nQ2xtbrFKDXN YOAzGswBEz8uXMgxSy8cc0/wQWRKtCFbXkXQ5w3Wik9okkFYg6ZPePMCgx23xbMssU++ DQXmdSPQOeE0q7c6/Sqxv1xBboFMoI0cG6Xf3sxZPsIJ1W3G6PQq1aO40PKmVSiTJiCM +xWF5V17e1SdBljgUy+d+a4GbHmf6mCXNj8yjWkV7hMK7VmzX8x2B2369mYyppZvZ4cI /Zpg== X-Gm-Message-State: AOAM533xTrppzi6e/f96aVYDbCfkylZirJKyx0X7JJKeKKFjVPk6A+nN weIX9HtZopOED5EuIpLixIbfhJOlkl1nineNduYPJw== X-Received: by 2002:a19:ac09:: with SMTP id g9mr1821239lfc.547.1618553088788; Thu, 15 Apr 2021 23:04:48 -0700 (PDT) MIME-Version: 1.0 References: <20210414184604.23473-1-ojeda@kernel.org> In-Reply-To: From: Nick Desaulniers Date: Thu, 15 Apr 2021 23:04:37 -0700 Message-ID: Subject: Re: [PATCH 00/13] [RFC] Rust support To: Boqun Feng Cc: Peter Zijlstra , ojeda@kernel.org, Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Stern , Andrea Parri , Will Deacon , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Josh Triplett , Wedson Almeida Filho Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 15, 2021 at 9:27 PM Boqun Feng wrote: > > [Copy LKMM people, Josh, Nick and Wedson] > > On Thu, Apr 15, 2021 at 08:58:16PM +0200, Peter Zijlstra wrote: > > On Wed, Apr 14, 2021 at 08:45:51PM +0200, ojeda@kernel.org wrote: > > > > > Rust is a systems programming language that brings several key > > > advantages over C in the context of the Linux kernel: > > > > > > - No undefined behavior in the safe subset (when unsafe code is > > > sound), including memory safety and the absence of data races. > > > > And yet I see not a single mention of the Rust Memory Model and how it > > aligns (or not) with the LKMM. The C11 memory model for example is a > > really poor fit for LKMM. > > > > I think Rust currently uses C11 memory model as per: > > https://doc.rust-lang.org/nomicon/atomics.html > > , also I guess another reason that they pick C11 memory model is because > LLVM has the support by default. > > But I think the Rust Community still wants to have a good memory model, > and they are open to any kind of suggestion and input. I think we (LKMM > people) should really get involved, because the recent discussion on > RISC-V's atomics shows that if we didn't people might get a "broken" > design because they thought C11 memory model is good enough: > > https://lore.kernel.org/lkml/YGyZPCxJYGOvqYZQ@boqun-archlinux/ > > And the benefits are mutual: a) Linux Kernel Memory Model (LKMM) is > defined by combining the requirements of developers and the behavior of > hardwares, it's pratical and can be a very good input for memory model > designing in Rust; b) Once Rust has a better memory model, the compiler > technologies whatever Rust compilers use to suppor the memory model can > be adopted to C compilers and we can get that part for free. Yes, I agree; I think that's a very good approach. Avoiding the ISO WG14 is interesting; at least the merits could be debated in the public and not behind closed doors. > > At least I personally is very intereted to help Rust on a complete and > pratical memory model ;-) > > Josh, I think it's good if we can connect to the people working on Rust > memoryg model, I think the right person is Ralf Jung and the right place > is https://github.com/rust-lang/unsafe-code-guidelines, but you > cerntainly know better than me ;-) Or maybe we can use Rust-for-Linux or > linux-toolchains list to discuss. > > [...] > > > - Boqun Feng is working hard on the different options for > > > threading abstractions and has reviewed most of the `sync` PRs. > > > > Boqun, I know you're familiar with LKMM, can you please talk about how > > Rust does things and how it interacts? > > As Wedson said in the other email, currently there is no code requiring > synchronization between C side and Rust side, so we are currently fine. > But in the longer term, we need to teach Rust memory model about the > "design patterns" used in Linux kernel for parallel programming. > > What I have been doing so far is reviewing patches which have memory > orderings in Rust-for-Linux project, try to make sure we don't include > memory ordering bugs for the beginning. > > Regards, > Boqun -- Thanks, ~Nick Desaulniers