Expand description
§Memory Mapping for UMEM
§Purpose
This module provides safe abstractions for creating and managing memory-mapped (mmap)
regions, specifically for the AF_XDP UMEM (Userspace Memory). The UMEM is a critical
component for achieving zero-copy performance.
§How it works
It defines an OwnedMmap struct that encapsulates a raw pointer to a memory-mapped
region and its size. This struct’s implementation handles the low-level libc::mmap
call for allocation and libc::munmap in its Drop implementation to ensure the
memory is safely released. It also includes logic to check for and optionally use
huge pages to back the UMEM, which can improve performance by reducing TLB misses.
§Main components
OwnedMmap: A struct that acts as a safe owner of a memory-mapped region.get_hugepage_info(): A helper function that parses/proc/meminfoto determine if huge pages are available for use.
Structs§
- Huge
Page Info - Contains information about the system’s huge page configuration.
- Owned
Mmap - A safe wrapper for a memory-mapped region.
Functions§
- get_
hugepage_ info - Parses
/proc/meminfoto get information about huge pages.