public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Ingo Molnar" <mingo@redhat.com>, "Will Deacon" <will@kernel.org>,
	"Waiman Long" <longman@redhat.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: sync: add wait_interruptible_freezable
Date: Mon, 3 Feb 2025 14:38:43 +0100	[thread overview]
Message-ID: <20250203133843.GG7145@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAH5fLggyyP1A=uNxr2iYNKOj0V5rxZRU83TRgs6Ah1uJ=Ee2uA@mail.gmail.com>

On Mon, Feb 03, 2025 at 12:56:05PM +0100, Alice Ryhl wrote:
> On Mon, Feb 3, 2025 at 12:54 PM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Thu, Jan 30, 2025 at 11:30:44AM +0000, Alice Ryhl wrote:
> > > Binder allows you to freeze a process where some of its threads are
> > > blocked on the Binder driver. To make this work, we need to pass
> > > TASK_FREEZABLE when going to sleep in the appropriate places. Thus, add
> > > a new method wait_interruptible_freezable for the condition variable so
> > > that sleeps where this is supported can be marked as such.
> >
> > The constraint on freezable is that you must not hold locks. There is a
> > lockdep check for this in the code, but it would probably make sense to
> > teach Rust about this constraint as well, hmm?
> 
> Unfortunately, I don't think there's any way to enforce this at
> compile time, but I'm definitely happy to add this in the
> documentation.

Ah, ISTR people talking about teaching Rust about the whole raw_spinlock
vs spinlock vs mutex nesting order and figured if it can do that, then
this should be doable too.

But perhaps that never quite happened.

Yes, documentation would be good. Just in case it isn't obviuos,
freezing a task that holds a lock can trivially deadlock vs another task
that needs that lock to complete before it too can hit freezable.

  reply	other threads:[~2025-02-03 13:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 11:30 [PATCH] rust: sync: add wait_interruptible_freezable Alice Ryhl
2025-02-03 11:54 ` Peter Zijlstra
2025-02-03 11:56   ` Alice Ryhl
2025-02-03 13:38     ` Peter Zijlstra [this message]
2025-02-03 13:41       ` Alice Ryhl
2025-02-03 14:30         ` Boqun Feng
2025-02-05 12:15           ` Alice Ryhl

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=20250203133843.GG7145@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --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