Module mmap

Module mmap 

Source
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/meminfo to determine if huge pages are available for use.

Structs§

HugePageInfo
Contains information about the system’s huge page configuration.
OwnedMmap
A safe wrapper for a memory-mapped region.

Functions§

get_hugepage_info
Parses /proc/meminfo to get information about huge pages.