From 91ccf4e6aa904af4fc46d112b406a27a551ef9f6 Mon Sep 17 00:00:00 2001 From: Andrey Turkin Date: Tue, 22 Oct 2024 22:14:39 +0300 Subject: [PATCH] Fix a bump allocator error --- src/allocator/frame/bump.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/allocator/frame/bump.rs b/src/allocator/frame/bump.rs index 792bc7c9e3..ee897feb80 100644 --- a/src/allocator/frame/bump.rs +++ b/src/allocator/frame/bump.rs @@ -46,8 +46,9 @@ impl FrameAllocator for BumpAllocator { let block = loop { let area = self.cur_areas.0.first()?; let off = self.cur_areas.1; - if area.size - off <= req_size { + if area.size - off < req_size { self.cur_areas = (&self.cur_areas.0[1..], 0); + continue; } self.cur_areas.1 += req_size; @@ -64,6 +65,6 @@ impl FrameAllocator for BumpAllocator { unsafe fn usage(&self) -> FrameUsage { let total = self.orig_areas.0.iter().map(|a| a.size).sum::() - self.orig_areas.1; let free = self.cur_areas.0.iter().map(|a| a.size).sum::() - self.cur_areas.1; - FrameUsage::new(FrameCount::new(total - free), FrameCount::new(total)) + FrameUsage::new(FrameCount::new((total - free) / A::PAGE_SIZE), FrameCount::new(total / A::PAGE_SIZE)) } }