@@ -15,7 +15,6 @@ use core::ptr::NonNull;
1515
1616use crate :: alloc:: { AllocError , Allocator , NumaNode } ;
1717use crate :: bindings;
18- use crate :: pr_warn;
1918
2019/// The contiguous kernel allocator.
2120///
@@ -56,25 +55,26 @@ fn aligned_size(new_layout: Layout) -> usize {
5655
5756/// # Invariants
5857///
59- /// One of the following: `krealloc_node `, `vrealloc_node `, `kvrealloc_node `.
58+ /// One of the following: `krealloc_node_align `, `vrealloc_node_align `, `kvrealloc_node_align `.
6059struct ReallocFunc (
6160 unsafe extern "C" fn (
6261 * const crate :: ffi:: c_void ,
6362 usize ,
63+ crate :: ffi:: c_ulong ,
6464 u32 ,
6565 crate :: ffi:: c_int ,
6666 ) -> * mut crate :: ffi:: c_void ,
6767) ;
6868
6969impl ReallocFunc {
70- // INVARIANT: `krealloc_node ` satisfies the type invariants.
71- const KREALLOC : Self = Self ( bindings:: krealloc_node ) ;
70+ // INVARIANT: `krealloc_node_align ` satisfies the type invariants.
71+ const KREALLOC : Self = Self ( bindings:: krealloc_node_align ) ;
7272
73- // INVARIANT: `vrealloc_node ` satisfies the type invariants.
74- const VREALLOC : Self = Self ( bindings:: vrealloc_node ) ;
73+ // INVARIANT: `vrealloc_node_align ` satisfies the type invariants.
74+ const VREALLOC : Self = Self ( bindings:: vrealloc_node_align ) ;
7575
76- // INVARIANT: `kvrealloc_node ` satisfies the type invariants.
77- const KVREALLOC : Self = Self ( bindings:: kvrealloc_node ) ;
76+ // INVARIANT: `kvrealloc_node_align ` satisfies the type invariants.
77+ const KVREALLOC : Self = Self ( bindings:: kvrealloc_node_align ) ;
7878
7979 /// # Safety
8080 ///
@@ -116,7 +116,7 @@ impl ReallocFunc {
116116 // - Those functions provide the guarantees of this function.
117117 let raw_ptr = unsafe {
118118 // If `size == 0` and `ptr != NULL` the memory behind the pointer is freed.
119- self . 0 ( ptr. cast ( ) , size, flags. 0 , nid. 0 ) . cast ( )
119+ self . 0 ( ptr. cast ( ) , size, layout . align ( ) , flags. 0 , nid. 0 ) . cast ( )
120120 } ;
121121
122122 let ptr = if size == 0 {
@@ -160,12 +160,6 @@ unsafe impl Allocator for Vmalloc {
160160 flags : Flags ,
161161 nid : NumaNode ,
162162 ) -> Result < NonNull < [ u8 ] > , AllocError > {
163- // TODO: Support alignments larger than PAGE_SIZE.
164- if layout. align ( ) > bindings:: PAGE_SIZE {
165- pr_warn ! ( "Vmalloc does not support alignments larger than PAGE_SIZE yet.\n " ) ;
166- return Err ( AllocError ) ;
167- }
168-
169163 // SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously
170164 // allocated with this `Allocator`.
171165 unsafe { ReallocFunc :: VREALLOC . call ( ptr, layout, old_layout, flags, nid) }
@@ -185,12 +179,6 @@ unsafe impl Allocator for KVmalloc {
185179 flags : Flags ,
186180 nid : NumaNode ,
187181 ) -> Result < NonNull < [ u8 ] > , AllocError > {
188- // TODO: Support alignments larger than PAGE_SIZE.
189- if layout. align ( ) > bindings:: PAGE_SIZE {
190- pr_warn ! ( "KVmalloc does not support alignments larger than PAGE_SIZE yet.\n " ) ;
191- return Err ( AllocError ) ;
192- }
193-
194182 // SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously
195183 // allocated with this `Allocator`.
196184 unsafe { ReallocFunc :: KVREALLOC . call ( ptr, layout, old_layout, flags, nid) }
0 commit comments