Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1221027rdb; Wed, 6 Dec 2023 11:59:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaBRP659u6HkCyB25i2R6jz0ms5U8M9qD4FjnJGMEvqEL3O9N6eLg2K0oNV4aTljYVLw4a X-Received: by 2002:a05:6a00:3a1a:b0:68f:a92a:8509 with SMTP id fj26-20020a056a003a1a00b0068fa92a8509mr4514553pfb.7.1701892775957; Wed, 06 Dec 2023 11:59:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701892775; cv=none; d=google.com; s=arc-20160816; b=Lc1GOpGyokMOoxQrAK166x7PLeWNaVFF7P3yQ7Rq8QMCQt6GxT5HNUF+78ByrWdq4p FjsTEsYbVvalvrpyC0MPO4zX/U1Z3mv00z3Zae9fnOHiDCI/ajfw2QHJ5qvo8ChhHlDC rCk9SGONPMXOGUxNxEXiRYpBfFGD0sOUxLTpHJbDXV18iIjGR1dM5UiI/8d0I7OVH5Ui NAj/2WQyrLmW0UtOC2J2A9B71wiN05fYS3bw2vLPvkHvH7fgi4yFYVj8hJUFIhi6WZIH i/b8scG9V5BhgMx7lYha0M9lMOEDEu7B8LDgZ4hSP419zLxX1qDq8VfXQoZtMqzT96A+ 7w/w== 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:dkim-signature:date; bh=OKWTVUD6pNI5sfwR2s7nHIQDUaGAUMh3NMmi/eQhsxU=; fh=77Y51qntmFxKXvVLBBzUUorRuQgiD9cDGFK/koplS2g=; b=kMN41lGBPQo1CgT3gw1aLGzH7mvWhbUhMHjKOs7o+xxi8LLp2+kvSL4PbuBwpKQPWl sM+th/onLwrxsM5cHKAhxEvgwLP4GYzAJD560ap9k+OxhDiSewsFvAcBo+QIRlRtku3I 0xIBRVB46ZVuvaYnFEFpLMqwcu04NKIMICf35wV9yqd8lAx8tykOfbkWuAJ3gCl6KBPj yeneOI/1HL35i9vyoS+ZTO8Aw6qVgWlNCAg8AP+VNEEjSKJq2W3RL0MqG1XJkFWsBzy/ CnCmO58czj9F840aw/90tiGTzECducyE4ShUhQzZH8JACSPauF/1bLgp6XEih85tU7sO b1cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nv65MBxA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id u13-20020a056a00158d00b006cde2b3ccffsi443769pfk.32.2023.12.06.11.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 11:59:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nv65MBxA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 44EF281CCDA3; Wed, 6 Dec 2023 11:59:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379453AbjLFT7O (ORCPT + 99 others); Wed, 6 Dec 2023 14:59:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379450AbjLFT7N (ORCPT ); Wed, 6 Dec 2023 14:59:13 -0500 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [IPv6:2001:41d0:203:375::b7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D389D18D for ; Wed, 6 Dec 2023 11:59:18 -0800 (PST) Date: Wed, 6 Dec 2023 14:59:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1701892756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OKWTVUD6pNI5sfwR2s7nHIQDUaGAUMh3NMmi/eQhsxU=; b=nv65MBxAAe0NCibcnLcAiwM+n4KDdBAaLeRDHm2ExyqPwZbt/zn4HI8VawRezcuijp/IeD 7xPLBTHfO+LQZeXqrFoC2uIRW/27aP7n9yXPcM6VnBg2zMwQ19bwaLXeqwaqTz7548VI9L aFdp78NbXUkqAcN4j/oC9zlqf4F+37k= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Christian Brauner Cc: Peter Zijlstra , Alice Ryhl , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?B?QmrDtnJu?= Roy Baron , Benno Lossin , Andreas Hindborg , Alexander Viro , Greg Kroah-Hartman , Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Dan Williams , Kees Cook , Matthew Wilcox , Thomas Gleixner , Daniel Xu , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 5/7] rust: file: add `Kuid` wrapper Message-ID: <20231206195911.vcp3c6q57zvkm7bf@moria.home.lan> References: <20231129-alice-file-v1-0-f81afe8c7261@google.com> <20231129-alice-file-v1-5-f81afe8c7261@google.com> <20231129-etappen-knapp-08e2e3af539f@brauner> <20231129164815.GI23596@noisy.programming.kicks-ass.net> <20231130-wohle-einfuhr-1708e9c3e596@brauner> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231130-wohle-einfuhr-1708e9c3e596@brauner> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 11:59:33 -0800 (PST) On Thu, Nov 30, 2023 at 01:46:36PM +0100, Christian Brauner wrote: > On Wed, Nov 29, 2023 at 05:48:15PM +0100, Peter Zijlstra wrote: > > On Wed, Nov 29, 2023 at 05:28:27PM +0100, Christian Brauner wrote: > > > > > > +pid_t rust_helper_task_tgid_nr_ns(struct task_struct *tsk, > > > > + struct pid_namespace *ns) > > > > +{ > > > > + return task_tgid_nr_ns(tsk, ns); > > > > +} > > > > +EXPORT_SYMBOL_GPL(rust_helper_task_tgid_nr_ns); > > > > > > I'm a bit puzzled by all these rust_helper_*() calls. Can you explain > > > why they are needed? Because they are/can be static inlines and that > > > somehow doesn't work? > > > > Correct, because Rust can only talk to C ABI, it cannot use C headers. > > Bindgen would need to translate the full C headers into valid Rust for > > that to work. > > > > I really think the Rust peoples should spend more effort on that, > > because you are quite right, all this wrappery is tedious at best. I suspect even if the manpower existed to go that route we'd end up regretting it, because then the Rust compiler would need to be able to handle _all_ the craziness a modern C compiler knows how to do - preprocessor magic/devilry isn't even the worst of it, it gets even worse when you start to consider things like bitfields and all the crazy __attributes__(()) people have invented. Swift went that route, but they have Apple funding them, and I doubt even they would want anything to do with Linux kernel C. IOW: yes, the extra friction from not being able to do full C -> Rust translation is annoying now, but probably a good thing in the long run. > The problem is that we end up with a long list of explicit exports that > also are all really weirdly named like rust_helper_*(). I wouldn't even > complain if it they were somehow auto-generated but as you say that > might be out of scope. I think we'd need help from the C side to auto generate them - what we really want is for them to be inline, not static inline, but of course that has never really worked for functions used across a single C file. But maybe C compiler people are smarter these days? Just a keyword to to tell the C compiler "take this static inline and generate a compiled version in this .c file" would be all we need. I could see it being handy for other things, too: as Linus has been saying, we tend to inline too much code these days, and part of the reason for that is we make a function inline because of the _one_ fastpath that needs it, but there's 3 more slowpaths that don't. And right now we don't have any sane way of having a function be available with both inlined and outlined versions, besides the same kind of manual wrappers the Rust people are doing here... so we should probably just fix that.