cma_declare_contiguous_nid(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 use 0 if 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, 0 means 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 function cma_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, or NUMA_NO_NODE for 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 πŸ’€


okay that's the whole thing, go forth and reserve your memory responsibly πŸ§šπŸ’–

source: ./mm β€” version vibes: October 2026 πŸ¦‹βœ¨

πŸ“¦ where this page comes from