ANDROID: rust_binder: add work lists
The binder driver uses linked lists of work items to store events that need to be delivered to userspace. There are work lists on both the process and threads. Work items are expected to implement the `DeliverToRead` trait, whose name signifies that this type is something that can be delivered to userspace via the read part of the `BINDER_WRITE_READ` ioctl. The trait defines what happens when a work item is executed, when it is cancelled, how the thread should be notified (`wake_up_interruptible_sync` or `wake_up_interruptible`?), and how it can be enqueued to a linked list. For each type that implements the trait, Rust will generate a vtable for the type. Pointers to the `dyn DeliverToRead` type will be fat pointers where the metadata of the pointer is a pointer to the vtable. We introduce the concept of a "ready thread". This is a thread that is currently waiting for work items inside the `get_work` method. The process will keep track of them and deliver new work items to one of the ready threads directly. When there are no ready threads, work items are stored in the process work list. Note that not all work items are delivered using the "ready thread" functionality. For example, in a future patch, transactions that are already part of a transaction stack are delivered directly to the appropriate thread instead. The work lists added in this patch are not used yet, so the `push_work` methods are marked with `#[allow(dead_code)]` to silence the warnings about unused methods. A user is added in the next patch of this patch set. Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-4-08ba9197f637@google.com/ Change-Id: I4a7c2db2a9b49996d50ca9544e8eb187d45f0566 Co-developed-by:Wedson Almeida Filho <wedsonaf@gmail.com> Signed-off-by:
Wedson Almeida Filho <wedsonaf@gmail.com> Signed-off-by:
Alice Ryhl <aliceryhl@google.com> Bug: 278052745
Loading
Please sign in to comment