From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: "Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Lyude Paul" <lyude@redhat.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Carlos Llamas" <cmllamas@google.com>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Petr Pavlu" <petr.pavlu@suse.com>,
"Daniel Gomez" <da.gomez@kernel.org>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Aaron Tomlin" <atomlin@atomlin.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Tamir Duberstein" <tamird@kernel.org>,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 1/3] rust: sync: return `Result<&T, T>` from `SetOnce::populate()`
Date: Wed, 29 Jul 2026 23:09:32 +0900 [thread overview]
Message-ID: <DKB45883L8T8.2TOSLCGCMSHYM@nvidia.com> (raw)
In-Reply-To: <20260722-setonce-populate-v1-1-fa7455c26c42@google.com>
On Wed Jul 22, 2026 at 6:16 PM JST, Alice Ryhl wrote:
> When `populate()` succeeds, there's no way infallible way to get the
> value that was just inserted. By returning &T in this case, such
> infallible access methods become possible.
>
> Additionally, when `populate()` fails, the provided value is dropped.
> This has two disadvantages:
>
> 1. If the caller holds a lock, the value is dropped under said lock.
> 2. If the caller wishes to use the same value for something else, they
> can't, because it's lost.
>
> Changing the return value to Result<&T, T> handles all of these cases.
>
> Rust Binder is updated to avoid a warning about an unused Result.
Does the GEM shmem module also need to be updated for the same reason?
next prev parent reply other threads:[~2026-07-29 14:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 9:16 [PATCH 0/3] rust: sync: add SetOnce::try_get_or_populate() Alice Ryhl
2026-07-22 9:16 ` [PATCH 1/3] rust: sync: return `Result<&T, T>` from `SetOnce::populate()` Alice Ryhl
2026-07-29 14:09 ` Alexandre Courbot [this message]
2026-07-22 9:16 ` [PATCH 2/3] rust: sync: add SetOnce::try_get_or_populate() Alice Ryhl
2026-07-29 14:05 ` Alexandre Courbot
2026-07-29 14:23 ` Boqun Feng
2026-07-30 9:11 ` Alice Ryhl
2026-07-30 14:48 ` Alexandre Courbot
2026-07-31 12:52 ` Alice Ryhl
2026-08-02 1:03 ` Alexandre Courbot
2026-07-22 9:16 ` [PATCH 3/3] rust_binder: use SetOnce::try_get_or_populate() Alice Ryhl
2026-07-29 14:12 ` [PATCH 0/3] rust: sync: add SetOnce::try_get_or_populate() Alexandre Courbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DKB45883L8T8.2TOSLCGCMSHYM@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=atomlin@atomlin.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=cmllamas@google.com \
--cc=da.gomez@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=mcgrof@kernel.org \
--cc=ojeda@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome