BorrowedPage and PageOwner
Subsystems (3)
Danilo Krummrich
maintainerv2 cover BorrowedPage and PageOwner
This patch series implements the BorrowedPage type and the PageOwner trait.
The latter can be implemented by any entity that potentially owns one or multiple pages and allow users to borrow them.
For instance, this is useful to access and borrow the backing pages of allocation primitives, such as Box and Vec, backing a scatterlist.
Hence, implement PageOwner for VBox and VVec.
Additionally, implement Vmalloc::to_page() and ArrayLayout::size(), which are dependencies of the above.
Changes in v2:
- BorrowedPage
- Add link to Ownable
- Use borrow_page() in the example
- Add PageOwner, Vmalloc::to_page(), ArrayLayout, VBox, VVec patches.
Danilo Krummrich (6):
rust: page: implement BorrowedPage
rust: page: define PageOwner trait
rust: alloc: vmalloc: implement Vmalloc::to_page()
rust: alloc: layout: implement ArrayLayout::size()
rust: alloc: kbox: implement PageOwner for VBox
rust: alloc: kvec: implement PageOwner for VVec
rust/bindings/bindings_helper.h | 1 + rust/kernel/alloc/allocator.rs | 49 +++++++++++++++++++ rust/kernel/alloc/kbox.rs | 42 ++++++++++++++++ rust/kernel/alloc/kvec.rs | 40 +++++++++++++++ rust/kernel/alloc/layout.rs | 5 ++ rust/kernel/page.rs | 87 ++++++++++++++++++++++++++++++++- 6 files changed, 223 insertions(+), 1 deletion(-)
base-commit: d2eedaa3909be9102d648a4a0a50ccf64f96c54f
Signature · 1 line
2.50.1
Danilo Krummrich
maintainerPATCH v2 1/6 rust: page: implement BorrowedPage
Currently, a Page always owns the underlying struct page.
However, sometimes a struct page may be owned by some other entity, e.g. a vmalloc allocation.
Hence, introduce BorrowedPage to support such cases, until the Ownable solution [1] lands.
This is required by the scatterlist abstractions.
--- rust/bindings/bindings_helper.h | 1 + rust/kernel/page.rs | 75 ++++++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-)
rust/bindings/bindings_helper.h +1 -0
@@ -57,6 +57,7 @@#include <linux/jiffies.h> #include <linux/jump_label.h> #include <linux/mdio.h> +#include <linux/mm.h> #include <linux/miscdevice.h> #include <linux/of_device.h> #include <linux/pci.h>
rust/kernel/page.rs +74 -1
87 lines not on this page · raw message
Signature · 1 line
2.50.1
Danilo Krummrich
maintainerPATCH v2 2/6 rust: page: define PageOwner trait
In reply to Danilo KrummrichIntroduce the PageOwner trait, which can be implemented by any entity that potentially owns one or multiple pages and allow users to borrow them.
For instance, this is useful to access and borrow the backing pages of allocation primitives, such as Box and Vec, backing a scatterlist.
--- rust/kernel/page.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+)
rust/kernel/page.rs +12 -0
@@ -103,6 +103,18 @@ fn deref(&self) -> &Self::Target { } } +/// Represents a potential owner of one or multiple [`Page`]s. +/// +/// This trait may be implemented by types that potentially hold ownership of memory pages. It +/// allows users to iterate over those pages and borrow them as [`BorrowedPage`]. +pub trait PageOwner { +/// Returns an [`Iterator`] of [`BorrowedPage`] items over all pages owned by `self`. +fn page_iter <'a>(&'amut self) ->impl Iterator <Item =BorrowedPage <'a>>; + +/// Returns the number of pages currently owned by `self`. +fn page_count (&self) ->usize ; +} +/// A pointer to a page that owns the page allocation. /// /// # Invariants
Signature · 1 line
2.50.1
Alexandre Courbot
reviewerRe: [PATCH v2 2/6] rust: page: define PageOwner trait
Quoted 17 lines · Danilo Krummrich
Introduce the PageOwner trait, which can be implemented by any entity that potentially owns one or multiple pages and allow users to borrow them.
For instance, this is useful to access and borrow the backing pages of allocation primitives, such as Box and Vec, backing a scatterlist.
Signed-off-by Danilo Krummrich <[email protected]>--- rust/kernel/page.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+)rust/kernel/page.rs +0
-0
rust/kernel/page.rs fn deref(&self) -> &Self::Target { · line 108
Quoted 6 lines
rust/kernel/page.rs +3
-0@@ -103,6 +103,18 @@ fn deref(&self) -> &Self::Target { } } +/// Represents a potential owner of one or multiple [`Page`]s. +/// +/// This trait may be implemented by types that potentially hold ownership of memory pages. It
Why "potentially"? I'd expect types implement this to be certain about their ownership of the memory they share. :)
rust/kernel/page.rs fn deref(&self) -> &Self::Target { · line 115
Quoted 7 lines
rust/kernel/page.rs +7
-0+/// allows users to iterate over those pages and borrow them as [`BorrowedPage`]. +pub trait PageOwner { +/// Returns an [`Iterator`] of [`BorrowedPage`] items over all pages owned by `self`. +fn page_iter <'a>(&'amut self) ->impl Iterator <Item =BorrowedPage <'a>>; + +/// Returns the number of pages currently owned by `self`. +fn page_count (&self) ->usize ;
Should we add a mention that page_iter is guaranteed to yield page_count pages? If this is part of the contract, should the trait be made unsafe as this guarantee cannot be held by a safe trait?
If so, I am wondering whether we should also take the next step and make page_iter return an ExactSizeIterator while requiring that its len method is accurate. This would allow us to remove page_count altogether.
Alice Ryhl
maintainerRe: [PATCH v2 2/6] rust: page: define PageOwner trait
In reply to Danilo KrummrichQuoted 21 lines · Danilo Krummrich
Introduce the PageOwner trait, which can be implemented by any entity that potentially owns one or multiple pages and allow users to borrow them.
For instance, this is useful to access and borrow the backing pages of allocation primitives, such as Box and Vec, backing a scatterlist.
Signed-off-by Danilo Krummrich <[email protected]>--- rust/kernel/page.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+)rust/kernel/page.rs +1
-0@@ -103,6 +103,18 @@ fn deref(&self) -> &Self::Target { } } +/// Represents a potential owner of one or multiple [`Page`]s.
rust/kernel/page.rs fn deref(&self) -> &Self::Target { · line 116
Quoted 10 lines
rust/kernel/page.rs +10
-0+/// +/// This trait may be implemented by types that potentially hold ownership of memory pages. It +/// allows users to iterate over those pages and borrow them as [`BorrowedPage`]. +pub trait PageOwner { +/// Returns an [`Iterator`] of [`BorrowedPage`] items over all pages owned by `self`. +fn page_iter <'a>(&'amut self) ->impl Iterator <Item =BorrowedPage <'a>>; + +/// Returns the number of pages currently owned by `self`. +fn page_count (&self) ->usize ; +}
Honestly, I don't entirely love this trait on its own merits. But I'd need to know more about how it will be used to give a clearer opinion.
Either way, I think the implementation of VBox and VVec could be merged to some shared VmallocPageIter that iterates a region of pages.
Alice
Danilo Krummrich
maintainerRe: [PATCH v2 2/6] rust: page: define PageOwner trait
Quoted 2 lines · Alice Ryhl
Either way, I think the implementation of VBox and VVec could be merged to some shared VmallocPageIter that iterates a region of pages.
I really like this idea. A VmallocPageIter type allows us to make more assumptions about the pages, e.g. that they're (contiguously) mapped in the virtual address space, which is useful as well.
I'm going to drop the PageOwner trait for now and provide a VmallocPageIter type instead.
- Danilo
Danilo Krummrich
maintainerPATCH v2 3/6 rust: alloc: vmalloc: implement Vmalloc::to_page()
In reply to Danilo KrummrichImplement an abstraction of vmalloc_to_page() for subsequent use in the PageOwner implementation of VBox and VVec.
--- rust/kernel/alloc/allocator.rs | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
rust/kernel/alloc/allocator.rs +49 -0
@@ -15,6 +15,7 @@use crate ::alloc::{AllocError ,Allocator };use crate ::bindings; +use crate ::page;use crate ::pr_warn;/// The contiguous kernel allocator.
@@ -140,6 +141,54 @@ unsafe fn realloc( } } +impl Vmalloc { +/// Convert a pointer to a [`Vmalloc`] allocation to a [`page::BorrowedPage`]. +/// +/// # Examples +/// +/// ``` +/// # use core::ptr::{NonNull, from_mut}; +/// # use kernel::{page, prelude::*}; +/// use kernel::alloc::allocator::Vmalloc; +/// +/// let mut vbox = VBox::<[u8; page::PAGE_SIZE]>::new_uninit(GFP_KERNEL)?; +/// +/// { +/// // SAFETY: By the type invariant of `Box` the inner pointer of `vbox` is non-null. +/// let ptr = unsafe { NonNull::new_unchecked(from_mut(&mut *vbox)) }; +/// +/// // SAFETY: +/// // `ptr` is a valid pointer to a `Vmalloc` allocation. +/// // `ptr` is valid for the entire lifetime of `page`. +/// let page = unsafe { Vmalloc::to_page(ptr.cast()) }; +/// +/// // SAFETY: There is no concurrent read or write to the same page. +/// unsafe { page.fill_zero_raw(0, page::PAGE_SIZE)? }; +/// } +/// # Ok::<(), Error>(()) +/// ``` +/// +/// # Safety +/// +/// - `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> { +// 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) }; + +// 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) } + } +} +// SAFETY: `realloc` delegates to `ReallocFunc::call`, which guarantees that // - memory remains valid until it is explicitly freed, // - passing a pointer to a valid memory allocation is OK,
Signature · 1 line
2.50.1
Re: [PATCH v2 3/6] rust: alloc: vmalloc: implement Vmalloc::to_page()
Quoted 4 lines · Danilo Krummrich
Implement an abstraction of
vmalloc_to_page()for subsequent use in the PageOwner implementation of VBox and VVec.Signed-off-by Danilo Krummrich <[email protected]>
One minor nit about the example below.
Quoted 17 lines
--- rust/kernel/alloc/allocator.rs | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)rust/kernel/alloc/allocator.rs +1
-0@@ -15,6 +15,7 @@use crate ::alloc::{AllocError ,Allocator };use crate ::bindings; +use crate ::page;use crate ::pr_warn;/// The contiguous kernel allocator.
rust/kernel/alloc/allocator.rs unsafe fn realloc( · line 150
Quoted 10 lines
rust/kernel/alloc/allocator.rs +7
-0@@ -140,6 +141,54 @@ unsafe fn realloc( } } +impl Vmalloc { +/// Convert a pointer to a [`Vmalloc`] allocation to a [`page::BorrowedPage`]. +/// +/// # Examples +/// +/// ``` +/// # use core::ptr::{NonNull, from_mut};
Maybe make these imports visible, as otherwise the reader might wonder where from_mut comes from (I did :)).
Danilo Krummrich
maintainerPATCH v2 4/6 rust: alloc: layout: implement ArrayLayout::size()
In reply to Danilo KrummrichProvide a convenience method for ArrayLayout to calculate the size of the ArrayLayout in bytes.
--- rust/kernel/alloc/layout.rs | 5 +++++ 1 file changed, 5 insertions(+)
rust/kernel/alloc/layout.rs +5 -0
@@ -98,6 +98,11 @@ pub const fn len(&self) -> usize {pub const fn is_empty (&self) ->bool { self.len ==0 } + +/// Returns the size of the [`ArrayLayout`] in bytes. +pub const fn size (&self) ->usize { + self.len () * core::mem::size_of ::<T >() + } }impl <T >From <ArrayLayout <T >>for Layout {
Signature · 1 line
2.50.1
Re: [PATCH v2 4/6] rust: alloc: layout: implement ArrayLayout::size()
Quoted 4 lines · Danilo Krummrich
Provide a convenience method for ArrayLayout to calculate the size of the ArrayLayout in bytes.
Signed-off-by Danilo Krummrich <[email protected]>
One question below for my own education.
Quoted 9 lines
--- rust/kernel/alloc/layout.rs | 5 +++++ 1 file changed, 5 insertions(+)rust/kernel/alloc/layout.rs +0
-0
rust/kernel/alloc/layout.rs pub const fn len(&self) -> usize { · line 105
Quoted 8 lines
rust/kernel/alloc/layout.rs +5
-0@@ -98,6 +98,11 @@ pub const fn len(&self) -> usize {pub const fn is_empty (&self) ->bool { self.len ==0 } + +/// Returns the size of the [`ArrayLayout`] in bytes. +pub const fn size (&self) ->usize { + self.len () * core::mem::size_of ::<T >() + }
The type invariant stipulates that len * size_of::<T>() <= isize::MAX, should we mention it here to highlight that this method cannot panic, and/or use wrapping_mul to potentially simplify the generated code?
Re: [PATCH v2 4/6] rust: alloc: layout: implement ArrayLayout::size()
In reply to Danilo KrummrichQuoted 5 lines · Danilo Krummrich
Provide a convenience method for ArrayLayout to calculate the size of the ArrayLayout in bytes.
Signed-off-by Danilo Krummrich <[email protected]>---
Re: [PATCH v2 4/6] rust: alloc: layout: implement ArrayLayout::size()
In reply to Danilo KrummrichQuoted 5 lines · Danilo Krummrich
Provide a convenience method for ArrayLayout to calculate the size of the ArrayLayout in bytes.
Signed-off-by Danilo Krummrich <[email protected]>
Quoted 9 lines
--- rust/kernel/alloc/layout.rs | 5 +++++ 1 file changed, 5 insertions(+)rust/kernel/alloc/layout.rs +0
-0
rust/kernel/alloc/layout.rs pub const fn len(&self) -> usize { · line 105
Quoted 8 lines
rust/kernel/alloc/layout.rs +5
-0@@ -98,6 +98,11 @@ pub const fn len(&self) -> usize {pub const fn is_empty (&self) ->bool { self.len ==0 } + +/// Returns the size of the [`ArrayLayout`] in bytes. +pub const fn size (&self) ->usize { + self.len () * core::mem::size_of ::<T >() + }
I believe Miguel added size_of to the prelude.
Alice
Danilo Krummrich
maintainerPATCH v2 5/6 rust: alloc: kbox: implement PageOwner for VBox
In reply to Danilo KrummrichImplement the PageOwner trait for VBox; it allows to iterate and borrow the backing pages of a VBox. This, for instance, is useful in combination with VBox backing a scatterlist.
--- rust/kernel/alloc/kbox.rs | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
rust/kernel/alloc/kbox.rs +42 -0
@@ -18,6 +18,7 @@use crate ::ffi::c_void;use crate ::init::InPlaceInit ; +use crate ::page;use crate ::types::ForeignOwnable ;use pin_init::{InPlaceWrite ,Init ,PinInit ,ZeroableOption };
@@ -598,3 +599,44 @@ fn drop(&mut self) {unsafe {A ::free (self.0 .cast (), layout) }; } } + +/// # Examples +/// +/// ``` +/// # use kernel::{page, prelude::*}; +/// use kernel::page::PageOwner; +/// +/// let mut vbox = VBox::<[u8; page::PAGE_SIZE]>::new_uninit(GFP_KERNEL)?; +/// +/// let page = vbox.page_iter().next().expect("At least one page should be available.\n"); +/// +/// // SAFETY: There is no concurrent read or write to the same page. +/// unsafe { page.fill_zero_raw(0, page::PAGE_SIZE)? }; +/// # Ok::<(), Error>(()) +/// ``` +impl <T > page::PageOwner for VBox <T > { +fn page_iter <'a>(&'amut self) ->impl Iterator <Item = page::BorrowedPage <'a>> { + (0 ..self.page_count ()).map (|idx| { +let ptr = self.0 .as_ptr ().cast ::<u8 >(); + +// TODO: Use `NonNull::add()` instead, once the minimum supported compiler version is +// bumped to 1.80 or later. +// +// SAFETY: `idx` is in the interval `[0, self.page_count())`, hence the resulting +// pointer is guaranteed to be within the same allocation. +let ptr =unsafe { ptr.add (idx * page::PAGE_SIZE ) }; + +// SAFETY: `ptr` is guaranteed to be non-null given that it is derived from `self.0`. +let ptr =unsafe {NonNull ::new_unchecked (ptr) }; + +// SAFETY: +// - `ptr` is a valid pointer to a `Vmalloc` allocation. +// - `ptr` is valid for the duration of `'a`. +unsafe {Vmalloc ::to_page (ptr) } + }) + } + +fn page_count (&self) ->usize { + core::mem::size_of ::<T >().div_ceil (page::PAGE_SIZE ) + } +}
Signature · 1 line
2.50.1
Re: [PATCH v2 5/6] rust: alloc: kbox: implement PageOwner for VBox
Quoted 5 lines · Danilo Krummrich
Implement the PageOwner trait for VBox; it allows to iterate and borrow the backing pages of a VBox. This, for instance, is useful in combination with VBox backing a scatterlist.
Signed-off-by Danilo Krummrich <[email protected]>
Re: [PATCH v2 5/6] rust: alloc: kbox: implement PageOwner for VBox
In reply to Danilo KrummrichQuoted 6 lines · Danilo Krummrich
Implement the PageOwner trait for VBox; it allows to iterate and borrow the backing pages of a VBox. This, for instance, is useful in combination with VBox backing a scatterlist.
Signed-off-by Danilo Krummrich <[email protected]>---
Danilo Krummrich
maintainerPATCH v2 6/6 rust: alloc: kvec: implement PageOwner for VVec
In reply to Danilo KrummrichImplement the PageOwner trait for VVec; it allows to iterate and borrow the backing pages of a VVec. This, for instance, is useful in combination with VBox backing a scatterlist.
--- rust/kernel/alloc/kvec.rs | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
rust/kernel/alloc/kvec.rs +40 -0
@@ -21,6 +21,7 @@ slice, slice::SliceIndex, }; +use kernel::page;mod errors;pub use self::errors::{InsertError ,PushError ,RemoveError };
@@ -1017,6 +1018,45 @@ fn into_iter(self) -> Self::IntoIter { } } +/// # Examples +/// +/// ``` +/// # use kernel::{page, prelude::*}; +/// use kernel::page::PageOwner; +/// +/// let mut vec = VVec::<u8>::new(); +/// vec.reserve(page::PAGE_SIZE, GFP_KERNEL)?; +/// +/// let page = vec.page_iter().next().expect("At least one page should be available.\n"); +/// +/// // SAFETY: There is no concurrent read or write to the same page. +/// unsafe { page.fill_zero_raw(0, page::PAGE_SIZE)? }; +/// # Ok::<(), Error>(()) +/// ``` +impl <T > page::PageOwner for VVec <T > { +fn page_iter <'a>(&'amut self) ->impl Iterator <Item = page::BorrowedPage <'a>> { + (0 ..self.page_count ()).map (|idx| { +let ptr = self.as_mut_ptr ().cast ::<u8 >(); + +// SAFETY: `idx` is in the interval `[0, self.page_count())`, hence the resulting +// pointer is guaranteed to be within the same allocation. +let ptr =unsafe { ptr.add (idx * page::PAGE_SIZE ) }; + +// SAFETY: `ptr` is guaranteed to be non-null given that it is derived from `self.0`. +let ptr =unsafe {NonNull ::new_unchecked (ptr) }; + +// SAFETY: +// - `ptr` is a valid pointer to a `Vmalloc` allocation. +// - `ptr` is valid for the duration of `'a`. +unsafe {Vmalloc ::to_page (ptr) } + }) + } + +fn page_count (&self) ->usize { + self.layout.size ().div_ceil (page::PAGE_SIZE ) + } +} +/// An [`Iterator`] implementation for [`Vec`] that moves elements out of a vector. /// /// This structure is created by the [`Vec::into_iter`] method on [`Vec`] (provided by the
Signature · 1 line
2.50.1
Re: [PATCH v2 6/6] rust: alloc: kvec: implement PageOwner for VVec
Quoted 5 lines · Danilo Krummrich
Implement the PageOwner trait for VVec; it allows to iterate and borrow the backing pages of a VVec. This, for instance, is useful in combination with VBox backing a scatterlist.
Signed-off-by Danilo Krummrich <[email protected]>
Re: [PATCH v2 6/6] rust: alloc: kvec: implement PageOwner for VVec
In reply to Danilo KrummrichQuoted 6 lines · Danilo Krummrich
Implement the PageOwner trait for VVec; it allows to iterate and borrow the backing pages of a VVec. This, for instance, is useful in combination with VBox backing a scatterlist.
Signed-off-by Danilo Krummrich <[email protected]>---
Quoted 1 line · Danilo Krummrich
This patch series implements the BorrowedPage type and the PageOwner trait.
Note that we have mm/page_owner.c already so there might be a bit of a name clash and confuse someone. But maybe it's sufficiently distinct.
Quoted 35 lines
The latter can be implemented by any entity that potentially owns one or multiple pages and allow users to borrow them.
For instance, this is useful to access and borrow the backing pages of allocation primitives, such as Box and Vec, backing a scatterlist.
Hence, implement PageOwner for VBox and VVec.
Additionally, implement
Vmalloc::to_page()andArrayLayout::size(), which are dependencies of the above.Changes in v2:
- BorrowedPage
- Add link to Ownable
- Useborrow_page()in the example
- Add PageOwner,Vmalloc::to_page(), ArrayLayout, VBox, VVec patches.Danilo Krummrich (6):
rust: page: implement BorrowedPage
rust: page: define PageOwner trait
rust: alloc: vmalloc: implementVmalloc::to_page()
rust: alloc: layout: implementArrayLayout::size()
rust: alloc: kbox: implement PageOwner for VBox
rust: alloc: kvec: implement PageOwner for VVecrust/bindings/bindings_helper.h | 1 + rust/kernel/alloc/allocator.rs | 49 +++++++++++++++++++ rust/kernel/alloc/kbox.rs | 42 ++++++++++++++++ rust/kernel/alloc/kvec.rs | 40 +++++++++++++++ rust/kernel/alloc/layout.rs | 5 ++ rust/kernel/page.rs | 87 ++++++++++++++++++++++++++++++++- 6 files changed, 223 insertions(+), 1 deletion(-)base-commit:
d2eedaa3909be9102d648a4a0a50ccf64f96c54f
Danilo Krummrich
maintainerQuoted 5 lines · Vlastimil Babka
Quoted 1 line · Danilo Krummrich
This patch series implements the BorrowedPage type and the PageOwner trait.
Note that we have
mm/page_owner.calready so there might be a bit of a name clash and confuse someone. But maybe it's sufficiently distinct.
Yeah, I'm aware of this debugging feature. But as you say, I also thought it's sufficiently distinct; and given that it's just the name of a trait I don't think it will lead to confusion for people interacting with the API.
Just shaped up the 4th revision of scatterlist on top of these patches and works great. I can confirm that it is now able to directly work with a VVec buffer, eliminating the need for a custom vmalloc_to_page() glue. Will send the next revision soon after some minor clean-ups.
Quoted 37 lines · Danilo Krummrich
This patch series implements the BorrowedPage type and the PageOwner trait.
The latter can be implemented by any entity that potentially owns one or multiple pages and allow users to borrow them.
For instance, this is useful to access and borrow the backing pages of allocation primitives, such as Box and Vec, backing a scatterlist.
Hence, implement PageOwner for VBox and VVec.
Additionally, implement
Vmalloc::to_page()andArrayLayout::size(), which are dependencies of the above.Changes in v2:
- BorrowedPage
- Add link to Ownable
- Useborrow_page()in the example
- Add PageOwner,Vmalloc::to_page(), ArrayLayout, VBox, VVec patches.Danilo Krummrich (6):
rust: page: implement BorrowedPage
rust: page: define PageOwner trait
rust: alloc: vmalloc: implementVmalloc::to_page()
rust: alloc: layout: implementArrayLayout::size()
rust: alloc: kbox: implement PageOwner for VBox
rust: alloc: kvec: implement PageOwner for VVecrust/bindings/bindings_helper.h | 1 + rust/kernel/alloc/allocator.rs | 49 +++++++++++++++++++ rust/kernel/alloc/kbox.rs | 42 ++++++++++++++++ rust/kernel/alloc/kvec.rs | 40 +++++++++++++++ rust/kernel/alloc/layout.rs | 5 ++ rust/kernel/page.rs | 87 ++++++++++++++++++++++++++++++++- 6 files changed, 223 insertions(+), 1 deletion(-)base-commit:
d2eedaa3909be9102d648a4a0a50ccf64f96c54f