ANDROID: rust_binder: add vma shrinker
When the system is under memory pressure, we want the driver to release unused pages. We do this by registering a memory shrinker with the kernel. The data for incoming transactions is stored in an mmap'ed region. Previously in this patch series, we just allocated all of the pages in that region immediately. With this patch series, we do not allocate the pages until we need them. Furthermore, when we no longer need a page, we mark it as "available" using an lru list. If the system is under memory pressure, this allows the shrinker to free that page by removing it from the lru list. If we need to use the page again before the shrinker frees it, then we just remove it from the lru list, and we don't need to reallocate the page. The page range abstraction is split into a fast path and slow path. The slow path is only used when a page is not allocated, which should only happen on first use, and when the system is under memory pressure. I'm not yet completely happy with this implementation. Specifically, I would like to improve the robustness of the unsafe code found in `allocation.rs`. The slow-path/fast-path implementation in `page_range.rs` is different from C Binder's current implementation, and was suggested to me by Carlos. Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-19-08ba9197f637@google.com/ Change-Id: I9f5c3619db4f1d0291ed4476c76494d951822906 Suggested-by:Carlos Llamas <cmllamas@google.com> Signed-off-by:
Alice Ryhl <aliceryhl@google.com> Bug: 278052745
Loading
Please sign in to comment