File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,9 @@ impl Allocator {
152
152
if let Some ( slab) = slab {
153
153
slab. alloc ( )
154
154
} else {
155
+ // the vmalloc allocator may require reverse dependency
156
+ core:: mem:: drop ( inner) ;
157
+
155
158
let size = align_up ( layout. size ( ) as _ , Size4KiB :: SIZE ) / Size4KiB :: SIZE ;
156
159
157
160
vmalloc:: get_vmalloc ( )
@@ -162,7 +165,6 @@ impl Allocator {
162
165
}
163
166
164
167
fn dealloc ( & self , ptr : * mut u8 , layout : Layout ) {
165
- let _inner = self . inner . lock_irq ( ) ;
166
168
let address = VirtAddr :: new ( ptr as u64 ) ;
167
169
168
170
if address >= vmalloc:: VMALLOC_START && address < vmalloc:: VMALLOC_END {
Original file line number Diff line number Diff line change @@ -108,16 +108,22 @@ impl Vmalloc {
108
108
. iter ( )
109
109
. find ( |area| area. protected . lock ( ) . size >= size_bytes) ?;
110
110
111
- let mut area = area. protected . lock ( ) ;
112
- let address = area . addr . clone ( ) ;
111
+ let mut area_p = area. protected . lock ( ) ;
112
+ let address = area_p . addr . clone ( ) ;
113
113
114
- if area . size > size_bytes {
115
- area . addr = area . addr + size_bytes;
116
- area . size -= size_bytes;
114
+ if area_p . size > size_bytes {
115
+ area_p . addr = area_p . addr + size_bytes;
116
+ area_p . size -= size_bytes;
117
117
} else {
118
- // the size of the area is exactly the size we need, so remove it from
119
- // the free list.
120
- log:: warn!( "todo: implement this" )
118
+ // NOTE: the area is has exactly the requested size, so we can remove it
119
+ // from the free list.
120
+ core:: mem:: drop ( area_p) ; // unlock
121
+
122
+ let area_ptr = area as * const VmallocArea ;
123
+
124
+ // SAFETY: The constructed pointer is a valid object that is in the tree,
125
+ let mut area_cursor = unsafe { self . free_list . cursor_mut_from_ptr ( area_ptr) } ;
126
+ area_cursor. remove ( ) ;
121
127
}
122
128
123
129
let mut address_space = AddressSpace :: this ( ) ;
You can’t perform that action at this time.
0 commit comments