@@ -13,7 +13,7 @@ use core::alloc::Layout;
1313use core:: ptr;
1414use core:: ptr:: NonNull ;
1515
16- use crate :: alloc:: { AllocError , Allocator } ;
16+ use crate :: alloc:: { AllocError , Allocator , NumaNode } ;
1717use crate :: bindings;
1818use crate :: pr_warn;
1919
@@ -56,20 +56,25 @@ fn aligned_size(new_layout: Layout) -> usize {
5656
5757/// # Invariants
5858///
59- /// One of the following: `krealloc `, `vrealloc `, `kvrealloc `.
59+ /// One of the following: `krealloc_node `, `vrealloc_node `, `kvrealloc_node `.
6060struct ReallocFunc (
61- unsafe extern "C" fn ( * const crate :: ffi:: c_void , usize , u32 ) -> * mut crate :: ffi:: c_void ,
61+ unsafe extern "C" fn (
62+ * const crate :: ffi:: c_void ,
63+ usize ,
64+ u32 ,
65+ crate :: ffi:: c_int ,
66+ ) -> * mut crate :: ffi:: c_void ,
6267) ;
6368
6469impl ReallocFunc {
65- // INVARIANT: `krealloc ` satisfies the type invariants.
66- const KREALLOC : Self = Self ( bindings:: krealloc ) ;
70+ // INVARIANT: `krealloc_node ` satisfies the type invariants.
71+ const KREALLOC : Self = Self ( bindings:: krealloc_node ) ;
6772
68- // INVARIANT: `vrealloc ` satisfies the type invariants.
69- const VREALLOC : Self = Self ( bindings:: vrealloc ) ;
73+ // INVARIANT: `vrealloc_node ` satisfies the type invariants.
74+ const VREALLOC : Self = Self ( bindings:: vrealloc_node ) ;
7075
71- // INVARIANT: `kvrealloc ` satisfies the type invariants.
72- const KVREALLOC : Self = Self ( bindings:: kvrealloc ) ;
76+ // INVARIANT: `kvrealloc_node ` satisfies the type invariants.
77+ const KVREALLOC : Self = Self ( bindings:: kvrealloc_node ) ;
7378
7479 /// # Safety
7580 ///
@@ -87,6 +92,7 @@ impl ReallocFunc {
8792 layout : Layout ,
8893 old_layout : Layout ,
8994 flags : Flags ,
95+ nid : NumaNode ,
9096 ) -> Result < NonNull < [ u8 ] > , AllocError > {
9197 let size = aligned_size ( layout) ;
9298 let ptr = match ptr {
@@ -110,7 +116,7 @@ impl ReallocFunc {
110116 // - Those functions provide the guarantees of this function.
111117 let raw_ptr = unsafe {
112118 // If `size == 0` and `ptr != NULL` the memory behind the pointer is freed.
113- self . 0 ( ptr. cast ( ) , size, flags. 0 ) . cast ( )
119+ self . 0 ( ptr. cast ( ) , size, flags. 0 , nid . 0 ) . cast ( )
114120 } ;
115121
116122 let ptr = if size == 0 {
@@ -134,9 +140,10 @@ unsafe impl Allocator for Kmalloc {
134140 layout : Layout ,
135141 old_layout : Layout ,
136142 flags : Flags ,
143+ nid : NumaNode ,
137144 ) -> Result < NonNull < [ u8 ] > , AllocError > {
138145 // SAFETY: `ReallocFunc::call` has the same safety requirements as `Allocator::realloc`.
139- unsafe { ReallocFunc :: KREALLOC . call ( ptr, layout, old_layout, flags) }
146+ unsafe { ReallocFunc :: KREALLOC . call ( ptr, layout, old_layout, flags, nid ) }
140147 }
141148}
142149
@@ -151,6 +158,7 @@ unsafe impl Allocator for Vmalloc {
151158 layout : Layout ,
152159 old_layout : Layout ,
153160 flags : Flags ,
161+ nid : NumaNode ,
154162 ) -> Result < NonNull < [ u8 ] > , AllocError > {
155163 // TODO: Support alignments larger than PAGE_SIZE.
156164 if layout. align ( ) > bindings:: PAGE_SIZE {
@@ -160,7 +168,7 @@ unsafe impl Allocator for Vmalloc {
160168
161169 // SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously
162170 // allocated with this `Allocator`.
163- unsafe { ReallocFunc :: VREALLOC . call ( ptr, layout, old_layout, flags) }
171+ unsafe { ReallocFunc :: VREALLOC . call ( ptr, layout, old_layout, flags, nid ) }
164172 }
165173}
166174
@@ -175,6 +183,7 @@ unsafe impl Allocator for KVmalloc {
175183 layout : Layout ,
176184 old_layout : Layout ,
177185 flags : Flags ,
186+ nid : NumaNode ,
178187 ) -> Result < NonNull < [ u8 ] > , AllocError > {
179188 // TODO: Support alignments larger than PAGE_SIZE.
180189 if layout. align ( ) > bindings:: PAGE_SIZE {
@@ -184,6 +193,6 @@ unsafe impl Allocator for KVmalloc {
184193
185194 // SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously
186195 // allocated with this `Allocator`.
187- unsafe { ReallocFunc :: KVREALLOC . call ( ptr, layout, old_layout, flags) }
196+ unsafe { ReallocFunc :: KVREALLOC . call ( ptr, layout, old_layout, flags, nid ) }
188197 }
189198}
0 commit comments