From: sashiko-bot@kernel.org
To: "Andreas Hindborg" <a.hindborg@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Uladzislau Rezki" <urezki@gmail.com>,
"David Hildenbrand" <david@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>,
"Brendan Jackman" <brendan.jackman@linux.dev>,
"Johannes Weiner" <hannes@cmpxchg.org>, "Zi Yan" <ziy@nvidia.com>,
"Mike Rapoport" <rppt@kernel.org>,
"Joshua Hahn" <joshua.hahnjy@gmail.com>,
"Rakie Kim" <rakie.kim@sk.com>,
"Gregory Price" <gourry@gourry.net>,
"Ying Huang" <ying.huang@linux.alibaba.com>,
"Matthew Wilcox" <willy@infradead.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Christian Brauner" <brauner@kernel.org>,
"Carlos Llamas" <cmllamas@google.com>
Cc: "Igor B" <igor.b@beldev.am>,
"Vitaly Wool" <vitaly.wool@konsulko.se>,
linux-mm@kvack.org
Subject: Re: [PATCH v22 1/6] rust: page: add page kinds and make `Page` reference counted
Date: Thu, 19 Nov 2026 16:20:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-223511@kernel.org> (raw)
In-Reply-To: <20261118-page-ownable-v22-1-d63ff73f4075@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] rust: page: missing #[inline] on Vmalloc::to_page() and
Page::as_ptr()
--
commit 36a035122eaf9c7ebb69272cab04826c581553f8
Author: Andreas Hindborg <a.hindborg@kernel.org>
rust: page: add page kinds and make `Page` reference counted
This commit makes Page generic over a sealed PageKind trait with Base and
RefCounted kinds, implements RefCounted and AlwaysRefCounted for
Page<RefCounted>, and replaces BorrowedPage with references to Page<Base>.
> diff --git a/rust/kernel/alloc/allocator.rs b/rust/kernel/alloc/allocator.rs
> index cd4203f27aed0..bf20714156c53 100644
> --- a/rust/kernel/alloc/allocator.rs
> +++ b/rust/kernel/alloc/allocator.rs
[ ... ]
> @@ -202,20 +205,19 @@ impl Vmalloc {
> ///
> /// - `ptr` must be a valid pointer to a [`Vmalloc`] allocation.
> /// - `ptr` must remain valid for the entire duration of `'a`.
> - pub unsafe fn to_page<'a>(ptr: NonNull<u8>) -> page::BorrowedPage<'a> {
> + pub unsafe fn to_page<'a>(ptr: NonNull<u8>) -> &'a Page<Base> {
> // SAFETY: `ptr` is a valid pointer to `Vmalloc` memory.
> let page = unsafe { bindings::vmalloc_to_page(ptr.as_ptr().cast()) };
>
> - // SAFETY: `vmalloc_to_page` returns a valid pointer to a `struct page` for a valid pointer
> - // to `Vmalloc` memory.
> - let page = unsafe { NonNull::new_unchecked(page) };
> -
> + // INVARIANT: `Base` has no invariants in addition to the validity of the `struct page`,
> + // which is argued below.
> // SAFETY:
> - // - `page` is a valid pointer to a `struct page`, given that by the safety requirements of
> - // this function `ptr` is a valid pointer to a `Vmalloc` allocation.
> - // - By the safety requirements of this function `ptr` is valid for the entire lifetime of
> - // `'a`.
> - unsafe { page::BorrowedPage::from_raw(page) }
> + // - `vmalloc_to_page` returns a valid, non-null pointer to a `struct page` for a valid
> + // pointer to `Vmalloc` memory, given that by the safety requirements of this function
> + // `ptr` is a valid pointer to a `Vmalloc` allocation.
> + // - By the safety requirements of this function `ptr`, and hence the `struct page`, is
> + // valid for the entire lifetime of `'a`.
> + unsafe { &*page.cast() }
> }
> }
[ ... ]
> diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs
> index 1c0796ea229f0..b2a17c86e7de0 100644
> --- a/rust/kernel/page.rs
> +++ b/rust/kernel/page.rs
[ ... ]
> @@ -185,19 +192,22 @@ impl Page {
[ ... ]
> +impl<Kind: PageKind> Page<Kind> {
> /// Returns a raw pointer to the page.
> pub fn as_ptr(&self) -> *mut bindings::page {
> - self.page.as_ptr()
> + self.page.get()
> }
[Severity: Low]
Should Vmalloc::to_page() and Page::as_ptr() be marked #[inline]?
Vmalloc::to_page() is a non-generic wrapper in the kernel crate that
forwards directly to bindings::vmalloc_to_page(), and Page::as_ptr() is a
one-line accessor called by #[inline] methods such as Page::nid() and
Page::inc_ref().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-page-ownable-v22-0-d63ff73f4075@kernel.org?part=1
next prev parent reply other threads:[~2026-11-19 16:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 16:18 [PATCH v22 0/6] rust: page: add page kinds Andreas Hindborg
2026-11-18 16:18 ` [PATCH v22 1/6] rust: page: add page kinds and make `Page` reference counted Andreas Hindborg
2026-11-19 16:20 ` sashiko-bot [this message]
2026-11-18 16:18 ` [PATCH v22 2/6] rust: page: add `from_raw()` Andreas Hindborg
2026-11-18 16:18 ` [PATCH v22 3/6] mm/page_alloc: make alloc_frozen_pages() available outside of mm Andreas Hindborg
2026-11-18 16:18 ` [PATCH v22 4/6] rust: page: add `Exclusive` page kind for race-free page access Andreas Hindborg
2026-11-18 16:18 ` [PATCH v22 5/6] rust: page: add `Frozen` page kind Andreas Hindborg
2026-11-18 16:18 ` [PATCH v22 6/6] rust: page: add slice access to `Page<Exclusive>` Andreas Hindborg
2026-11-18 17:02 ` [PATCH v22 0/6] rust: page: add page kinds Zi Yan
2026-11-18 19:34 ` Andreas Hindborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-223511@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=brauner@kernel.org \
--cc=brendan.jackman@linux.dev \
--cc=cmllamas@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=david@kernel.org \
--cc=gary@garyguo.net \
--cc=gourry@gourry.net \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.org \
--cc=igor.b@beldev.am \
--cc=joshua.hahnjy@gmail.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=lossin@kernel.org \
--cc=mhocko@suse.com \
--cc=ojeda@kernel.org \
--cc=rakie.kim@sk.com \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=surenb@google.com \
--cc=tamird@kernel.org \
--cc=tkjos@android.com \
--cc=tmgross@umich.edu \
--cc=urezki@gmail.com \
--cc=vbabka@kernel.org \
--cc=vitaly.wool@konsulko.se \
--cc=willy@infradead.org \
--cc=work@onurozkan.dev \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox