vm_ctx_init_with_ranges(9)
π vm_ctx_init_with_ranges β a Kernel API Manual moment π
okay so bestie, welcome to vm_ctx_init_with_ranges(9) from the Kernel API Manual β yes the whole page is literally named after the function, main character energy fr fr. she's a 9 (kernel API section) and she's here to set up virtual memory for a context. let's get into it β¨
πΈ NAME πΈ
vm_ctx_init_with_ranges β initialize virtual memory for context. that's it, that's the vibe π
π SYNOPSIS π
int vm_ctx_init_with_ranges (struct hl_ctx *ctx , u64 host_range_start ,
u64 host_range_end , u32 host_page_size , u64 host_huge_range_start ,
u64 host_huge_range_end , u32 host_huge_page_size , u64 dram_range_start
, u64 dram_range_end , u32 dram_page_size );
look at all those parameters. she's thorough. she's detailed. she does NOT do one-liners π«Ά
β¨ ARGUMENTS β¨
time to meet the whole cast, no skips:
ctxβ pointer to the habanalabs context structure. the main character, everyone else is supporting πhost_range_startβ host virtual addresses range start. where the host range begins, periodt.host_range_endβ host virtual addresses range end. where it stops, so you know π¦host_page_sizeβ host page size. the size. of the host pages. iconic.host_huge_range_startβ host virtual addresses range start for memory allocated with huge pages. yes, huge. she's big, she's bold, she has her own range πhost_huge_range_endβ host virtual addresses range end for memory allocated with huge pages. huge range ends here bestie πΈhost_huge_page_sizeβ host huge page size. the size of the huge ones, obviously πdram_range_startβ dram virtual addresses range start. now we're in DRAM territory π₯dram_range_endβ dram virtual addresses range end. DRAM range wraps up here.dram_page_sizeβ dram page size. last one, and she ate β
π¦ DESCRIPTION π¦
okay so this function initializes the following, and ngl the list is giving "getting ready for the group chat" energy:
- MMU for context. she's setting up the memory management unit for the context, as one does π
- Virtual address to area descriptor hashtable. hashtable! very organized, very slay π
- Virtual block list of available virtual memory. cataloging what VM is free, iykyk.
that's literally all three things. no more, no less. she knows her job and she does it π
π SEE ALSO π
grab a snack, this is a long one β but every single reference is here because we do NOT gatekeep:
kernel file: ./drivers/accel/habanalabs/common/memory.c
dma_map_host_va(9), dma_unmap_host_va(9), dram_pg_pool_do_release(9), free_phys_pg_pack(9), free_device_memory(9), clear_va_list_locked(9), print_va_list_locked(9), merge_va_blocks_locked(9), add_va_block_locked(9), add_va_block(9), is_hint_crossing_range(9), get_va_block(9), hl_get_va_range_type(9), hl_unreserve_va_block(9), init_phys_pg_pack_from_userptr(9), map_phys_pg_pack(9), unmap_phys_pg_pack(9), map_device_va(9), unmap_device_va(9), hl_hw_block_mmap(9), export_dmabuf_from_addr(9), allocate_timestamps_buffers(9), hl_pin_host_memory(9), hl_userptr_delete_list(9), hl_userptr_is_pinned(9), va_range_init(9), va_range_fini(9), hl_vm_ctx_fini(9), hl_vm_init(9), hl_vm_fini(9), hl_hw_block_mem_init(9), hl_hw_block_mem_fini(9)
go read them. all of them. I'll wait π«Ά
and that's the whole page, bestie β¨ she's sourced from ./drivers/accel/habanalabs/common and dated October 2026 β stamped for your reading pleasure by the Kernel API Manual. mwah π
π¦ 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