Commit 08dde7ca authored by Alice Ryhl's avatar Alice Ryhl
Browse files

ANDROID: rust_binder: properly handle critical refcount increments



Whenever we need to deliver a refcount increment to the current thread,
we will try to deliver it by just scheduling the `Node` directly. It is
expected that this will work most of the time, but it is possible that
the `Node` has already been scheduled on a different list. If that is
the case, we allocate a new wrapper struct around the node and schedule
that to the current thread instead.

By only using the wrappers when the `Node` is already scheduled, we
should hopefully avoid allocating memory for these wrappers outside of
rare edge cases.

After using a Pixel phone for a few minutes with this patch applied, I
observed three calls to CritIncrWrapper::new. This confirms that the
edge case is rare, but also that it can happen in practice. None of the
assertions were triggered.

Bug: 333535706
Change-Id: I26d694205bf42c935886bf3561ebd407e67895ee
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
parent 39285e9a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment