From: Alice Ryhl <aliceryhl@google.com>
To: Carlos Llamas <cmllamas@google.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Todd Kjos" <tkjos@android.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"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>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] rust_binder: add TF_DEFER_COMPLETE flag for avoiding userspace roundtrip
Date: Tue, 11 Aug 2026 17:40:07 +0000 [thread overview]
Message-ID: <anted6Qc-yHE8cMh@google.com> (raw)
In-Reply-To: <anpinBy0adT0JDVn@google.com>
On Mon, Aug 10, 2026 at 11:45:32PM +0000, Carlos Llamas wrote:
> On Wed, Jul 22, 2026 at 09:09:22PM +0000, Alice Ryhl wrote:
> > Userspace only actually specifies TF_DEFER_COMPLETE when the Parcel does
> > not contain fds or refcounts on binder objects. This is because
> > otherwise said fd or binder node will not be freed until the binder
> > thread receives another incoming transaction, which could be a long
> > time. In the case of fds, this is especially important because delaying
> > fclose() can result in processes hanging because they read from a pipe
> > that isn't being closed due to fclose() not getting called. Note that
> > even if TF_DEFER_COMPLETE is not specified for this transaction, it can
> > still be useful to defer the BC_REPLY command, as it can still avoid a
> > userspace roundtrip when a new incoming transaction is available right
> > away.
>
> The processing of a deferred COMPLETE doesn't change right? It doesn't
> matter if the kernel rejects / ignores the new flag, userspace will
> still follow the same path. 100% backward-compatible then.
Yes. In fact, if userspace passes the flag to a kernel without support
for it, the only consequence is worse perf (extra userspace roundtrips).
It will still work correctly.
> > + // Note that if the thread list is empty, then the call to `pop_work()` has changed
> > + // `process_work_list` back to `false` even if we set it to `true` above.
> > + thread_has_deferred_work = inner.process_work_list;
>
> I might be getting this wrong, but for the new TF_DEFER_COMPLETE case,
> we have !process_work_list and !work_list.is_empty(). Then pop_work()
> does not touch process_work_list because it's already false.
>
> So we set thread_has_deferred_work to false? Maybe this was meant to be:
> thread_has_deferred_work = !inner.work_list.is_empty()
You're right.
> > + {
> > + // This performs a deferred push so that `read` can wait for the next incoming
> > + // transaction without a userspace roundtrip.
> > + let mut inner = self.inner.lock();
> > + inner.push_work_deferred(completion);
> > + // However, if `TF_DEFER_COMPLETE` is not set, then set `process_work_list` to make
> > + // the push non-deferred. This forces a userspace roundtrip.
> > + inner.process_work_list |= info.flags & TF_DEFER_COMPLETE == 0;
>
> If there is already a push_work() and a push_work_deferred() why use
> process_work_list directly? Is it to avoid an if/else?
I guess so ...
Alice
prev parent reply other threads:[~2026-08-11 17:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 21:09 [PATCH v2] rust_binder: add TF_DEFER_COMPLETE flag for avoiding userspace roundtrip Alice Ryhl
2026-07-23 11:58 ` Alice Ryhl
2026-08-10 23:45 ` Carlos Llamas
2026-08-11 17:40 ` Alice Ryhl [this message]
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=anted6Qc-yHE8cMh@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=cmllamas@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tkjos@android.com \
--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