IBV_ALLOC_TD(3)

πŸ’… ibv_alloc_td β€” the Libibverbs Programmer's Manual, but make it cute πŸ¦‹

okay bestie, welcome to the ibv_alloc_td(3) page from the libibverbs programmer's manual. we're talking thread domains today and honestly? they're lowkey iconic. let's get into it ✨


🌸 NAME 🌸

ibv_alloc_td(), ibv_dealloc_td() β€” allocate and deallocate a thread domain object 🧚


⭐ SYNOPSIS ⭐

#include <infiniband/verbs.h>

struct ibv_td *ibv_alloc_td(struct ibv_context *context,
                            struct ibv_td_init_attr *init_attr);

int ibv_dealloc_td(struct ibv_td *td);

like, copy that include exactly, no cap 🫢


πŸ’– DESCRIPTION πŸ’–

so ibv_alloc_td() allocates a thread domain object for the RDMA device context context. that's the whole vibe.

and what even is a thread domain, you ask? bestie. the thread domain object defines how the verbs libraries and the provider will use locks and additional hardware capabilities to achieve best performance for handling multi-thread or single-thread protection. it's giving ✨performance optimization✨. an application assigns verbs resources to a thread domain when it creates a verbs object. periodt.

here's the tea though πŸ‘€ β€” if the ibv_td object is specified, then any objects created under this thread domain will disable internal locking designed to protect against concurrent access to that object from multiple user threads. so yeah, you're turning off the safety rails, no biggie, just be aware fr fr.

but wait, don't panic: by default all verbs objects are safe for multi-threaded access, whether or not a thread domain is specified. so if you do nothing, you're fine πŸ’….

also a struct ibv_td can be added to a parent domain via ibv_alloc_parent_domain(), and then the parent domain can be used to create verbs objects. nesting!! we love to see it 🌈

now ibv_dealloc_td() will deallocate the thread domain td.

⚠️ okay important bestie: all resources created with the td should be destroyed prior to deallocating the td. clean up your room before you move out, okay? 🧹✨

πŸ”₯ RETURN VALUE πŸ”₯

  • ibv_alloc_td() returns a pointer to the allocated struct ibv_td object, or NULL if the request fails (and sets errno to indicate the failure reason). so if you get NULL, check errno, she's telling you what went wrong πŸ™ˆ
  • ibv_dealloc_td() returns 0 on success, or the value of errno on failure (which indicates the failure reason). zero is the slay, anything else is a vibe check fail 😭

πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’œ AUTHORS πŸ’œ

  • Alex Rosenbaum <alexr@mellanox.com>
  • Yishai Hadas <yishaih@mellanox.com>

and that's the whole page, bestie! this masterpiece came out of libibverbs, dated 2017-11-06, and it's been serving ever since πŸ’– thanks for reading, now go destroy your resources before you dealloc your td, mwah πŸ«Άβœ¨πŸŽ€

πŸ“¦ where this page comes from