gen_pool_dma_alloc_align(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« gen_pool_dma_alloc_align β€” bestie edition πŸ’«

okay so this is from the Kernel API Manual and it's literally the glow-up guide for gen_pool_dma_alloc_align. it's giving "allocate special memory from the pool for DMA usage with the given alignment" and honestly? iconic.


πŸ› οΈ SYNOPSIS πŸ› οΈ

void * gen_pool_dma_alloc_align (struct gen_pool *pool , size_t size ,
dma_addr_t *dma , int align );

πŸŽ€ ARGUMENTS πŸŽ€

  • pool β€” the pool you're allocating from, bestie. that's your source.
  • size β€” number of bytes to allocate from the pool. yes, the exact byte count, no cap.
  • dma β€” the DMA-view physical address return value. use NULL if unneeded β€” like, if you don't care about the physical address, just pass NULL and move on.
  • align β€” alignment in bytes for the starting address. it's giving "make it line up precisely" energy.

✨ DESCRIPTION ✨

so what this does is allocate the requested number of bytes from the specified pool, with the given alignment restriction. like, you get your memory, and it starts at an address that's aligned the way you asked. slay.

⚠️ real talk though: this can not be used in an NMI handler on architectures without an NMI-safe cmpxchg implementation. periodt. don't try it there, it's not gonna work and that's not a vibe.

🌈 RETURN 🌈

on success, you get the virtual address of the allocated memory. on failure? you get NULL. that's it. that's the whole mood. 😭


πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./lib/genalloc.c and the whole squad:

gen_pool_create(9), gen_pool_add_owner(9), gen_pool_virt_to_phys(9), gen_pool_destroy(9), gen_pool_alloc_algo_owner(9), gen_pool_dma_alloc(9), gen_pool_dma_alloc_algo(9), gen_pool_dma_zalloc(9), gen_pool_dma_zalloc_algo(9), gen_pool_dma_zalloc_align(9), gen_pool_free_owner(9), gen_pool_for_each_chunk(9), gen_pool_has_addr(9), gen_pool_avail(9), gen_pool_size(9), gen_pool_set_algo(9), gen_pool_first_fit(9), gen_pool_first_fit_align(9), gen_pool_fixed_alloc(9), gen_pool_first_fit_order_align(9), gen_pool_best_fit(9), gen_pool_get(9), devm_gen_pool_create(9), of_gen_pool_get(9).


that's the whole page, bestie. now go allocate something aligned and live your main character kernel-dev life πŸ’…πŸ¦‹

signed, sealed, delivered by the kernel gang from ./lib β€” October 2026, version gen_pool_dma_alloc_align(9) πŸŽ€

πŸ“¦ where this page comes from