Re: [PATCH] rust_binder: add TF_DEFER_COMPLETE flag for avoiding userspace roundtrip

From: Alice Ryhl

Date: Thu Jul 16 2026 - 08:29:05 EST


On Thu, Jul 16, 2026 at 11:20:56AM +0000, Alice Ryhl wrote:
> + {
> + // 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;
> + }

Sashiko makes a good point that we must be a bit more careful here. If
we find that that the thread-local queue only contains the deferred
completion, but that the process-global queue is non-empty, we must
still deliver the deferred completion first before taking anything from
the process-global queue.

Alice