ib_map_mr_sg(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 check
  • sg β€” a dma mapped scatterlist πŸ¦‹
  • sg_nents β€” how many entries live in sg, literally just the count bestie
  • sg_offset β€” offset in bytes into sg, yes bytes, don't @ me
  • page_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 sg element is allowed to have an offset. she gets a little grace period, we love that for her
  • πŸ’… each sg element must either be aligned to page_size or be virtually contiguous to the previous element. and if an sg element has a non-contiguous offset β€” the mapping prefix will not include it 🚫 that one's not invited to the party
  • πŸŽ€ the last sg element is allowed to have a length less than page_size (short king behavior, iconic)
  • ⭐ if sg_nents total byte length exceeds the mr max_num_sge * page_size then only max_num_sg entries 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 the page_size argument 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