public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: lyude@redhat.com
To: Alice Ryhl <aliceryhl@google.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	rust-for-linux@vger.kernel.org, Gary Guo <gary@garyguo.net>,
	Ingo Molnar	 <mingo@redhat.com>, Miguel Ojeda <ojeda@kernel.org>,
	Tamir Duberstein	 <tamird@kernel.org>,
	Boqun Feng <boqun@kernel.org>,
	Peter Zijlstra	 <peterz@infradead.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Benno Lossin	 <lossin@kernel.org>, Will Deacon <will@kernel.org>
Subject: Re: [PATCH v2 2/2] rust: sync: Introduce LazyInit
Date: Mon, 01 Jun 2026 18:26:04 -0400	[thread overview]
Message-ID: <fe3c191db743897eace3e50d9994269b45f16d3f.camel@redhat.com> (raw)
In-Reply-To: <ah1CarNtFhCvAAav@google.com>

On Mon, 2026-06-01 at 08:27 +0000, Alice Ryhl wrote:
> I'm not a big fan of using these kinds of tricks to access the
> contents
> of a mutex after unlocking it. Could we instead use a struct like
> this:
> 
> struct LazyInit<T> {
>     data: UnsafeCell<MaybeUninit<T>>,
>     set: AtomicBool,
>     lock: Mutex<()>,
> }
> 
> or even:
> 
> struct LazyInit<T> {
>     data: SetOnce<T>,
>     lock: Mutex<()>,
> }
> 
> I think this logic will be simpler for everyone.

> By the way, another option is to use a similar strategy to
> https://lore.kernel.org/rust-for-linux/20260523-upgrade-poll-v4-2-f5b4c747eac2@google.com/
> where you just use SetOnce and protect calls to `populate` by another
> mutex in the structure. Then you don't need a separate LazyInit.

ooo - yeah, that definitely works for me and would be preferable. I
still will like to make one change to SetOnce that I think isn't too
crazy: writing up a `reset()` function for SetOnce that works through a
&mut like what I had here for LazyInit, since that would be quite
helpful to have in the gem shmem free_callback() function.

> 
> Alice


  reply	other threads:[~2026-06-01 22:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 17:30 [PATCH v2 0/2] rust: sync: Introduce LazyInit Lyude Paul
2026-05-29 17:30 ` [PATCH v2 1/2] rust: sync: lock: Add Lock::get_mut_pinned() Lyude Paul
2026-06-01  8:28   ` Alice Ryhl
2026-06-04  6:11   ` Claude review: " Claude Code Review Bot
2026-05-29 17:30 ` [PATCH v2 2/2] rust: sync: Introduce LazyInit Lyude Paul
2026-06-01  8:27   ` Alice Ryhl
2026-06-01 22:26     ` lyude [this message]
2026-06-04  6:11   ` Claude review: " Claude Code Review Bot
2026-06-04  6:11 ` Claude Code Review Bot

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=fe3c191db743897eace3e50d9994269b45f16d3f.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=aliceryhl@google.com \
    --cc=boqun@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mingo@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=will@kernel.org \
    /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