Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1094831pxb; Sat, 17 Apr 2021 06:31:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMIt0HrYxv//mz6XSW40OAIJTjELBXzuzbUauBw8p4YM7ILgYioWPLPkTbkPQB1krL7pZN X-Received: by 2002:a17:90b:224d:: with SMTP id hk13mr15403505pjb.218.1618666285674; Sat, 17 Apr 2021 06:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618666285; cv=none; d=google.com; s=arc-20160816; b=EXlCMDrc2c/qrQ8yespvn/so+bjoFypaoZYfbuDlq7tIlUmaL5qJ+ZTQcx5i/68kJD CdoviMV/bTSw6P4V3b0WpgKtD1Dd4MdqGUFf5Ac6IyRq8CCNKZ6HZ7QV7qoILu1ZwoDn 4rnKu1ey+Gt13RaFBhaORDCwArrNAdfjPnatb4MRQLHXytYYXdkbhSpQWY1meBxkSZjB HraJkii20Inx4xFVfYZYvCcmhC23lGL4LZHV6cCproyZii9k86UebJWBL2O/99afYjN2 S0DfqJTj4lf1GCvz34Y4KKREY10wHoo16esdjzNUWMAs+lwpxKVcqedjzZQDfvD/xhgI G4dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ISBdoGIET+ZYznAio2FskDixMUDkKh8PC4/Pd4Loq2k=; b=Yk5paNN6tN/8i56UUGwFG1VCaa267vrO9ciZ6b9VNvRhsREAKFZmksNBCoSJMv99Z4 vwTNwykaDsdrdZ6FwNADDtOuHQXM9oufcgxLy6d4Bw3vZGIfLY4jBQfipLKvI1R2Bqx7 LydMbv5d2uDD9udTDwqpis6+yoHjD5mu8QuAOwiEbzf1nrIeFGRjIiTXJ+uJsFfOGNqA vKPo5e/Y3GglUxV/kcZu92hwwRXfJrsCR8BnbrttHya+aMm1zvWHK+p9CWQJbW+KjiA4 CGFvYQGp1hMPt40yCEQ704BfEr+DSjI9ynemgyK2SUgZacfG2lsg6U7DYkgwVoR49xNu DfOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="d/Pja+Dm"; 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 z31si10038428pga.478.2021.04.17.06.31.12; Sat, 17 Apr 2021 06:31:25 -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="d/Pja+Dm"; 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 S236287AbhDQN3y (ORCPT + 99 others); Sat, 17 Apr 2021 09:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234904AbhDQN3t (ORCPT ); Sat, 17 Apr 2021 09:29:49 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA3FC061756 for ; Sat, 17 Apr 2021 06:29:21 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id y124-20020a1c32820000b029010c93864955so17950970wmy.5 for ; Sat, 17 Apr 2021 06:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ISBdoGIET+ZYznAio2FskDixMUDkKh8PC4/Pd4Loq2k=; b=d/Pja+DmXSa+DmZhRpIEt3/37I45Rs75tBubp/JfNW0JByklVj/oO1Mnpl+LGw4Miw s8mlIsXzOhdvN08Cwvzaknh9HE7sNEJwbpiFeunxRCkJ/1FRnctFHC8f+rWH2oM3eYFK MTXxU5dZXVeXwZYbTn0xfbnSLi5NFB3UxiiRg0juj/B+SUlMgWl0ZwombT8SJriD+iQc RDzmYTa2a0GkMdzoPk5pWWcCPGK7RMzCc1JYoUPe05/+cVNl+EpRizRV7UZfHMH+ylgW TyOQHeJrz/vlVZ93tboITgeFuJCSXE/A40E0JF7U+x1cZJJW5kc0u6Y73ZruuCx1HBmO OihQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ISBdoGIET+ZYznAio2FskDixMUDkKh8PC4/Pd4Loq2k=; b=houO8V2Zh6FMXLkU0LhMFE9lotOu+cKP+7iGUpTWvhIm35U7EsUEFiBnSLVPCzrGbu x+CBEX8R0+PwQ8EiY8ipXKQWeQuHTjFKK9w66HUui2HO1qkJ0Yia+zCx0JcsZ1Tphbcy OINhEnBOOyYBFcRDDlYzOec8pogTPUVuZM5hSKdLqNTjBLMraiijvSm/m0kVAKbEd9Ng My2lVOWc+zELeZ+ceUrJVEtaerud0gcK7jeilJyqmIJQl+PInGeaS66I7Npb0bc6WVrZ AuBPJy2M48gteSVngGAzI3oh2mSHah3U+x+COuVum0mY/xJpNryadMKu4uUW7+YiThta z/nQ== X-Gm-Message-State: AOAM530EY1a40CKmaZ7/r4A5kYYdtpuanpvDKeazS2wQIoa3Neqz2W+k rnTrSBMG7KIxd94iXWugkBYT X-Received: by 2002:a05:600c:4fc8:: with SMTP id o8mr12727799wmq.87.1618666160177; Sat, 17 Apr 2021 06:29:20 -0700 (PDT) Received: from google.com ([2a00:79e0:d:209:3c1c:8462:b77e:21a4]) by smtp.gmail.com with ESMTPSA id l8sm12570438wme.18.2021.04.17.06.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Apr 2021 06:29:19 -0700 (PDT) Date: Sat, 17 Apr 2021 14:29:15 +0100 From: Wedson Almeida Filho To: Matthew Wilcox 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 Subject: Re: [PATCH 00/13] [RFC] Rust support Message-ID: References: <20210414184604.23473-1-ojeda@kernel.org> <20210416150307.GJ2531743@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210416150307.GJ2531743@casper.infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 16, 2021 at 04:03:07PM +0100, Matthew Wilcox wrote: > Well, we could do that in C too. > > struct unlocked_inode { > spinlock_t i_lock; > }; > > struct locked_inode { > spinlock_t i_lock; > unsigned short i_bytes; > blkcnt_t i_blocks; > }; > > struct locked_inode *lock_inode(struct unlocked_inode *inode) > { > spin_lock(&inode->i_lock); > return (struct locked_inode *)inode; > } Indeed you can do this kind of thing in C, but as I said before (apologies if I'm too repetitive on this) Rust forces you to do it the right way, whereas the lack of enforcement in C leaves room for mistakes. If you do add extensions to C to add some of these restrictions (and I encourage you to pursue such extensions as we all benefit from better C), it is likely not sufficient to reach the level of compile-time guarantee that Rust offers because you need a whole slew of restrictions/enforcements. I also note that academics have a formalisation of [a subset of] Rust that show the soundness of these guarantees and the requirements on unsafe to compose safely. So we're not talking about guesswork, there are formal machine-checked proofs published about this (see for example https://people.mpi-sws.org/~dreyer/papers/safe-sysprog-rust/paper.pdf).