Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5417681pxv; Wed, 7 Jul 2021 03:20:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/0/xUojPddF8SAlYkfuiUgI1U3E5wmwVs6hYrQVivPFw+rSAqG86ROKx9AvpCGHwNOVGP X-Received: by 2002:a05:6402:1688:: with SMTP id a8mr27162755edv.4.1625653259719; Wed, 07 Jul 2021 03:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625653259; cv=none; d=google.com; s=arc-20160816; b=G39rx+d5WRcawMiJ8m/kKDOf4HKFiDXPtlFqJD/KzIvzUDyMDNNhIVmGnJPNOqYuYg S2aVysDEnqwVNhGdq40rGkeO6bOlk3m0IUZ7XHRWd4dKMeUZHw/Ja3wtZF92btul+6Se akmJeaPRyVbYnMIiXvbrqxxD05Ci3+M6lB1UMoBgHqxjZmMzxcSriRJFu8bQUWu1fP0h z+5RXOUjppwv78ZUH2tmfTsAR4V0Pkpdm8He45ukHlgY5KnIOTuHMr9eFmMELk+DoANf MRvHzUxrdAB2FrqBFz/R/WGo4wqHI2WbYg5xVhpybqi9OKpP7BUw+eo+ME9ntKCAhhpD SoRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=5/41QsdtJR+pnNTqK6DmTCH5qChei4s6l1r+fcxa5os=; b=CaCqeDnC2VchDeYtsI/eAVF/pO3qmmJL6d3niFLK2juRjyP8SZF1rKndGweyM6nUqO NyfKac32mWoa8uyFrulANHaRlQH+xPZMlzEtgjAG3QsZrOZUFFfFijDayY5rJ9bNyaoX Dsjm2Y2WZ8DY5aBustp0EbLu7fiwcelEsELfLGj/TCyEAH0miY23dMly+hkLxS32ZBwv c5W61QH9XCawGug1Vfr/3IcOQyohnc25rOt7Arb6Yg9nidIPNyaT5gJFhPjaHxzMr+Mh se4+MU2+hRP+7f+dgIBEtPTRR98dD1kfZhTrsv6F5fy+KpK1Clg493FC589l5i26qSf5 /AfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=m6Prb02g; 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 w19si61976edv.129.2021.07.07.03.20.35; Wed, 07 Jul 2021 03:20: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=@google.com header.s=20161025 header.b=m6Prb02g; 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 S231259AbhGGKWE (ORCPT + 99 others); Wed, 7 Jul 2021 06:22:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbhGGKWE (ORCPT ); Wed, 7 Jul 2021 06:22:04 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D95C061762 for ; Wed, 7 Jul 2021 03:19:23 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id f17so2416115wrt.6 for ; Wed, 07 Jul 2021 03:19:23 -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:user-agent; bh=5/41QsdtJR+pnNTqK6DmTCH5qChei4s6l1r+fcxa5os=; b=m6Prb02gepak06rbGn1SOrXDszjWMsxxbLOuQ1T6C+rzgmxTzsqqEQkeZE4kusgddO SGCxMk0aV+EwydOfmYm3fU7Po9TzMU8N7feUairqdef9ja/9b4wUZE5XyuLGHqSVDFbE 5uQpdqFIsY0AeIOTObvhB6t5ezeyTOwPs3igLCx0dKLf8Fh63Y4JrldkXKCea+Di2Bdq RC8h9B/KV9jhodxWABOSR+1NGb0bp7rbEsoj9xW9Bvrrqt7WPodxMa+shw1yrTAqmqfU k01SEnk5bdBE3FBTBDpc0tZwzjD4ZoM0bJ9IS40mZ77XZZZPI79GAnodT1lDIfFpLmSd sHGg== 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:user-agent; bh=5/41QsdtJR+pnNTqK6DmTCH5qChei4s6l1r+fcxa5os=; b=mR7Lgwu2hvX1dYaaqf59RPev3fJnYC5n45++7KPsjKWXsVhxEItYUJLpPpQzCoNXo+ BeXrS0yiNAL+YtR/YA80L7WYy8GREozU3P1HEMUfvUrUGQg5Cla3UYZUKP8ohY9+JT1j jAyTjrqKmhAjVvkLgf0pyvV1hEr+4gFYP8/Z2XgAb2wQhT1Iz4tkLEc96nWV2iFqUWzo 1DBWQR/qeJDSdeS7RXbCzn4vE8wW4yw65RyyeLnqQ2imxGrRqoKhFHR4B1urfApt2c2L NxYZkJVDWaSdcaUWTxCApivpPXeUcXaHTlJaGaIhX56nwh/FD+nZvLcmZq7xyW/qtcxq csxQ== X-Gm-Message-State: AOAM533pUg/p9b/3KDDlAswVMG4V9YOlV9fYvuFHlRrFuScvDYaH21qu sFVUYXNEI9XEu+0fHuRHPbOLSw== X-Received: by 2002:a5d:680b:: with SMTP id w11mr14879170wru.426.1625653161522; Wed, 07 Jul 2021 03:19:21 -0700 (PDT) Received: from elver.google.com ([2a00:79e0:15:13:396a:6bf2:9c33:26ce]) by smtp.gmail.com with ESMTPSA id c125sm2543281wme.36.2021.07.07.03.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 03:19:20 -0700 (PDT) Date: Wed, 7 Jul 2021 12:19:14 +0200 From: Marco Elver To: ojeda@kernel.org Cc: 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, Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho , Boqun Feng , Sumera Priyadarsini , Michael Ellerman , Sven Van Asbroeck , Gary Guo , Boris-Chengbiao Zhou , Fox Chen , Ayaan Zaidi , Douglas Su , Yuki Okushi , clang-built-linux@googlegroups.com Subject: Re: [PATCH 05/17] rust: add C helpers Message-ID: References: <20210704202756.29107-1-ojeda@kernel.org> <20210704202756.29107-6-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210704202756.29107-6-ojeda@kernel.org> User-Agent: Mutt/2.0.5 (2021-01-21) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 04, 2021 at 10:27PM +0200, ojeda@kernel.org wrote: > From: Miguel Ojeda > > This source file contains forwarders to C macros and inlined > functions. What is the story with Rust and LTO? Intuitively, I would expect Rust code to only perform optimally if the kernel is built with LTO (currently only supported via Clang). Because if calls to every one of these helpers are real calls, I would expect performance to be pretty poor. There's probably a reason these are macros or inlinable functions. I would almost go so far and suggest that CONFIG_RUST be modified as follows: --- a/init/Kconfig +++ b/init/Kconfig @@ -2028,6 +2028,7 @@ config RUST depends on HAS_RUST depends on !COMPILE_TEST depends on !MODVERSIONS + depends on LTO || EXPERT default n help Enables Rust support in the kernel. [ I'm sure there are configs that don't yet work with LTO, but could be useful to enable for debugging or testing purposes, and therefore would make it conditional on CONFIG_EXPERT as well. ] [...] > +unsigned long rust_helper_copy_from_user(void *to, const void __user *from, unsigned long n) > +{ > + return copy_from_user(to, from, n); > +} > + [...] From some local tests, it looks like simply attaching __attribute__((always_inline)) will do what one would expect when compiling with Clang LTO (I checked -flto=thin). If you confirm this also works across C and Rust TUs when enabling LTO, I would then suggested adding __attribute__((always_inline)) to all these helpers. Thanks, -- Marco