Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp542373pxb; Thu, 15 Apr 2021 00:13:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWBQWq7adNQhDJu/zluTLFwO7d3q83WS4fTpGoCoqtzGSTYR4lXr9meNPXobteesKb21mu X-Received: by 2002:a17:90a:6587:: with SMTP id k7mr2302476pjj.97.1618470779868; Thu, 15 Apr 2021 00:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618470779; cv=none; d=google.com; s=arc-20160816; b=GHOlDwi3vq8HCSMUzpJ+uX4whF3I/G0lZwr742Ybg46qyNaXG6W4hqEiIl8tBMF4R/ ajtaAjo6VRy6RRPAJLYMhgN1Mzsa3lE9MjjnCAhIr++2ZgjKCKjZ3BMHgteHwpOebieb SlIGpWdwkvh8ZIDlyY2Tu5a1z1uobSpYn3QvyPhV9Lf5GnJFDyeTvTf/jBI3r/ZZvFH0 4YAx6S1ASvBQrA9dzvOHA+GvcyO/aJqw2pDOXO/lK4MMhxaxikabJ7VbTR+qYfNJ3mH8 P1PTX00GIIE+2/avff/MZx2tNnj4TkYBS9kG4ZeUDp89wCzErtZlhF6Rih0ZAdVw4Dva c2Hg== 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=/yXPccx4bcUSLW6GpVmtmfCes+qopq5hZtA6CkdInW4=; b=c4gtkBsy8jsWFs5prm7pI5YntFLHmJYAzIygJcSHaeWWWKakj/oH6rDO3Uk0AjCyYA pz6KkloQ+bSYQyHFg4WzBAv1KP3Rgy3Q/YgsMoEgeGlLvIPUX+yZdo6RoJcQZiOui7Eg 5bzftoKTPTOQCf6qNj/mAnDV5NyikK5syz8QuyOQprNgQqYJc/iWxbxYXJeGztCtUyFZ knhz0WR91j/i5cVDB64r2VltN6siVxzVpKQ3aXhcnJRaNrQVjuVKhTRYhsBUZaUKdhiV WXfam7Geqf8qITUYK+4+Wf6lexcwmyTCzdCs0ADO9fbgbCFPWJOEea8Qz2ZHqZDIcdGo eQEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fRu6Pltp; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m8si2139399pgi.113.2021.04.15.00.12.47; Thu, 15 Apr 2021 00:12:59 -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=@linuxfoundation.org header.s=korg header.b=fRu6Pltp; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbhDOHLQ (ORCPT + 99 others); Thu, 15 Apr 2021 03:11:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:42716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbhDOHLQ (ORCPT ); Thu, 15 Apr 2021 03:11:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BACD6611AD; Thu, 15 Apr 2021 07:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618470653; bh=l10X+vv5dBXcCRCNYL3D6TNyby9Y/mbKe5evcjbSDSE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fRu6Pltpvgw1T16C8/s7fBg1XzHMQN24KoKIRaCbHA1fe3Xo0Vl8m5zetxLdUei2P Fq5k+6Pdi6WGffZkmhg1bwFLdtHLNImkUHzfyDLaae2P8BqEYlb9cvNyC1TlBi1EzN Zv4m5f1Huyww/1N7oQTFjmOsWgxduiKgkZNYa05w= Date: Thu, 15 Apr 2021 09:10:50 +0200 From: Greg Kroah-Hartman To: Nick Desaulniers Cc: Linus Torvalds , Miguel Ojeda , rust-for-linux@vger.kernel.org, Linux Kbuild mailing list , "open list:DOCUMENTATION" , Linux Kernel Mailing List , Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho Subject: Re: [PATCH 09/13] Samples: Rust examples Message-ID: References: <20210414184604.23473-1-ojeda@kernel.org> <20210414184604.23473-10-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 14, 2021 at 04:24:45PM -0700, Nick Desaulniers wrote: > On Wed, Apr 14, 2021 at 12:35 PM Linus Torvalds > wrote: > > > > On Wed, Apr 14, 2021 at 11:47 AM wrote: > > > > > > From: Miguel Ojeda > > > > > > A set of Rust modules that showcase how Rust modules look like > > > and how to use the abstracted kernel features. > > > > Honestly, I'd like to see a real example. This is fine for testing, > > but I'd like to see something a bit more real, and a bit less special > > than the Android "binder" WIP that comes a few patches later. > > > > Would there be some kind of real driver or something that people could > > use as a example of a real piece of code that actually does something > > meaningful? > > Are you suggesting that they "rewrite it in Rust?" :^P *ducks* Well, that's what they are doing here with the binder code :) Seriously, binder is not a "normal" driver by any means, the only way you can squint at it and consider it a driver is that it has a char device node that it uses to talk to userspace with. Other than that, it's very stand-alone and does crazy things to kernel internals, which makes it a good canidate for a rust rewrite in that it is easy to benchmark and no one outside of one ecosystem relies on it. The binder code also shows that there is a bunch of "frameworks" that need to be ported to rust to get it to work, I think the majority of the rust code for binder is just trying to implement core kernel things like linked lists and the like. That will need to move into the rust kernel core eventually. The binder rewrite here also is missing a number of features that the in-kernel binder code has gotten over the years, so it is not feature-complete by any means yet, it's still a "toy example". > (sorry, I couldn't help myself) Perhaps it would be a good exercise to > demonstrate some of the benefits of using Rust for driver work? I've been talking with the developers here about doing a "real" driver, as the interaction between the rust code which has one set of lifetime rules, and the driver core/model which has a different set of lifetime rules, is going to be what shows if this actually can be done or not. If the two can not successfully be "bridged" together, then there will be major issues. Matthew points out that a nvme driver would be a good example, and I have a few other thoughts about what would be good to start with for some of the basics that driver authors deal with on a daily basis (platform driver, gpio driver, pcspkr driver, /dev/zero replacement), or that might be more suited for a "safety critical language use-case" like the HID parser or maybe the ACPI parser (but that falls into the rewrite category that we want to stay away from for now...) Let's see what happens here, this patchset is a great start that provides the core "here's how to build rust in the kernel build system", which was a non-trivial engineering effort. Hats off to them that "all" I had to do was successfully install the proper rust compiler on my system (not these developers fault), and then building the kernel code here did "just work". That's a major achievement. thanks, greg k-h