ib_map_mr_sg(9)
π ib_map_mr_sg(9) β the Kernel API Manual glow-up π
okay bestie, welcome to ib_map_mr_sg(9) from the Kernel API Manual β¨ this one's short but she's important β she maps stuff and sets stuff and honestly she ate π
β¨ NAME β¨
ib_map_mr_sg β maps the biggest prefix of a dma mapped SG list and then sets it on the memory region π«Ά like, she takes what she can get and commits to it, main character energy fr fr.
π¦ SYNOPSIS π¦
int ib_map_mr_sg (struct ib_mr *mr , struct scatterlist *sg , int
sg_nents , unsigned int *sg_offset , unsigned int page_size );
she returns an int, no cap π
πΈ ARGUMENTS πΈ
mrβ the memory region π that's the whole point of the vibe checksgβ a dma mapped scatterlist π¦sg_nentsβ how many entries live insg, literally just the count bestiesg_offsetβ offset in bytes intosg, yes bytes, don't @ mepage_sizeβ the page vector desired page size π "desired" is doing a lot of work there iykyk
π DESCRIPTION π
so there are constraints, and we respect them πβ¨ not me being obsessed with rules but like, here they are:
- π«Ά the first
sgelement is allowed to have an offset. she gets a little grace period, we love that for her - π
each
sgelement must either be aligned topage_sizeor be virtually contiguous to the previous element. and if ansgelement has a non-contiguous offset β the mapping prefix will not include it π« that one's not invited to the party - π the last
sgelement is allowed to have a length less thanpage_size(short king behavior, iconic) - β if
sg_nentstotal byte length exceeds themrmax_num_sge * page_sizethen onlymax_num_sgentries will be mapped. that's the cap bestie, that's the limit - π₯ if the MR was allocated with type
IB_MR_TYPE_SG_GAPS, none of these constraints hold and thepage_sizeargument is ignored π literally ghosted
π what she gives back
Returns the number of sg elements that were mapped to the memory region π count them, love them.
after this completes successfully, the memory region is ready for registration π like she's all dressed up and ready to go out. but successfully is doing heavy lifting β don't skip that word π
π§ SEE ALSO π§
the whole friend group showed up, no gatekeeping here:
Kernel file ./drivers/infiniband/core/verbs.c, __ib_alloc_pd(9), ib_dealloc_pd_user(9), rdma_copy_ah_attr(9), rdma_replace_ah_attr(9), rdma_move_ah_attr(9), rdma_create_ah(9), rdma_create_user_ah(9), rdma_move_grh_sgid_attr(9), rdma_destroy_ah_attr(9), ib_create_srq_user(9), ib_create_qp_user(9), ib_resolve_eth_dmac(9), ib_modify_qp_with_udata(9), ib_alloc_mr(9), ib_alloc_mr_integrity(9), ib_alloc_xrcd_user(9), ib_dealloc_xrcd_user(9), ib_create_wq(9), ib_destroy_wq_user(9), ib_map_mr_sg_pi(9), ib_sg_to_pages(9), ib_drain_sq(9), ib_drain_rq(9), ib_drain_qp(9), rdma_alloc_hw_stats_struct(9), rdma_free_hw_stats_struct(9)
okay that's the whole page, mwah π
πΈ from the ./drivers/infiniband/core girlies, dated October 2026, page ib_map_mr_sg(9) β stay hydrated, read your manpages, and never, ever forget that page_size is ignored for IB_MR_TYPE_SG_GAPS πβ¨π
π¦ 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