Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2756566rdh; Mon, 30 Oct 2023 06:59:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFInSNjcQng/8o4REyuhzKSP/PNuZhBWI7+C/XcyBzztGk6LGSd8aIaJCaz4OZyako72ggU X-Received: by 2002:a05:6a20:8e24:b0:13a:dd47:c31a with SMTP id y36-20020a056a208e2400b0013add47c31amr15787198pzj.20.1698674348346; Mon, 30 Oct 2023 06:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698674348; cv=none; d=google.com; s=arc-20160816; b=r64WauC9myKwCcLUeRqy+FD6FVIeHbVYT3t7zBD0RiK5HbM/uM20mrlmFjkzRWH89D xdvV2eMeBOmJiPi84nUioLfWHuzC35ORNNegfd4J32zwM3OeH0JWvLavlCtQc0+gyGfE v6Uw47i0fdo3YRW6mIZHfF4ntbjQwaNcS+Wa893jh8aZ01pfkIIpslqvLYwsy0AP0EQ0 TqKG4sA43ERbZw900LNlzpYxatPBcWYyw8cy22sXtW5Lmldr9BSeX2IsaipTS14JR524 ZskC8jefNJej6TzGbGpXyWXgzY6usZZLYXq1j/VuPDxGTd31VJF1uTIxn2ly6KQ59Z9i 3TnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=Pwv0nNI/GXb5sK6crMnTZzX7DXnGnuo4VkjJxSyGGBE=; fh=tmoeJPrHTr3NLvkQoDRrxSSAyA3gkE6fiPTxYerb/xE=; b=dpnSIN/umG839Xupe9z3nEMMVFaY0l0Un8BRg99YfpVroolOGcEJNfTutT21Z6XIUx g0SFNMnzrPL5OTH7rybjptnmD1AqComKuBqQa1bqXdOOvs3tK0uaPUZ4wKn7Dblosj6z oi2kUKGAozseEWF8dJlfDtOvocmoiFxVs3cNt+eR5nYTsulK64DPQJjNnGOQnBb4rcZW acFi8hQjusDizg523ogV9GrmIgxKk8GV9pVk22hsXeXOqoY7PdbX2HpsUgxKwqWfxtPw GojV9g3WlaiaN+k4ZaV92v5PWt5lemYbi97SkV4WrUdOme3dcD5isTu5gdmtK/tw+ocJ HPvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Pw/SRXYo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k184-20020a6384c1000000b005b960674526si3366171pgd.779.2023.10.30.06.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Pw/SRXYo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EAB8780A1E2B; Mon, 30 Oct 2023 06:59:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232221AbjJ3N66 (ORCPT + 99 others); Mon, 30 Oct 2023 09:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232118AbjJ3N64 (ORCPT ); Mon, 30 Oct 2023 09:58:56 -0400 Received: from mail-ed1-x54a.google.com (mail-ed1-x54a.google.com [IPv6:2a00:1450:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A811DC1 for ; Mon, 30 Oct 2023 06:58:53 -0700 (PDT) Received: by mail-ed1-x54a.google.com with SMTP id 4fb4d7f45d1cf-542d910f34bso1437666a12.3 for ; Mon, 30 Oct 2023 06:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698674332; x=1699279132; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Pwv0nNI/GXb5sK6crMnTZzX7DXnGnuo4VkjJxSyGGBE=; b=Pw/SRXYoxDLks3cmJ83KKdDUaLJOw/++8rzzczrv5QNwLvEh6F/aVJ4p8Vm04Tu5ST uxoT1x1n7FxzK7ZAn2srR/K/yTwAfdbIeAYEuxwpyr3Iz/H/slZDCFi2x3TM/QbHZTXy 0fgOZvmzkr2c96W96XsJemLGGtK9rGVnG832Z7lJDXfDsrFvh/JIq2H20S+6La/asCPF XE1qRMs36ns1Vpzu/g4yS1N+6xp03dknrCTZrLJeVBh3YUu4oo2IPGZHOgxkPVauPDlI 2wf2LzII9tsSqUiPPYy0trkBFEKk5NJ82FQCOhJbHqfx+Ys3qx8Y2dDSdi/Rg4roxr3W FkGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698674332; x=1699279132; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Pwv0nNI/GXb5sK6crMnTZzX7DXnGnuo4VkjJxSyGGBE=; b=dykdl6v3QlXudgKjaGc5Y6YrnJ4s3HGa1asZbZwm5o6DFImUI/LejUEtfOsVTbfrBj mSRsoT/g89k+kRcmlQAhJSOq3TXpk0yiDIZTldX7tW0fLemxAsGFXSmExnBsMieCTOGW niv3iVtd9mNb7eex9jwt2wsOKF9fuw15HS6kH/cIzDp5quTftUBm+Q05otC8IPgUXs4u UrkbmiiGed/0GiLaeb+1Qlu0r6K1VzolOSDRspH7mntv8d6T3+2pgxHrg9BfnIFk/jcG WG/z7MEksmZ4SKmkq1066RnktSdSKl/tUO6Pzom1Ix92a46hGu80xpwPUtPrCLkv4j/N dAGw== X-Gm-Message-State: AOJu0Yyfeu2uBltfPj80x8tp70Qdv2WWOeE/ML0SJlZ1a/A5smr8S69r OZaqA835Lk335aER4eCBHup7LJgmwwArdIY= X-Received: from aliceryhl.c.googlers.com ([fda3:e722:ac3:cc00:31:98fb:c0a8:6c8]) (user=aliceryhl job=sendgmr) by 2002:a05:6402:f19:b0:53e:b944:d5ca with SMTP id i25-20020a0564020f1900b0053eb944d5camr92691eda.0.1698674332155; Mon, 30 Oct 2023 06:58:52 -0700 (PDT) Date: Mon, 30 Oct 2023 13:58:49 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231030135849.1587717-1-aliceryhl@google.com> Subject: Re: [RFC] rust: types: Add read_once and write_once From: Alice Ryhl To: boqun.feng@gmail.com Cc: a.hindborg@samsung.com, akiyks@gmail.com, alex.gaynor@gmail.com, aliceryhl@google.com, benno.lossin@proton.me, 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 Content-Type: text/plain; charset="utf-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Mon, 30 Oct 2023 06:59:06 -0700 (PDT) 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? I think `kernel::sync` is a reasonable choice, but here's another possibility: Put them in the `bindings` crate. 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. 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. Alice