Skip to content

Commit 0a3a6b8

Browse files
committed
perf(alloc): don't overalign allocations
1 parent 6efb49e commit 0a3a6b8

File tree

2 files changed

+5
-87
lines changed

2 files changed

+5
-87
lines changed

src/mm/allocator.rs

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/mm/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
//! │ │ │ │
4141
//! ```
4242
43-
pub(crate) mod allocator;
4443
pub(crate) mod device_alloc;
4544
pub(crate) mod physicalmem;
4645
pub(crate) mod virtualmem;
@@ -50,10 +49,10 @@ use core::ops::Range;
5049

5150
use align_address::Align;
5251
use free_list::{PageLayout, PageRange};
53-
use hermit_sync::Lazy;
52+
use hermit_sync::{Lazy, RawInterruptTicketMutex};
5453
pub use memory_addresses::{PhysAddr, VirtAddr};
54+
use talc::{ErrOnOom, Span, Talc, Talck};
5555

56-
use self::allocator::LockedAllocator;
5756
#[cfg(any(target_arch = "x86_64", target_arch = "riscv64"))]
5857
use crate::arch::mm::paging::HugePageSize;
5958
pub use crate::arch::mm::paging::virtual_to_physical;
@@ -64,7 +63,7 @@ use crate::{arch, env};
6463

6564
#[cfg(target_os = "none")]
6665
#[global_allocator]
67-
pub(crate) static ALLOCATOR: LockedAllocator = LockedAllocator::new();
66+
pub(crate) static ALLOCATOR: Talck<RawInterruptTicketMutex, ErrOnOom> = Talc::new(ErrOnOom).lock();
6867

6968
/// Physical and virtual address range of the 2 MiB pages that map the kernel.
7069
static KERNEL_ADDR_RANGE: Lazy<Range<VirtAddr>> = Lazy::new(|| {
@@ -276,11 +275,9 @@ pub(crate) fn init() {
276275

277276
let heap_end_addr = map_addr;
278277

278+
let arena = Span::new(heap_start_addr.as_mut_ptr(), heap_end_addr.as_mut_ptr());
279279
unsafe {
280-
ALLOCATOR.init(
281-
heap_start_addr.as_mut_ptr(),
282-
(heap_end_addr - heap_start_addr) as usize,
283-
);
280+
ALLOCATOR.lock().claim(arena).unwrap();
284281
}
285282

286283
info!("Heap is located at {heap_start_addr:p}..{heap_end_addr:p} ({map_size} Bytes unmapped)");

0 commit comments

Comments
 (0)