Skip to main content

allocate_phys_contiguous

Function allocate_phys_contiguous 

Source
pub(crate) fn allocate_phys_contiguous(
    token: &IrqDisabledToken,
    order: u8,
) -> Result<PhysFrame, AllocError>
Expand description

Allocate a physically contiguous block of 2^order pages.

Use when physical contiguity is required: DMA rings, MMIO-adjacent buffers, hardware tables, copy-on-write multi-page copies, kernel stacks (allocate_kernel_stack_frames), etc.

Do not use for general large kernel buffers : prefer allocate_kernel_virtual (virtually contiguous, physically fragmented) or allocate_frame for single pages.

Telemetry: increments CONTIGUOUS_ALLOC_PAGES on success and CONTIGUOUS_ALLOC_FAIL_COUNT on failure; CONTIGUOUS_FREE_PAGES on free_phys_contiguous. Those counters include every use of this allocate/free pair (DMA buffers, kernel stacks, COW multi-page blocks, etc.) : not only hardware DMA. Treat phys_contiguous_diag as overall buddy multi-page contiguous traffic.