public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
	"Miguel Ojeda" <ojeda@kernel.org>, "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 06:30:01 -0800	[thread overview]
Message-ID: <Z6DS6cIWgGsX7FXL@tardis.local> (raw)
In-Reply-To: <CAH5fLgjVyCSTyZqS7uSzWMTKvrxPL55PKUyM-H0RrnuZiU9VEg@mail.gmail.com>

On Mon, Feb 03, 2025 at 02:41:37PM +0100, Alice Ryhl wrote:
> On Mon, Feb 3, 2025 at 2:38 PM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > 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

Peter, are you talking about the POC idea I proposed on tracking irqsave
status:

	https://lore.kernel.org/rust-for-linux/20241018055125.2784186-1-boqun.feng@gmail.com/

? I'm working on this right now, however, I don't think this would help
spinlock or mutex nesting? Because there's no global(percpu) status of
acquiring these locks. Am I missing something here?

Regards,
Boqun

> > this should be doable too.
> >
> > But perhaps that never quite happened.
> 
> There isn't too much progress on that front lately, but you are right
> that this work could be extended to support this case too.
> 
> > 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.
> 
> I'll include those details, thanks!
> 
> Alice

  reply	other threads:[~2025-02-03 14:30 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
2025-02-03 13:41       ` Alice Ryhl
2025-02-03 14:30         ` Boqun Feng [this message]
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=Z6DS6cIWgGsX7FXL@tardis.local \
    --to=boqun.feng@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.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