> `struct page` is managed by a native reference count, and kernel C > code routinely takes its own references to pages, for example when a > page is inserted into a VMA with `vm_insert_page()`. > > Thus, implement `RefCounted` for `Page`, backed by `get_page()` and > `put_page()`, mark it `AlwaysRefCounted`, and return `ARef<Page>` from > `Page::alloc_page()`. The page is freed when the last reference to it is > dropped; for the order-0 pages allocated here, this is equivalent to > `__free_pages()`. > > This also allows `Page` references to be returned as borrowed > references without owning the `struct page`. Remove `BorrowedPage` > and update users to use `&Page` and `ARef<Page>`. > > Assisted-by: LLM > Suggested-by: Alice Ryhl <[email protected]> > Signed-off-by: Andreas Hindborg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=7
