cma_declare_contiguous_nid(9)
π cma_declare_contiguous_nid(9) π
okay so this is a page straight out of the Kernel API Manual, and it's literally about carving out your own custom contiguous memory area. bestie, it's giving "I made this block myself" energy π
β¨ NAME β¨
cma_declare_contiguous_nid β reserve custom contiguous area π«Ά
πΈ SYNOPSIS πΈ
int cma_declare_contiguous_nid (phys_addr_t base , phys_addr_t size ,
phys_addr_t limit , phys_addr_t alignment , unsigned int order_per_bit ,
bool fixed , const char *name , struct cma **res_cma , int nid );
π¦ ARGUMENTS π¦
baseβ the base address of the reserved area. it's optional, so just use0if you want literally any address π«sizeβ the size of the reserved area, in bytes. yes, bytes. no cap πlimitβ end address of the reserved memory. also optional,0means any πalignmentβ alignment for the CMA area. should be a power of 2, or zero. those are your two moods β¨order_per_bitβ order of pages represented by one bit on the bitmap. that's the whole vibe π₯fixedβ a hint about where to place the reserved area. it's hinting, not demanding πnameβ the name of the area. see the functioncma_init_reserved_memπres_cmaβ pointer to store the created cma region in. that's where the good stuff lands π¦nidβ nid of the free area to find, orNUMA_NO_NODEfor any node π
β DESCRIPTION β
so this function reserves memory from the early allocator. and like β timing matters, okay? it should be called by arch specific code once the early allocator (memblock or bootmem) has been activated, and all the other subsystems have already allocated/reserved their memory. everyone else eats first, then you get your plate π
this function is the whole point: it lets you create custom reserved areas. main character energy, honestly π
if fixed is true, it reserves the contiguous area at exactly base. if it's false, it reserves in the range from base to limit. that's the difference, and it's iconic π
π SEE ALSO π
- Kernel file
./mm/cma.c cma_init_reserved_mem(9)cma_alloc(9)cma_release(9)
okay that's the whole thing, go forth and reserve your memory responsibly π§π
source: ./mm β version vibes: October 2026 π¦β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms