Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2858882rdh; Mon, 30 Oct 2023 09:37:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEeSVbSh1JopFbkGytCr2hV8+QqFkxC3ADZDLdwg6+WSXZfUeBB8cGjbGdHBnnxFMZ6vIg X-Received: by 2002:a05:6a20:5511:b0:16c:13b1:2c6d with SMTP id ko17-20020a056a20551100b0016c13b12c6dmr6573596pzb.56.1698683820659; Mon, 30 Oct 2023 09:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698683820; cv=none; d=google.com; s=arc-20160816; b=WEx7IuhXj09vyXPOi6EHgEMHzN41pKgoELsfaGS7iIpfzH16azFJbua5DKE3RfflqK ETy/hdS+MqMWHszBPqthbhix5zCa2Z7QiBrUw02LN/eKHmfbAB9obhrDGiBPJuL1VawJ Sw1pNO7oDiTsJm6gJMidovg40/ujUBKdwFW+RzKjY5xRi1QG+8qKznCJSTl8sP7U3s56 bP4ny2vTYCCAUBR9Y4GOaeO6eeIc74ottaz19EyQu7ZsNUYU7dT87m9WsdLwziwqQ1Ut pMxavn3tr0xEdQznCdTq80a6BdCjRAeptkbygEPg5CcEqfEO4tXVCJ498/DUUX0V5nZA QD7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :date:dkim-signature; bh=48kbBn6jkCTqXGMjhvy3WCOjTju2J1w8JsfGvQF5nCY=; fh=qpuvJ3HdsIp7LkqbnA6JmJ7wMaqF3xVjFWOblXJRoH8=; b=VJ5csE6g8xU2Ba+EgCIJzKRDTAmQs9L526wys1KstIs75ZrbV05epQrci8jqWedKQX iDy44gg9xpOJzMIb6xdyU32R7maBxtc4NyEoQKDyRmpp3C1RIYS4t0an86utdqft9ynz fdMxQCrg3/t4t2yhr/CCgXi9LSq8CAkErbtmcXQ2Q9pwVbVx+Pgxms6ldmKnhOn3+Bz8 BJO2Yt1bFkBKOdmfbjL6x5pOe0JCLAn9dAP3HS6XNE9X7SAVF/tQ/wQ/I6xOCB7QXpBn sMOGbBL+R5ORvFvKHiYDk04UQGoV2BSXA2KlhMtOs7WJt2axt6y771272e41b9dm3od1 IgHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=PhRquX5X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a5-20020a656045000000b00565f0e9cfbbsi5420704pgp.382.2023.10.30.09.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 09:37:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=PhRquX5X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A6BB380C9CA0; Mon, 30 Oct 2023 09:36:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233692AbjJ3Qg6 (ORCPT + 99 others); Mon, 30 Oct 2023 12:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233878AbjJ3Qg4 (ORCPT ); Mon, 30 Oct 2023 12:36:56 -0400 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1D40D9; Mon, 30 Oct 2023 09:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1698683810; x=1698943010; bh=48kbBn6jkCTqXGMjhvy3WCOjTju2J1w8JsfGvQF5nCY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=PhRquX5XYbL9cmO7eGIsQTKgbWiey1WWXX6Do83etj6fuvfXkDAqA3RenBNzoUVff h1qpb0am7m9QzyFK+RNca7nXY/R5ImWaFT+NWuLrTxrMbub8JMoJfzElJ2ig2ayipA LkCnen1dGXfizTga5QtT63EV8vhw8chLuSVS/tmVVvyreapStbIiSteQSdMMRFxhk7 cmlYv26RpBAxXc+vSJkjEY3yjUkqF/CHGqpYpwIHfaci7gURYLaNNiE73lQtyHJjju QosB5KTUVI2oc1VPPcxLSzRt1mqoMSqDcXGQ/a/O4dmvh0isW00EEFUiJFX1pspbln jRslf8uKPncBA== Date: Mon, 30 Oct 2023 16:36:35 +0000 To: Alice Ryhl From: Benno Lossin Cc: boqun.feng@gmail.com, a.hindborg@samsung.com, akiyks@gmail.com, alex.gaynor@gmail.com, bjorn3_gh@protonmail.com, brauner@kernel.org, david@fromorbit.com, dhowells@redhat.com, dlustig@nvidia.com, elver@google.com, gary@garyguo.net, gregkh@linuxfoundation.org, j.alglave@ucl.ac.uk, joel@joelfernandes.org, kent.overstreet@gmail.com, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, luc.maranget@inria.fr, nathan@kernel.org, ndesaulniers@google.com, npiggin@gmail.com, ojeda@kernel.org, parri.andrea@gmail.com, paulmck@kernel.org, peterz@infradead.org, rust-for-linux@vger.kernel.org, stern@rowland.harvard.edu, trix@redhat.com, viro@zeniv.linux.org.uk, wedsonaf@gmail.com, will@kernel.org, willy@infradead.org Subject: Re: [RFC] rust: types: Add read_once and write_once Message-ID: In-Reply-To: <20231030135849.1587717-1-aliceryhl@google.com> References: <20231030135849.1587717-1-aliceryhl@google.com> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 30 Oct 2023 09:36:59 -0700 (PDT) On 30.10.23 14:58, Alice Ryhl wrote: > Boqun Feng writes: >>> On Wed, Oct 25, 2023 at 09:51:28PM +0000, Benno Lossin wrote: >>>> diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs >>>> index d849e1979ac7..b0872f751f97 100644 >>>> --- a/rust/kernel/types.rs >>>> +++ b/rust/kernel/types.rs >>> >>> I don't think this should go into `types.rs`. But I do not have a good >>> name for the new module. >> >> kernel::sync? >=20 > I think `kernel::sync` is a reasonable choice, but here's another > possibility: Put them in the `bindings` crate. >=20 > Why? Well, they are a utility that intends to replicate the C > `READ_ONCE` and `WRITE_ONCE` macros. All of our other methods that do > the same thing for C functions are functions in the bindings crate. I think we should keep things separate, that way `bindings` can be fully automatically generated. Stuff in the bindings crate is just an interface to the C world. Functions are not implemented there, but rather linked to. > Similarly, if we ever decide to reimplement a C function in Rust for > performance/inlining reasons, then I also think that it is reasonable to > put that Rust-reimplementation in the bindings crate. This approach also > makes it easy to transparently handle cases where we only reimplement a > function in Rust under some configurations. Is it really going to make things easier? We would have to make bindgen conditionally not create bindings for an item, so I think it would be easier to just always have the bindings function and handle the conditional reimplementation fully in the Rust code. Having extra code in the bindings crate will also make it more difficult to ensure that only abstractions use the bindings (we already have some exceptions, but why make it worse?). --=20 Cheers, Benno