| From stable+bounces-121477-greg=kroah.com@vger.kernel.org Fri Mar 7 23:51:40 2025 |
| From: Miguel Ojeda <ojeda@kernel.org> |
| Date: Fri, 7 Mar 2025 23:49:29 +0100 |
| Subject: rust: alloc: rename `KernelAllocator` to `Kmalloc` |
| To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sasha Levin <sashal@kernel.org>, stable@vger.kernel.org |
| Cc: Danilo Krummrich <dakr@kernel.org>, Alice Ryhl <aliceryhl@google.com>, Alyssa Ross <hi@alyssa.is>, NoisyCoil <noisycoil@disroot.org>, patches@lists.linux.dev, Miguel Ojeda <ojeda@kernel.org> |
| Message-ID: <20250307225008.779961-23-ojeda@kernel.org> |
| |
| From: Danilo Krummrich <dakr@kernel.org> |
| |
| commit 941e65531446c1eb5d573c5d30172117ebe96112 upstream. |
| |
| Subsequent patches implement `Vmalloc` and `KVmalloc` allocators, hence |
| align `KernelAllocator` to this naming scheme. |
| |
| Reviewed-by: Alice Ryhl <aliceryhl@google.com> |
| Reviewed-by: Benno Lossin <benno.lossin@proton.me> |
| Reviewed-by: Gary Guo <gary@garyguo.net> |
| Signed-off-by: Danilo Krummrich <dakr@kernel.org> |
| Link: https://lore.kernel.org/r/20241004154149.93856-4-dakr@kernel.org |
| Signed-off-by: Miguel Ojeda <ojeda@kernel.org> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| rust/kernel/alloc/allocator.rs | 6 +++--- |
| 1 file changed, 3 insertions(+), 3 deletions(-) |
| |
| --- a/rust/kernel/alloc/allocator.rs |
| +++ b/rust/kernel/alloc/allocator.rs |
| @@ -6,7 +6,7 @@ use super::{flags::*, Flags}; |
| use core::alloc::{GlobalAlloc, Layout}; |
| use core::ptr; |
| |
| -struct KernelAllocator; |
| +struct Kmalloc; |
| |
| /// Returns a proper size to alloc a new object aligned to `new_layout`'s alignment. |
| fn aligned_size(new_layout: Layout) -> usize { |
| @@ -37,7 +37,7 @@ pub(crate) unsafe fn krealloc_aligned(pt |
| } |
| |
| // SAFETY: TODO. |
| -unsafe impl GlobalAlloc for KernelAllocator { |
| +unsafe impl GlobalAlloc for Kmalloc { |
| unsafe fn alloc(&self, layout: Layout) -> *mut u8 { |
| // SAFETY: `ptr::null_mut()` is null and `layout` has a non-zero size by the function safety |
| // requirement. |
| @@ -74,7 +74,7 @@ unsafe impl GlobalAlloc for KernelAlloca |
| } |
| |
| #[global_allocator] |
| -static ALLOCATOR: KernelAllocator = KernelAllocator; |
| +static ALLOCATOR: Kmalloc = Kmalloc; |
| |
| // See <https://github.com/rust-lang/rust/pull/86844>. |
| #[no_mangle] |