Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp324485pxy; Thu, 22 Apr 2021 03:04:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytMJaDvgS4yQxPP0cezIlzYEQ5YRRRzeboUE6BUVG+rEpnrGK/3Aj8kVd0F89DihP9yhVd X-Received: by 2002:a17:907:6289:: with SMTP id nd9mr2513623ejc.384.1619085880359; Thu, 22 Apr 2021 03:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619085880; cv=none; d=google.com; s=arc-20160816; b=Fnelk4Cn1OXP52Xj1dpBFE457q0WvM+2KqIPdWeqaFvhEkLoof1nMYZMIHG43hOcVN v3zh31Z6kwPQ5RrG64b+HOLrj4e5ZppTKqGOUY5DVtw34wfpxCXC4Dp16QimXWtF1gPV 178dxhNJ8/tEJ4Zr+RHeZQ9meKuCumhYtPd48mCoXCRmjOCwjq9b9xaSH4tGCIsLvhFL V0UZqWwThULa9DVFkmNibSoApEgjdNoEJj12gnafRpWSlRxsWRxw+TFz9AiU5qX9iuc0 AFr0OUp6XOeqwVqakNPAtBdmomsbxtaWwQrO2LSbf5P1/ZJ5lheaUDRdXlB4w7SG0FjO yqwA== 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=fi1nyojqm+ITv1jOfr1bYqtxzxCOpWmoUIo17W0BtvI=; b=JJimFVyBLJA3RLQExEVetDBBU+Mwkbm0QKC4mQea4+5Ktoi73YP8L6ceuShbCVkur0 2R8kzi5HnlqbhcZZiF8IYG9+NfSYjLs/coqWLhTmIaQVGdEOR7UG1XZWjhuK5wfO7oOL ycIqzJ4q7sM/ZWrq804SuRWAJ61m37pF2TSvsZzJgWcYJ4xrUFFAKgpwIpLjHSjOSlM4 VWX7fGoSi3GXI0njS97lUt6tX11H7jCjH2KUCG35MeiTve1H6w5Xf2iMIcmoLJGfgTSV B5Evt3mBmvg79vx8kMvFvwSOdqlFXgidg41ryyS50HUsVIXGSjEUernR6mWTJk1RzxbF uhbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pPEh/5ux"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i26si1885199ejb.13.2021.04.22.03.04.16; Thu, 22 Apr 2021 03:04:40 -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=@linaro.org header.s=google header.b="pPEh/5ux"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235838AbhDVKEC (ORCPT + 99 others); Thu, 22 Apr 2021 06:04:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235817AbhDVKEA (ORCPT ); Thu, 22 Apr 2021 06:04:00 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 081E8C06138E for ; Thu, 22 Apr 2021 03:03:26 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id o16so51133982ljp.3 for ; Thu, 22 Apr 2021 03:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fi1nyojqm+ITv1jOfr1bYqtxzxCOpWmoUIo17W0BtvI=; b=pPEh/5ux89ZxxJmLelA6aiTCu6nZP4KZan7I1fhxg5IM2mB/pMxqaykorlLBoHAAF4 BMwLxkvatGofd4g/7+fqs5W27wB9dZ9ZhACIq8AHx9wYErcvCBLxJQL0Waq9f9wS1u+g ht4F4t5p/O9cXD7fTHrqQmB/HkFlmngsYDC/A3S/BdRExVGFpY72I+8AC343Vy6dWKl8 05OiqXHyputw/PXr55qoyVbKz9N21H9AnOjxyCORDXaFz5gzHgg7CJq7CDmr4EeoejnQ ASEO0Ip6TWf9+beKJsxfqsnzWoOhq5DyC5nhFwIEVJ/tayxxWlrG2MAN38Bcw/RRaEKQ hl3g== 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=fi1nyojqm+ITv1jOfr1bYqtxzxCOpWmoUIo17W0BtvI=; b=lsNVISeeTTLxzZShKZ0C1naRjpx8542//JoxhXIRoU9hAD8n09jRNjlgtpwgA1Sz63 0ihr0jS+byDNX/w8+j1oiV7h2gJtIVlb04JsMGs4zvREOa4M64bt0crrg1SYfE4wIB1R CW0b7N4or5aCqOVXrHuJ0kukJwRP5DsN+CoxH3QXdmySU4V8iaxeadUpGwo1oyJX+nPU bEiaclurN84H0ke0Iiwz9nvdjEax+gQSC4dsP1SV74lSeUarj85PhDdj0r158mEe/QtJ KIVd6TDvuB9bqmk2jbbaJbSo14AclvRBw+5oFSAnRs/nLASpiSUURROP01vbo3Ds0yuv KYbg== X-Gm-Message-State: AOAM531eu7flAQN9GhETdBKmBl184mVj0uFy6mOULeDRuAz7Ejcv3ebk /5vN/zktg3X2OQnaET+ln7Zluvb01lyAOfU9vAoSfA== X-Received: by 2002:a05:651c:c1:: with SMTP id 1mr1859058ljr.467.1619085804376; Thu, 22 Apr 2021 03:03:24 -0700 (PDT) MIME-Version: 1.0 References: <20210414184604.23473-1-ojeda@kernel.org> In-Reply-To: From: Linus Walleij Date: Thu, 22 Apr 2021 12:03:13 +0200 Message-ID: Subject: Re: [PATCH 00/13] [RFC] Rust support To: Wedson Almeida Filho Cc: Peter Zijlstra , ojeda@kernel.org, Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kbuild , Linux Doc Mailing List , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi folks, "we will do less critical stuff, like device drivers, first". OK I mostly do device drivers. Kind of like it. So I'd like to provide feedback from that angle. On Fri, Apr 16, 2021 at 4:22 AM Wedson Almeida Filho wrote: > We don't intend to directly expose C data structures to Rust code (outside the > kernel crate). Instead, we intend to provide wrappers that expose safe > interfaces even though the implementation may use unsafe blocks. So we expect > the vast majority of Rust code to just care about the Rust memory model. I'm a bit worried about this. I am sure you are aware of this document: Documentation/process/stable-api-nonsense.rst We really like to change the internal APIs of the kernel, and it sounds to me like Rust really likes a rust-side-vs-C-side approach to APIs, requiring these wrappers to be written and maintained all over the place, and that is going to affect the mobility of the kernel-internal APIs and make them less mobile. If it means I need to write and review less patches related to NULL dereference and use-after-free etc etc, then it may very well be worth it. But as subsystem maintainer I'd like a clear picture of this wrapper overhead, what does it usually entail? A typical kernel API has vtable and a few variables, not much more than that. I go to patch 12/13 and I see things like this: +/// A descriptor of wrapped list elements. +pub trait GetLinksWrapped: GetLinks { + /// Specifies which wrapper (e.g., `Box` and `Arc`) wraps the list entries. + type Wrapped: Wrapper; +} + +impl GetLinksWrapped for Box +where + Box: GetLinks, +{ + type Wrapped = Box< as GetLinks>::EntryType>; +} + +impl GetLinks for Box { + type EntryType = T::EntryType; + fn get_links(data: &Self::EntryType) -> &Links { + ::get_links(data) + } +} My God. Lose the horrible CamelCase to begin with. I hope the language spec does not mandate that because our kernel C style does not use it. It becomes obvious that as subsystem maintainer for the Linux kernel a casual drive-by experience with Rust is not going to suffice by far. All subsystem maintainers are expected to understand and maintain wrappers like these, right? That means all subsystem maintainers need to be elevated to understand the above without effort if you wake them up in their sleep at 4 in the morning. This makes me a bit sceptic. Get me right, we are of course good at doing really complicated stuff, that's what engineers do. But we are not Iron Man. We need a clear way into understanding and maintaining wrappers and we need support with it when we don't understand it, so the kernel would need a Rust wrapper maintainer that we can trust to stay around for the long term, i.e. until their retirement, while actively teaching others for decades. For an example see how RCU is maintained. Developing trust in the people Miguel and Wedson is going to be more important than trust in Google the company for this. Yours, Linus Walleij