ibv_alloc_null_mr(3)

πŸ’… ibv_alloc_null_mr(3) β€” the Libibverbs Programmer's Manual, bestie edition

Okay so real talk, this one lives in the Libibverbs Programmer's Manual and it's literally called ibv_alloc_null_mr ✨


🌸 NAME 🌸

ibv_alloc_null_mr β€” allocate a null memory region (MR) 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <infiniband/verbs.h>

struct ibv_mr *ibv_alloc_null_mr(struct ibv_pd *pd);

No cap, that's the whole thing. One include, one function call, one pd. Clean. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So ibv_alloc_null_mr() allocates a null memory region (MR) that's associated with the protection domain pd. Think of it as the MR that's too cool to actually hold your data 😌

Here's the vibe: a null MR discards all data written to it, and it always returns 0 on read. Iconic behavior honestly. It has the maximum length, and only the lkey is valid β€” the MR is not exposed as an rkey. Periodt. πŸ’€

A device should implement the null MR in a way that bypasses PCI transfers, internally discarding or sourcing 0 data. Why do we care? Because this gives you a way to avoid PCI bus transfers by using a scatter/gather list in commands β€” super useful if your app doesn't actually intend to access the data, or if it needs the data to be 0 filled. 🧚

Specifically bestie, pay attention:

  • upon ibv_post_send() the device skips PCI read cycles πŸ”₯
  • upon ibv_post_recv() the device skips PCI write cycles πŸ”₯

...which finally improves performance. We love a glow-up that's also a speed-up. ⭐

ibv_dereg_mr() deregisters the MR. That's your cleanup era. 🧹

🚨 Heads up, bestie: the use of ibv_rereg_mr() or ibv_bind_mw() with this MR is invalid. Don't do it. Just don't. πŸ™ˆ

✨ RETURN VALUE ✨

ibv_alloc_null_mr() returns a pointer to the allocated MR, or NULL if the request fails. 😭 That's it, that's the return value. Simple. Elegant. Main character energy. πŸ‘‘


πŸ’œ SEE ALSO πŸ’œ

(yes, the trailing comma is canon, iykyk πŸŽ€)


🌈 AUTHOR 🌈

Yonatan Cohen <yonatanc@mellanox.com> β€” thank you for your service 🫢


Alright bestie, that's the whole page! This little gem comes to you courtesy of libibverbs, dated 2018-6-1, and it's filed under ibv_alloc_null_mr(3) in the Libibverbs Programmer's Manual. Go forth and allocate your nulls πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from